You are here

protected function BooleanOperator::valueValidate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueValidate()

Validate the options form.

Overrides FilterPluginBase::valueValidate

File

core/modules/views/src/Plugin/views/filter/BooleanOperator.php, line 181

Class

BooleanOperator
Simple filter to handle matching of boolean values

Namespace

Drupal\views\Plugin\views\filter

Code

protected function valueValidate($form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue([
    'options',
    'value',
  ]) == 'All' && !$form_state
    ->isValueEmpty([
    'options',
    'expose',
    'required',
  ])) {
    $form_state
      ->setErrorByName('value', $this
      ->t('You must select a value unless this is an non-required exposed filter.'));
  }
}