class Range
Same name in this branch
- 11.1.x core/lib/Drupal/Core/Render/Element/Range.php \Drupal\Core\Render\Element\Range
Validates that a given number or DateTime object is between some minimum and maximum.
@author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\Range extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of Range
2 files declare their use of Range
- RangeConstraint.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ RangeConstraint.php - RangeConstraintValidator.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ RangeConstraintValidator.php
5 string references to 'Range'
- BinaryFileResponse::prepare in vendor/
symfony/ http-foundation/ BinaryFileResponse.php - Prepares the Response before it is sent to the client.
- CallableArgumentsExtractor::extractArguments in vendor/
twig/ twig/ src/ Util/ CallableArgumentsExtractor.php - CallExpression::getArguments in vendor/
twig/ twig/ src/ Node/ Expression/ CallExpression.php - CoreExtension::getFunctions in vendor/
twig/ twig/ src/ Extension/ CoreExtension.php - Returns a list of functions to add to the existing list.
- Range::preRenderRange in core/
lib/ Drupal/ Core/ Render/ Element/ Range.php - Prepares a #type 'range' render element for input.html.twig.
File
-
vendor/
symfony/ validator/ Constraints/ Range.php, line 25
Namespace
Symfony\Component\Validator\ConstraintsView source
class Range extends Constraint {
public const INVALID_CHARACTERS_ERROR = 'ad9a9798-7a99-4df7-8ce9-46e416a1e60b';
public const NOT_IN_RANGE_ERROR = '04b91c99-a946-4221-afc5-e65ebac401eb';
public const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69';
public const TOO_LOW_ERROR = '76454e69-502c-46c5-9643-f447d837c4d5';
protected const ERROR_NAMES = [
self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR',
self::NOT_IN_RANGE_ERROR => 'NOT_IN_RANGE_ERROR',
self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR',
self::TOO_LOW_ERROR => 'TOO_LOW_ERROR',
];
public string $notInRangeMessage = 'This value should be between {{ min }} and {{ max }}.';
public string $minMessage = 'This value should be {{ limit }} or more.';
public string $maxMessage = 'This value should be {{ limit }} or less.';
public string $invalidMessage = 'This value should be a valid number.';
public string $invalidDateTimeMessage = 'This value should be a valid datetime.';
public mixed $min = null;
public ?string $minPropertyPath = null;
public mixed $max = null;
public ?string $maxPropertyPath = null;
/**
* @param array<string,mixed>|null $options
* @param string|null $invalidMessage The message if min and max values are numeric but the given value is not
* @param string|null $invalidDateTimeMessage The message if min and max values are PHP datetimes but the given value is not
* @param int|float|non-empty-string|null $min The minimum value, either numeric or a datetime string representation
* @param non-empty-string|null $minPropertyPath Property path to the min value
* @param int|float|non-empty-string|null $max The maximum value, either numeric or a datetime string representation
* @param non-empty-string|null $maxPropertyPath Property path to the max value
* @param string[]|null $groups
*/
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) {
parent::__construct($options, $groups, $payload);
$this->notInRangeMessage = $notInRangeMessage ?? $this->notInRangeMessage;
$this->minMessage = $minMessage ?? $this->minMessage;
$this->maxMessage = $maxMessage ?? $this->maxMessage;
$this->invalidMessage = $invalidMessage ?? $this->invalidMessage;
$this->invalidDateTimeMessage = $invalidDateTimeMessage ?? $this->invalidDateTimeMessage;
$this->min = $min ?? $this->min;
$this->minPropertyPath = $minPropertyPath ?? $this->minPropertyPath;
$this->max = $max ?? $this->max;
$this->maxPropertyPath = $maxPropertyPath ?? $this->maxPropertyPath;
if (null === $this->min && null === $this->minPropertyPath && null === $this->max && null === $this->maxPropertyPath) {
throw new MissingOptionsException(\sprintf('Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given for constraint "%s".', __CLASS__), [
'min',
'minPropertyPath',
'max',
'maxPropertyPath',
]);
}
if (null !== $this->min && null !== $this->minPropertyPath) {
throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires only one of the "min" or "minPropertyPath" options to be set, not both.', static::class));
}
if (null !== $this->max && null !== $this->maxPropertyPath) {
throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires only one of the "max" or "maxPropertyPath" options to be set, not both.', static::class));
}
if ((null !== $this->minPropertyPath || null !== $this->maxPropertyPath) && !class_exists(PropertyAccess::class)) {
throw new LogicException(\sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option. Try running "composer require symfony/property-access".', static::class));
}
if (null !== $this->min && null !== $this->max && ($minMessage || $maxMessage || isset($options['minMessage']) || isset($options['maxMessage']))) {
throw new ConstraintDefinitionException(\sprintf('The "%s" constraint can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead.', static::class));
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Constraint::$groups | public | property | The groups that the constraint belongs to. | ||
Constraint::$payload | public | property | Domain-specific data attached to a constraint. | ||
Constraint::addImplicitGroupName | public | function | Adds the given group if this constraint is in the Default group. | 2 | |
Constraint::CLASS_CONSTRAINT | public | constant | Marks a constraint that can be put onto classes. | ||
Constraint::DEFAULT_GROUP | public | 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. | 28 | |
Constraint::getErrorName | public static | function | Returns the name of the given error code. | ||
Constraint::getRequiredOptions | public | function | Returns the name of the required options. | 22 | |
Constraint::getTargets | public | function | Returns whether the constraint can be put onto classes, properties or both. |
8 | |
Constraint::normalizeOptions | protected | function | |||
Constraint::PROPERTY_CONSTRAINT | public | constant | Marks a constraint that can be put onto properties. | ||
Constraint::validatedBy | public | function | Returns the name of the class that validates this constraint. | 9 | |
Constraint::__get | public | function | Returns the value of a lazily initialized option. | 2 | |
Constraint::__isset | public | function | 1 | ||
Constraint::__set | public | function | Sets the value of a lazily initialized option. | 1 | |
Constraint::__sleep | public | function | Optimizes the serialized value to minimize storage space. | ||
Range::$invalidDateTimeMessage | public | property | |||
Range::$invalidMessage | public | property | |||
Range::$max | public | property | |||
Range::$maxMessage | public | property | |||
Range::$maxPropertyPath | public | property | |||
Range::$min | public | property | |||
Range::$minMessage | public | property | |||
Range::$minPropertyPath | public | property | |||
Range::$notInRangeMessage | public | property | |||
Range::ERROR_NAMES | protected | constant | Maps error codes to the names of their constants. | Overrides Constraint::ERROR_NAMES | |
Range::INVALID_CHARACTERS_ERROR | public | constant | |||
Range::NOT_IN_RANGE_ERROR | public | constant | |||
Range::TOO_HIGH_ERROR | public | constant | |||
Range::TOO_LOW_ERROR | public | constant | |||
Range::__construct | public | function | Overrides Constraint::__construct | 1 |