Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

UserNameConstraint.php

Namespace

Drupal\user\Plugin\Validation\Constraint

File

core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php

View source
<?php

namespace Drupal\user\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;

/**
 * Checks if a value is a valid user name.
 */
class UserNameConstraint extends SymfonyConstraint {
    public $emptyMessage = 'You must enter a username.';
    public $spaceBeginMessage = 'The username cannot begin with a space.';
    public $spaceEndMessage = 'The username cannot end with a space.';
    public $multipleSpacesMessage = 'The username cannot contain multiple spaces in a row.';
    public $illegalMessage = 'The username contains an illegal character.';
    public $tooLongMessage = 'The username %name is too long: it must be %max characters or less.';

}

Classes

Title Deprecated Summary
UserNameConstraint Checks if a value is a valid user name.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal