You are here

private function RecursiveContextualValidator::validateInGroup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Validator/RecursiveContextualValidator.php \Symfony\Component\Validator\Validator\RecursiveContextualValidator::validateInGroup()

Validates a node's value against all constraints in the given group.

Parameters

mixed $value The validated value:

string $cacheKey The key for caching the: validated value

MetadataInterface $metadata The metadata of the value:

string $group The group to validate:

ExecutionContextInterface $context The execution context:

2 calls to RecursiveContextualValidator::validateInGroup()
RecursiveContextualValidator::validateClassNode in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates a class node.
RecursiveContextualValidator::validateGenericNode in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates a node that is not a class node.

File

vendor/symfony/validator/Validator/RecursiveContextualValidator.php, line 851

Class

RecursiveContextualValidator
Recursive implementation of {@link ContextualValidatorInterface}.

Namespace

Symfony\Component\Validator\Validator

Code

private function validateInGroup($value, $cacheKey, MetadataInterface $metadata, $group, ExecutionContextInterface $context) {
  $context
    ->setGroup($group);
  foreach ($metadata
    ->findConstraints($group) as $constraint) {

    // Prevent duplicate validation of constraints, in the case
    // that constraints belong to multiple validated groups
    if (null !== $cacheKey) {
      $constraintHash = spl_object_hash($constraint);
      if ($context
        ->isConstraintValidated($cacheKey, $constraintHash)) {
        continue;
      }
      $context
        ->markConstraintAsValidated($cacheKey, $constraintHash);
    }
    $context
      ->setConstraint($constraint);
    $validator = $this->validatorFactory
      ->getInstance($constraint);
    $validator
      ->initialize($context);
    $validator
      ->validate($value, $constraint);
  }
}