Skip to content

Commit 2fae337

Browse files
Merge branch '3.4' into 4.4
* 3.4: Fixes sprintf(): Too few arguments in form transformer [Console] Fix QuestionHelper::disableStty() validate subforms in all validation groups Update Hungarian translations Add meaningful message when Process is not installed (ProcessHelper) [PropertyAccess] Fix TypeError parsing again. [Form] add missing Czech validators translation [Validator] add missing Czech translations never directly validate Existence (Required/Optional) constraints
2 parents ec017d5 + 5fb8812 commit 2fae337

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

Resources/translations/validators.cs.xlf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,54 @@
334334
<source>This value should be valid JSON.</source>
335335
<target>Tato hodnota musí být validní JSON.</target>
336336
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>Tato kolekce musí obsahovat pouze unikátní prvky.</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>Tato hodnota musí být kladná.</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>Tato hodnota musí být buď kladná nebo nula.</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>Tato hodnota musí být záporná.</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>Tato hodnota musí být buď záporná nebo nula.</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>Tato časová zóna neexistuje.</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>Zadané heslo bylo součástí úniku dat, takže ho není možné použít. Použijte prosím jiné heslo.</target>
364+
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>Hodnota musí být mezi {{ min }} a {{ max }}.</target>
368+
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>Tato hodnota není platný hostname.</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Počet prvků v této kolekci musí být násobek {{ compared_value }}.</target>
376+
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>Tato hodnota musí splňovat alespoň jedno z následujících omezení:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Každý prvek v této kolekci musí splňovat svá vlastní omezení.</target>
384+
</trans-unit>
337385
</body>
338386
</file>
339387
</xliff>

Tests/Validator/RecursiveValidatorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Component\Validator\Constraints\Length;
2020
use Symfony\Component\Validator\Constraints\NotBlank;
2121
use Symfony\Component\Validator\Constraints\NotNull;
22+
use Symfony\Component\Validator\Constraints\Optional;
23+
use Symfony\Component\Validator\Constraints\Required;
2224
use Symfony\Component\Validator\ConstraintValidatorFactory;
2325
use Symfony\Component\Validator\Context\ExecutionContextFactory;
2426
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -159,4 +161,18 @@ public function testAllConstraintValidateAllGroupsForNestedConstraints()
159161
$this->assertInstanceOf(Length::class, $violations->get(1)->getConstraint());
160162
$this->assertInstanceOf(Length::class, $violations->get(2)->getConstraint());
161163
}
164+
165+
public function testRequiredConstraintIsIgnored()
166+
{
167+
$violations = $this->validator->validate([], new Required());
168+
169+
$this->assertCount(0, $violations);
170+
}
171+
172+
public function testOptionalConstraintIsIgnored()
173+
{
174+
$violations = $this->validator->validate([], new Optional());
175+
176+
$this->assertCount(0, $violations);
177+
}
162178
}

Validator/RecursiveContextualValidator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\Composite;
16+
use Symfony\Component\Validator\Constraints\Existence;
1617
use Symfony\Component\Validator\Constraints\GroupSequence;
1718
use Symfony\Component\Validator\Constraints\Valid;
1819
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
@@ -728,6 +729,10 @@ private function validateInGroup($value, ?string $cacheKey, MetadataInterface $m
728729
$context->setGroup($group);
729730

730731
foreach ($metadata->findConstraints($group) as $constraint) {
732+
if ($constraint instanceof Existence) {
733+
continue;
734+
}
735+
731736
// Prevent duplicate validation of constraints, in the case
732737
// that constraints belong to multiple validated groups
733738
if (null !== $cacheKey) {

0 commit comments

Comments
 (0)