public static Email::validateEmail(&$element, FormStateInterface $form_state, &$complete_form)
Form element validation handler for #type 'email'.
Note that #maxlength and #required is validated by _form_validate() already.
public static function validateEmail(&$element, FormStateInterface $form_state, &$complete_form) { $value = trim($element['#value']); $form_state->setValueForElement($element, $value); if ($value !== '' && !\Drupal::service('email.validator')->isValid($value)) { $form_state->setError($element, t('The email address %mail is not valid.', array('%mail' => $value))); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Email.php/function/Email::validateEmail/8.1.x