public function InviteSettingsForm::elementValidateEmail in User External Invite 8
Same name and namespace in other branches
- 2.0.x src/Form/InviteSettingsForm.php \Drupal\user_external_invite\Form\InviteSettingsForm::elementValidateEmail()
Validation handler to check that a string is a valid email address.
Parameters
$element:
\Drupal\Core\Form\FormStateInterface $form_state:
$complete_form:
File
- src/
Form/ InviteSettingsForm.php, line 238
Class
Namespace
Drupal\user_external_invite\FormCode
public function elementValidateEmail(&$element, FormStateInterface $form_state, &$complete_form) {
$value = $form_state
->getValue($element['#name']);
if ($value !== '' && !\Drupal::service('email.validator')
->isValid($value)) {
$form_state
->setErrorByName($element['#name'], $this
->t('@mail needs to be a valid email address.', [
'@mail' => $value,
]));
}
}