1 email.module email_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)

Implements hook_field_validate().

Possible error codes:

  • 'email_invalid': The email address is not valid

File

core/modules/email/email.module, line 28
Module file for the email module, which creates a email address field.

Code

function email_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  foreach ($items as $delta => $item) {
    if ($item['email'] != '' && !valid_email_address(trim($item['email']))) {
      $message = t('"%mail" is not a valid email address', array('%mail' => $item['email']));
      $errors[$field['field_name']][$langcode][$delta][] = array(
        'error' => 'email_invalid',
        'message' => $message,
      );
    }
  }
}