function AllValidator::validate
Overrides ConstraintValidatorInterface::validate
File
-
vendor/
symfony/ validator/ Constraints/ AllValidator.php, line 24
Class
- AllValidator
- @author Bernhard Schussek <bschussek@gmail.com>
Namespace
Symfony\Component\Validator\ConstraintsCode
public function validate(mixed $value, Constraint $constraint) : void {
if (!$constraint instanceof All) {
throw new UnexpectedTypeException($constraint, All::class);
}
if (null === $value) {
return;
}
if (!\is_array($value) && !$value instanceof \Traversable) {
throw new UnexpectedValueException($value, 'iterable');
}
$context = $this->context;
$validator = $context->getValidator()
->inContext($context);
foreach ($value as $key => $element) {
$validator->atPath('[' . $key . ']')
->validate($element, $constraint->constraints);
}
}