Skip to content

Commit 6e8e175

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: fix tests using Twig 3.12 skip tests requiring the intl extension if it's not installed 🐛 throw ParseException on invalid date [ExpressionLanguage] Improve test coverage [HttpKernel] [WebProfileBundle] Fix Routing panel for URLs with a colon [Form] NumberType: Fix parsing of numbers in exponential notation with negative exponent [Security] consistent singular/plural translation in Dutch reset the validation context after validating nested constraints do not duplicate directory separators fix handling empty data in ValueToDuplicatesTransformer [Validator] review latvian translations [Validator] Add Dutch translation for `WordCount` constraint allow more unicode characters in URL paths [String][EnglishInflector] Fix words ending in 'le', e.g., articles do not duplicate directory separators [Uid] Ensure UuidV1 is created in lowercase
2 parents bcf939a + e6ef5f2 commit 6e8e175

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

Constraints/AtLeastOneOfValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ public function validate(mixed $value, Constraint $constraint)
4242
continue;
4343
}
4444

45+
$context = $this->context;
4546
$executionContext = clone $this->context;
4647
$executionContext->setNode($value, $this->context->getObject(), $this->context->getMetadata(), $this->context->getPropertyPath());
4748
$violations = $validator->inContext($executionContext)->validate($value, $item, $this->context->getGroup())->getViolations();
49+
$this->context = $context;
4850

4951
if (\count($this->context->getViolations()) === \count($violations)) {
5052
return;

Constraints/UrlValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class UrlValidator extends ConstraintValidator
4040
\] # an IPv6 address
4141
)
4242
(:[0-9]+)? # a port (optional)
43-
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
43+
(?:/ (?:[\pL\pN\pS\pM\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
4444
(?:\? (?:[\pL\pN\-._\~!$&\'\[\]()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
4545
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
4646
$~ixu';

Resources/translations/validators.lv.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</trans-unit>
4949
<trans-unit id="12">
5050
<source>This value is not a valid datetime.</source>
51-
<target>Šī vērtība ir nederīgs datums un laiks</target>
51+
<target>Šī vērtība ir nederīgs datums un laiks.</target>
5252
</trans-unit>
5353
<trans-unit id="13">
5454
<source>This value is not a valid email address.</source>
@@ -444,11 +444,11 @@
444444
</trans-unit>
445445
<trans-unit id="114">
446446
<source>This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</source>
447-
<target state="needs-translation">This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</target>
447+
<target>Šī vērtība ir pārāk īsa. Tai būtu jābūt vismaz vienu vārdu garai.|Šī vērtība ir pārāk īsa. Tai būtu jābūt ne mazāk kā {{ min }} vārdus garai.</target>
448448
</trans-unit>
449449
<trans-unit id="115">
450450
<source>This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</source>
451-
<target state="needs-translation">This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</target>
451+
<target>Šī vērtība ir pārāk gara. Tai būtu jābūt vienam vārdam.|Šī vērtība ir pārāk gara. Tai būtu jābūt ne vairāk kā {{ max }} vārdus garai.</target>
452452
</trans-unit>
453453
</body>
454454
</file>

Resources/translations/validators.nl.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@
444444
</trans-unit>
445445
<trans-unit id="114">
446446
<source>This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</source>
447-
<target state="needs-translation">This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</target>
447+
<target>Deze waarde is te kort. Het moet ten minste één woord bevatten.|Deze waarde is te kort. Het moet ten minste {{ min }} woorden bevatten.</target>
448448
</trans-unit>
449449
<trans-unit id="115">
450450
<source>This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</source>
451-
<target state="needs-translation">This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</target>
451+
<target>Deze waarde is te lang. Het moet één woord zijn.|Deze waarde is te lang. Het mag maximaal {{ max }} woorden bevatten.</target>
452452
</trans-unit>
453453
</body>
454454
</file>

Tests/Constraints/AtLeastOneOfValidatorTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraints\AtLeastOneOf;
1515
use Symfony\Component\Validator\Constraints\AtLeastOneOfValidator;
1616
use Symfony\Component\Validator\Constraints\Choice;
17+
use Symfony\Component\Validator\Constraints\Collection;
1718
use Symfony\Component\Validator\Constraints\Count;
1819
use Symfony\Component\Validator\Constraints\Country;
1920
use Symfony\Component\Validator\Constraints\DivisibleBy;
@@ -27,9 +28,11 @@
2728
use Symfony\Component\Validator\Constraints\Length;
2829
use Symfony\Component\Validator\Constraints\LessThan;
2930
use Symfony\Component\Validator\Constraints\Negative;
31+
use Symfony\Component\Validator\Constraints\NotBlank;
3032
use Symfony\Component\Validator\Constraints\NotNull;
3133
use Symfony\Component\Validator\Constraints\Range;
3234
use Symfony\Component\Validator\Constraints\Regex;
35+
use Symfony\Component\Validator\Constraints\Type;
3336
use Symfony\Component\Validator\Constraints\Unique;
3437
use Symfony\Component\Validator\Constraints\Valid;
3538
use Symfony\Component\Validator\ConstraintViolation;
@@ -296,6 +299,35 @@ public function trans(?string $id, array $parameters = [], ?string $domain = nul
296299
$this->assertCount(1, $violations);
297300
$this->assertSame('Dummy translation: [1] Dummy violation.', $violations->get(0)->getMessage());
298301
}
302+
303+
public function testValidateNestedAtLeaseOneOfConstraints()
304+
{
305+
$data = [
306+
'foo' => [
307+
'bar' => 'foo.bar',
308+
'baz' => 'foo.baz',
309+
],
310+
];
311+
312+
$constraints = new Collection([
313+
'foo' => new AtLeastOneOf([
314+
new Collection([
315+
'bar' => new AtLeastOneOf([
316+
new Type('int'),
317+
new Choice(['test1', 'test2'])
318+
]),
319+
]),
320+
new Collection([
321+
'baz' => new Type('int'),
322+
]),
323+
]),
324+
]);
325+
326+
$validator = Validation::createValidator();
327+
$violations = $validator->validate($data, $constraints);
328+
329+
self::assertCount(1, $violations);
330+
}
299331
}
300332

301333
class ExpressionConstraintNested

Tests/Constraints/UrlValidatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ public static function getValidUrls()
174174
['http://symfony.com/#one_more%20test'],
175175
['http://example.com/exploit.html?hello[0]=test'],
176176
['http://বিডিআইএ.বাংলা'],
177+
['http://www.example.com/คนแซ่ลี้/'],
178+
['http://www.example.com/か/'],
177179
];
178180
}
179181

0 commit comments

Comments
 (0)