You are here

public function EmailExampleGetFormPage::validateForm in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 email_example/src/Form/EmailExampleGetFormPage.php \Drupal\email_example\Form\EmailExampleGetFormPage::validateForm()

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

modules/email_example/src/Form/EmailExampleGetFormPage.php, line 104

Class

EmailExampleGetFormPage
File test form class.

Namespace

Drupal\email_example\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!$this->emailValidator
    ->isValid($form_state
    ->getValue('email'))) {
    $form_state
      ->setErrorByName('email', $this
      ->t('That e-mail address is not valid.'));
  }
}