You are here

public function Tag::validateForm in Doubleclick for Publishers (DFP) 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/Tag.php, line 197
Contains \Drupal\dfp\Form\Tag.

Class

Tag
Form to edit and add DFP tags.

Namespace

Drupal\dfp\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (preg_match(TagInterface::ADUNIT_PATTERN_VALIDATION_REGEX, $form_state
    ->getValue('adunit'))) {
    $form_state
      ->setErrorByName('adunit', $this
      ->t('Ad Unit Patterns can only include letters, numbers, hyphens, dashes, periods, slashes and tokens.'));
  }
}