You are here

function ldapauth_admin_form_validate_field in LDAP integration 6

Validation for machine name field.

1 string reference to 'ldapauth_admin_form_validate_field'
ldapauth_admin_form in ./ldapauth.admin.inc
Implements the LDAP server edit page.

File

./ldapauth.admin.inc, line 816
Module admin page callbacks.

Code

function ldapauth_admin_form_validate_field($element, &$form_state) {
  switch ($element['#name']) {
    case 'machine_name':
      if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
        form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
      }
      elseif (empty($element['#default_value']) && ldapauth_server_load($element['#value'])) {
        form_error($element, t('A server with the machine_name, @name, already exists on your site. Please choose a different name.', array(
          '@name' => $element['#value'],
        )));
      }
      break;
  }
}