class RangeConstraint in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\RangeConstraint
- 9 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.
Plugin annotation
@Constraint(
id = "Range",
label = @Translation("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
File
- core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ RangeConstraint.php, line 20
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class RangeConstraint extends Range {
/**
* {@inheritdoc}
*/
public function __construct(array $options = NULL) {
if (isset($options['min']) && isset($options['max'])) {
$options['notInRangeMessage'] = $options['notInRangeMessage'] ?? 'This value should be between %min and %max.';
}
else {
$options['minMessage'] = $options['minMessage'] ?? 'This value should be %limit or more.';
$options['maxMessage'] = $options['maxMessage'] ?? 'This value should be %limit or less.';
}
parent::__construct($options);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RangeConstraint:: |
public | function |