class LengthConstraint

Length constraint.

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

@todo: Move this below the TypedData core component.

Plugin annotation


@Plugin(
  id = "Length",
  label = @Translation("Length", context = "Validation"),
  type = { "string" }
)

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Length

Expanded class hierarchy of LengthConstraint

File

drupal/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php, line 27
Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint.

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class LengthConstraint extends Length {
  public $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.';
  public $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.';
  public $exactMessage = 'This value should have exactly %limit character.|This value should have exactly %limit characters.';

  /**
   * Overrides Range::validatedBy().
   */
  public function validatedBy() {
    return '\\Symfony\\Component\\Validator\\Constraints\\LengthValidator';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Constraint::$groups public property
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group
Constraint::CLASS_CONSTRAINT constant Marks a constraint that can be put onto classes
Constraint::DEFAULT_GROUP constant The name of the group given to all constraints with no explicit group
Constraint::getDefaultOption public function Returns the name of the default option 12
Constraint::getRequiredOptions public function Returns the name of the required options 10
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or both 7
Constraint::PROPERTY_CONSTRAINT constant Marks a constraint that can be put onto properties
Constraint::__set public function Unsupported operation.
Length::$charset public property
Length::$max public property
Length::$min public property
Length::__construct public function Initializes the constraint with options. Overrides Constraint::__construct
LengthConstraint::$exactMessage public property Overrides Length::$exactMessage
LengthConstraint::$maxMessage public property Overrides Length::$maxMessage
LengthConstraint::$minMessage public property Overrides Length::$minMessage
LengthConstraint::validatedBy public function Overrides Range::validatedBy(). Overrides Constraint::validatedBy