You are here

public function MoAuthCustomerSetup::validateForm in Google Authenticator / 2 Factor Authentication - 2FA 8.2

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/MoAuthCustomerSetup.php, line 362
Contains form for customer setup.

Class

MoAuthCustomerSetup
Customer setup form().

Namespace

Drupal\miniorange_2fa\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state
    ->getValues();
  if (isset($form_values['Mo_auth_customer_register_username']) && !\Drupal::service('email.validator')
    ->isValid($form_values['Mo_auth_customer_register_username']) && !isset($form_values['mo_auth_customer_otp_token']) && !isset($form_values['Mo_auth_customer_login_username']) && !isset($form_values['miniorange_hidden_value'])) {
    $form_state
      ->setErrorByName('Mo_auth_customer_register_username', $this
      ->t('The email address is not valid.'));
  }
}