function EmailExampleGetFormPage::validateForm

Same name in other branches
  1. 3.x modules/email_example/src/Form/EmailExampleGetFormPage.php \Drupal\email_example\Form\EmailExampleGetFormPage::validateForm()

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.'));
    }
}