Checks if the passed value is valid.
@api
mixed $value The value that should be validated:
Constraint $constraint The constraint for the validation:
Overrides ConstraintValidatorInterface::validate
public function validate($value, Constraint $constraint) {
if (null === $value) {
return;
}
if (!is_array($value) && !$value instanceof \Traversable) {
throw new UnexpectedTypeException($value, 'array or Traversable');
}
$group = $this->context
->getGroup();
foreach ($value as $key => $element) {
foreach ($constraint->constraints as $constr) {
$this->context
->validateValue($element, $constr, '[' . $key . ']', $group);
}
}
}