function user_validate_name
Same name in other branches
- 7.x modules/user/user.module \user_validate_name()
- 9 core/modules/user/user.module \user_validate_name()
- 8.9.x core/modules/user/user.module \user_validate_name()
- 10 core/modules/user/user.module \user_validate_name()
Verify the syntax of the given name.
Parameters
string $name: The user name to validate.
Return value
string|null A translated violation message if the name is invalid or NULL if the name is valid.
Deprecated
in drupal:10.3.0 and is removed from drupal:12.0.0. Use \Drupal\user\UserNameValidator::validateName() instead.
See also
https://www.drupal.org/node/3431205
1 call to user_validate_name()
- UserValidationTest::testUsernames in core/
modules/ user/ tests/ src/ Kernel/ UserValidationTest.php - Tests user name validation.
File
-
core/
modules/ user/ user.module, line 214
Code
function user_validate_name($name) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. Use \\Drupal\\user\\UserNameValidator::validateName() instead. See https://www.drupal.org/node/3431205', E_USER_DEPRECATED);
$violations = \Drupal::service('user.name_validator')->validateName($name);
if (count($violations) > 0) {
return $violations[0]->getMessage();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.