function AbstractComparison::__construct
Overrides Constraint::__construct
File
-
vendor/
symfony/ validator/ Constraints/ AbstractComparison.php, line 31
Class
- AbstractComparison
- Used for the comparison of values.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(mixed $value = null, ?string $propertyPath = null, ?string $message = null, ?array $groups = null, mixed $payload = null, array $options = []) {
if (\is_array($value)) {
$options = array_merge($value, $options);
}
elseif (null !== $value) {
$options['value'] = $value;
}
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
$this->propertyPath = $propertyPath ?? $this->propertyPath;
if (null === $this->value && null === $this->propertyPath) {
throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires either the "value" or "propertyPath" option to be set.', static::class));
}
if (null !== $this->value && null !== $this->propertyPath) {
throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires only one of the "value" or "propertyPath" options to be set, not both.', static::class));
}
if (null !== $this->propertyPath && !class_exists(PropertyAccess::class)) {
throw new LogicException(\sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option. Try running "composer require symfony/property-access".', static::class));
}
}