function email_field_validate in Email Field 7
Implements hook_field_validate().
Possible error codes:
- 'email_invalid': The email address is not valid
File
- ./
email.module, line 39 - Module file for the email module, which creates a email address field.
Code
function email_field_validate($obj_type, $object, $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,
);
}
}
}