You are here

function user_validate_name in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/user/user.module \user_validate_name()
  2. 5 modules/user/user.module \user_validate_name()
  3. 6 modules/user/user.module \user_validate_name()
  4. 7 modules/user/user.module \user_validate_name()
  5. 9 core/modules/user/user.module \user_validate_name()

Verify the syntax of the given name.

1 call to user_validate_name()
_user_edit_validate in modules/user.module

File

modules/user.module, line 231
Enables the user registration and login system.

Code

function user_validate_name($name) {
  if (!strlen($name)) {
    return t('You must enter a username.');
  }
  if (substr($name, 0, 1) == ' ') {
    return t('The username cannot begin with a space.');
  }
  if (substr($name, -1) == ' ') {
    return t('The username cannot end with a space.');
  }
  if (ereg('  ', $name)) {
    return t('The username cannot contain multiple spaces in a row.');
  }
  if (ereg("", $name)) {
    return t('The username contains an illegal character.');
  }
  if (preg_match('/[\\x{80}-\\x{A0}' . '\\x{AD}' . '\\x{2000}-\\x{200F}' . '\\x{2028}-\\x{202F}' . '\\x{205F}-\\x{206F}' . '\\x{FEFF}' . '\\x{FF01}-\\x{FF60}' . '\\x{FFF9}-\\x{FFFD}' . '\\x{0}]/u', $name)) {
    return t('The username contains an illegal character.');
  }
  if (ereg('@', $name) && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) {
    return t('The username is not a valid authentication ID.');
  }
  if (strlen($name) > 56) {
    return t('The username %name is too long: it must be less than 56 characters.', array(
      '%name' => theme('placeholder', $name),
    ));
  }
}