diff --git a/Resources/translations/validators.ar.xlf b/Resources/translations/validators.ar.xlf index 7c509b482..46a649848 100644 --- a/Resources/translations/validators.ar.xlf +++ b/Resources/translations/validators.ar.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. يجب أن يكون عدد العناصر في هذه المجموعة مضاعف {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + يجب أن تستوفي هذه القيمة واحدة من القيود التالية: + + + Each element of this collection should satisfy its own set of constraints. + يجب أن يفي كل عنصر من عناصر هذه المجموعة بمجموعة القيود الخاصة به. + diff --git a/Resources/translations/validators.de.xlf b/Resources/translations/validators.de.xlf index a546b86c7..c5d1fe0cf 100644 --- a/Resources/translations/validators.de.xlf +++ b/Resources/translations/validators.de.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Die Anzahl an Elementen in dieser Sammlung sollte ein Vielfaches von {{ compared_value }} sein. + + This value should satisfy at least one of the following constraints: + Dieser Wert sollte eine der folgenden Bedingungen erfüllen: + + + Each element of this collection should satisfy its own set of constraints. + Jedes Element dieser Sammlung sollte seine eigene Menge an Bedingungen erfüllen. + diff --git a/Resources/translations/validators.fr.xlf b/Resources/translations/validators.fr.xlf index e54be35c1..c44ade69e 100644 --- a/Resources/translations/validators.fr.xlf +++ b/Resources/translations/validators.fr.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Le nombre d'éléments de cette collection doit être un multiple de {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + Cette valeur doit satisfaire à au moins une des contraintes suivantes : + + + Each element of this collection should satisfy its own set of constraints. + Chaque élément de cette collection doit satisfaire à son propre jeu de contraintes. + diff --git a/Resources/translations/validators.hu.xlf b/Resources/translations/validators.hu.xlf index 96ae6fe54..23ca56180 100644 --- a/Resources/translations/validators.hu.xlf +++ b/Resources/translations/validators.hu.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Ennek az értéknek {{ min }} és {{ max }} között kell lennie. + + This value is not a valid hostname. + Ez az érték nem egy érvényes állomásnév (hosztnév). + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + A gyűjteményben lévő elemek számának oszthatónak kell lennie a következővel: {{ compared_value }}. + + + This value should satisfy at least one of the following constraints: + Ennek az értéknek meg kell felelni legalább egynek a következő feltételek közül: + + + Each element of this collection should satisfy its own set of constraints. + A gyűjtemény minden elemének meg kell felelni a saját feltételeinek. + diff --git a/Resources/translations/validators.it.xlf b/Resources/translations/validators.it.xlf index 3ec620ad6..9a5768c30 100644 --- a/Resources/translations/validators.it.xlf +++ b/Resources/translations/validators.it.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Questo valore dovrebbe essere compreso tra {{ min }} e {{ max }}. + + This value is not a valid hostname. + Questo valore non è un nome di host valido. + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + Il numero di elementi in questa collezione dovrebbe essere un multiplo di {{ compared_value }}. + + + This value should satisfy at least one of the following constraints: + Questo valore dovrebbe soddisfare almeno uno dei vincoli seguenti: + + + Each element of this collection should satisfy its own set of constraints. + Ciascun elemento di questa collezione dovrebbe soddisfare il suo insieme di vincoli. + diff --git a/Resources/translations/validators.lt.xlf b/Resources/translations/validators.lt.xlf index 2a079aacb..ccb58818c 100644 --- a/Resources/translations/validators.lt.xlf +++ b/Resources/translations/validators.lt.xlf @@ -366,6 +366,22 @@ This value should be between {{ min }} and {{ max }}. Ši reikšmė turi būti tarp {{ min }} ir {{ max }}. + + This value is not a valid hostname. + Ši reikšmė nėra tinkamas svetainės adresas. + + + The number of elements in this collection should be a multiple of {{ compared_value }}. + Šio sąrašo elementų skaičius turėtų būti skaičiaus {{ compared_value }} kartotinis. + + + This value should satisfy at least one of the following constraints: + Ši reikšmė turėtų atitikti bent vieną iš šių nurodymų: + + + Each element of this collection should satisfy its own set of constraints. + Kiekvienas šio sąrašo elementas turi atitikti savo nurodymų rinkinį. + diff --git a/Resources/translations/validators.vi.xlf b/Resources/translations/validators.vi.xlf index 301d42f02..f4286d25e 100644 --- a/Resources/translations/validators.vi.xlf +++ b/Resources/translations/validators.vi.xlf @@ -374,6 +374,14 @@ The number of elements in this collection should be a multiple of {{ compared_value }}. Số lượng các phần tử trong bộ sưu tập này nên là bội số của {{ compared_value }}. + + This value should satisfy at least one of the following constraints: + Giá trị này nên thỏa mãn ít nhất một trong những ràng buộc sau: + + + Each element of this collection should satisfy its own set of constraints. + Mỗi phần tử trong bộ sưu tập này nên thỏa mãn những ràng buộc của nó. + diff --git a/Tests/Validator/AbstractTest.php b/Tests/Validator/AbstractTest.php index 4cb354ec4..06f7e8577 100644 --- a/Tests/Validator/AbstractTest.php +++ b/Tests/Validator/AbstractTest.php @@ -698,4 +698,25 @@ public function testNestedObjectIsValidatedIfGroupInValidConstraintIsValidated() $this->assertCount(2, $violations); } + + public function testNestedObjectIsValidatedInMultipleGroupsIfGroupInValidConstraintIsValidated() + { + $entity = new Entity(); + $entity->firstName = null; + + $reference = new Reference(); + $reference->value = null; + + $entity->childA = $reference; + + $this->metadata->addPropertyConstraint('firstName', new NotBlank()); + $this->metadata->addPropertyConstraint('childA', new Valid(['groups' => ['group1', 'group2']])); + + $this->referenceMetadata->addPropertyConstraint('value', new NotBlank(['groups' => 'group1'])); + $this->referenceMetadata->addPropertyConstraint('value', new NotNull(['groups' => 'group2'])); + + $violations = $this->validator->validate($entity, null, ['Default', 'group1', 'group2']); + + $this->assertCount(3, $violations); + } } diff --git a/Validator/RecursiveContextualValidator.php b/Validator/RecursiveContextualValidator.php index dc06899ae..121ecf236 100644 --- a/Validator/RecursiveContextualValidator.php +++ b/Validator/RecursiveContextualValidator.php @@ -14,6 +14,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Composite; use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContext; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -720,8 +721,9 @@ private function validateInGroup($value, ?string $cacheKey, MetadataInterface $m // that constraints belong to multiple validated groups if (null !== $cacheKey) { $constraintHash = spl_object_hash($constraint); - - if ($constraint instanceof Composite) { + // instanceof Valid: In case of using a Valid constraint with many groups + // it makes a reference object get validated by each group + if ($constraint instanceof Composite || $constraint instanceof Valid) { $constraintHash .= $group; }