function WhenValidator::validate
Overrides ConstraintValidatorInterface::validate
File
-
vendor/
symfony/ validator/ Constraints/ WhenValidator.php, line 26
Class
Namespace
Symfony\Component\Validator\ConstraintsCode
public function validate(mixed $value, Constraint $constraint) : void {
if (!$constraint instanceof When) {
throw new UnexpectedTypeException($constraint, When::class);
}
$context = $this->context;
$variables = $constraint->values;
$variables['value'] = $value;
$variables['this'] = $context->getObject();
$variables['context'] = $context;
if ($this->getExpressionLanguage()
->evaluate($constraint->expression, $variables)) {
$context->getValidator()
->inContext($context)
->validate($value, $constraint->constraints);
}
}