function UserNameValidator::validateName

Same name and namespace in other branches
  1. 10 core/modules/user/src/UserNameValidator.php \Drupal\user\UserNameValidator::validateName()

Validates a user name.

Return value

\Symfony\Component\Validator\ConstraintViolationListInterface The list of constraint violations.

File

core/modules/user/src/UserNameValidator.php, line 30

Class

UserNameValidator
Provides a username validator.

Namespace

Drupal\user

Code

public function validateName(string $name) : ConstraintViolationListInterface {
    $validator = $this->validatorFactory
        ->createValidator();
    $constraint = $this->constraintManager
        ->create('UserName', []);
    return $validator->validate($name, $constraint);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.