class RangeConstraint

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

Range constraint.

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

@todo Move this below the TypedData core component.

Attributes

#[Constraint(id: 'Range', label: new TranslatableMarkup('Range', [], [ 'context' => 'Validation', ]), type: [ 'integer', 'float', ])]

Hierarchy

  • class \Drupal\Core\Validation\Plugin\Validation\Constraint\RangeConstraint extends \Symfony\Component\Validator\Constraints\Range

Expanded class hierarchy of RangeConstraint

1 file declares its use of RangeConstraint
MenuLinkDepthConstraint.php in core/lib/Drupal/Core/Menu/Plugin/Validation/Constraint/MenuLinkDepthConstraint.php

File

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

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class RangeConstraint extends Range {
  
  /**
   * {@inheritdoc}
   */
  public function __construct(?array $options = NULL, ?string $notInRangeMessage = NULL, ?string $minMessage = NULL, ?string $maxMessage = NULL, ?string $invalidMessage = NULL, ?string $invalidDateTimeMessage = NULL, mixed $min = NULL, ?string $minPropertyPath = NULL, mixed $max = NULL, ?string $maxPropertyPath = NULL, ?array $groups = NULL, mixed $payload = NULL) {
    $this->notInRangeMessage = 'This value should be between %min and %max.';
    $this->minMessage = 'This value should be %limit or more.';
    $this->maxMessage = 'This value should be %limit or less.';
    parent::__construct($options, $notInRangeMessage, $minMessage, $maxMessage, $invalidMessage, $invalidDateTimeMessage, $min, $minPropertyPath, $max, $maxPropertyPath, $groups, $payload);
  }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
RangeConstraint::__construct public function #[HasNamedArguments] 1

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