class UserNameConstraint

Same name in other branches
  1. 9 core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php \Drupal\user\Plugin\Validation\Constraint\UserNameConstraint
  2. 8.9.x core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php \Drupal\user\Plugin\Validation\Constraint\UserNameConstraint
  3. 10 core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php \Drupal\user\Plugin\Validation\Constraint\UserNameConstraint

Checks if a value is a valid user name.

Hierarchy

  • class \Drupal\user\Plugin\Validation\Constraint\UserNameConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of UserNameConstraint

1 file declares its use of UserNameConstraint
MigrateEntityContentValidationTest.php in core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php

File

core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php, line 12

Namespace

Drupal\user\Plugin\Validation\Constraint
View source
class UserNameConstraint extends SymfonyConstraint {
    
    /**
     * The violation message when there is no username.
     *
     * @var string
     */
    public $emptyMessage = 'You must enter a username.';
    
    /**
     * The violation message when the username begins with whitespace.
     *
     * @var string
     */
    public $spaceBeginMessage = 'The username cannot begin with a space.';
    
    /**
     * The violation message when the username ends with whitespace.
     *
     * @var string
     */
    public $spaceEndMessage = 'The username cannot end with a space.';
    
    /**
     * The violation message when the username has consecutive whitespace.
     *
     * @var string
     */
    public $multipleSpacesMessage = 'The username cannot contain multiple spaces in a row.';
    
    /**
     * The violation message when the username uses an invalid character.
     *
     * @var string
     */
    public $illegalMessage = 'The username contains an illegal character.';
    
    /**
     * The violation message when the username length exceeds the maximum allowed.
     *
     * @var string
     */
    public $tooLongMessage = 'The username %name is too long: it must be %max characters or less.';

}

Members

Title Sort descending Modifiers Object type Summary
UserNameConstraint::$emptyMessage public property The violation message when there is no username.
UserNameConstraint::$illegalMessage public property The violation message when the username uses an invalid character.
UserNameConstraint::$multipleSpacesMessage public property The violation message when the username has consecutive whitespace.
UserNameConstraint::$spaceBeginMessage public property The violation message when the username begins with whitespace.
UserNameConstraint::$spaceEndMessage public property The violation message when the username ends with whitespace.
UserNameConstraint::$tooLongMessage public property The violation message when the username length exceeds the maximum allowed.

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