class LengthConstraint
Same name in other branches
- 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
- 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
- 11.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.
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 16
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class LengthConstraint extends Length {
/**
* {@inheritdoc}
*/
public function __construct(...$args) {
$this->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.';
$this->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.';
$this->exactMessage = 'This value should have exactly %limit character.|This value should have exactly %limit characters.';
parent::__construct(...$args);
}
/**
* {@inheritdoc}
*
* @return string
* The name of the class that validates this constraint.
*
* @todo Add method return type declaration.
* @see https://www.drupal.org/project/drupal/issues/3425150
*/
public function validatedBy() {
return '\\Symfony\\Component\\Validator\\Constraints\\LengthValidator';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
LengthConstraint::validatedBy | public | function | @todo Add method return type declaration. |
LengthConstraint::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.