Skip to content

Commit

Permalink
never directly validate Existence (Required/Optional) constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed May 21, 2020
1 parent dd902d9 commit 530dfc8
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Composite;
use Symfony\Component\Validator\Constraints\Existence;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
Expand Down Expand Up @@ -790,6 +791,10 @@ private function validateInGroup($value, $cacheKey, MetadataInterface $metadata,
$context->setGroup($group);

foreach ($metadata->findConstraints($group) as $constraint) {
if ($constraint instanceof Existence) {
continue;
}

// Prevent duplicate validation of constraints, in the case
// that constraints belong to multiple validated groups
if (null !== $cacheKey) {
Expand Down

0 comments on commit 530dfc8

Please sign in to comment.