class LengthConstraint

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
  3. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
  4. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint

Length constraint.

Overrides the symfony constraint to use Drupal-style replacement patterns.

@todo Move this below the TypedData core component.

Attributes

#[Constraint(id: 'Length', label: new TranslatableMarkup('Length', [], [ 'context' => 'Validation', ]), type: [ 'string', ])]

Hierarchy

  • class \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint extends \Symfony\Component\Validator\Constraints\Length

Expanded class hierarchy of LengthConstraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php, line 17

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class LengthConstraint extends Length {
  
  /**
   * {@inheritdoc}
   */
  public function __construct(int|array|null $exactly = NULL, ?int $min = NULL, ?int $max = NULL, ?string $charset = NULL, ?callable $normalizer = NULL, ?string $countUnit = NULL, ?string $exactMessage = 'This value should have exactly %limit character.|This value should have exactly %limit characters.', ?string $minMessage = 'This value is too short. It should have %limit character or more.|This value is too short. It should have %limit characters or more.', ?string $maxMessage = 'This value is too long. It should have %limit character or less.|This value is too long. It should have %limit characters or less.', ?string $charsetMessage = NULL, ?array $groups = NULL, mixed $payload = NULL, ?array $options = NULL) {
    parent::__construct($exactly, $min, $max, $charset, $normalizer, $countUnit, $exactMessage, $minMessage, $maxMessage, $charsetMessage, $groups, $payload, $options);
  }
  
  /**
   * {@inheritdoc}
   */
  public function validatedBy() : string {
    return '\\Symfony\\Component\\Validator\\Constraints\\LengthValidator';
  }

}

Members

Title Sort descending Modifiers Object type Summary
LengthConstraint::validatedBy public function
LengthConstraint::__construct public function #[HasNamedArguments]

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