You are here

function ldap_authentication_profile_update_form_validate in Lightweight Directory Access Protocol (LDAP) 7.2

Form validator for updating the profile.

See also

ldap_authentication_profile_update_form()

File

ldap_authentication/ldap_authentication.pages.inc, line 32
User-facing page callbacks for the LDAP Authentication module.

Code

function ldap_authentication_profile_update_form_validate($form, &$form_state) {
  if (!filter_var($form_state['values']['mail'], FILTER_VALIDATE_EMAIL)) {
    form_set_error('mail', t('You must specify a valid email address.'));
  }
  $existing = user_load_by_mail($form_state['values']['mail']);
  if ($existing) {
    form_set_error('mail', t('This email address is already in user.'));
  }
  $auth = ldap_authentication_get_valid_conf();
  $regex = '`' . $auth->templateUsagePromptRegex . '`i';
  if (preg_match($regex, $form_state['values']['mail'])) {
    form_set_error('mail', t('This email address still matches the invalid email template.'));
  }
}