You are here

public function RecursiveValidator::validate in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/validator/Validator/RecursiveValidator.php \Symfony\Component\Validator\Validator\RecursiveValidator::validate()
  2. 8 core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php \Drupal\Core\TypedData\Validation\RecursiveValidator::validate()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Validator/RecursiveValidator.php \Symfony\Component\Validator\Validator\RecursiveValidator::validate()

Validates a value against a constraint or a list of constraints.

If no constraint is passed, the constraint {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.

Parameters

mixed $value The value to validate:

Constraint|Constraint[] $constraints The constraint(s) to validate: against

array|null $groups The validation groups to: validate. If none is given, "Default" is assumed

Return value

ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded

Overrides ValidatorInterface::validate

1 call to RecursiveValidator::validate()
RecursiveValidator::validateValue in vendor/symfony/validator/Validator/RecursiveValidator.php
Validates a value against a constraint or a list of constraints.

File

vendor/symfony/validator/Validator/RecursiveValidator.php, line 118

Class

RecursiveValidator
Recursive implementation of {@link ValidatorInterface}.

Namespace

Symfony\Component\Validator\Validator

Code

public function validate($value, $groups = null, $traverse = false, $deep = false) {
  $numArgs = func_num_args();

  // Use new signature if constraints are given in the second argument
  if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) {

    // Rename to avoid total confusion ;)
    $constraints = $groups;
    $groups = $traverse;
  }
  else {
    @trigger_error('The Symfony\\Component\\Validator\\ValidatorInterface::validate method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\\Component\\Validator\\Validator\\ValidatorInterface::validate method instead.', E_USER_DEPRECATED);
    $constraints = new Valid(array(
      'traverse' => $traverse,
      'deep' => $deep,
    ));
  }
  return $this
    ->startContext($value)
    ->validate($value, $constraints, $groups)
    ->getViolations();
}