public function AllValidator::validate

Checks if the passed value is valid.

@api

Parameters

mixed $value The value that should be validated:

Constraint $constraint The constraint for the validation:

Overrides ConstraintValidatorInterface::validate

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/AllValidator.php, line 28

Class

AllValidator
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Symfony\Component\Validator\Constraints

Code

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);
    }
  }
}