Skip to content

Commit 759ba00

Browse files
Merge branch '7.2' into 7.3
* 7.2: [Intl] Fix locale validator when canonicalize is true Update GitHub PR template [Notifier] Update fake SMS transports to use contracts event dispatcher.
2 parents a19337e + 06ad8f9 commit 759ba00

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Constraints/LocaleValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function validate(mixed $value, Constraint $constraint): void
4444
$value = \Locale::canonicalize($value);
4545
}
4646

47-
if (!Locales::exists($value)) {
47+
if (null === $value || !Locales::exists($value)) {
4848
$this->context->buildViolation($constraint->message)
4949
->setParameter('{{ value }}', $this->formatValue($inputValue))
5050
->setCode(Locale::NO_SUCH_LOCALE_ERROR)

Tests/Constraints/LocaleValidatorTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ public static function getInvalidLocales()
8989
];
9090
}
9191

92+
public function testTooLongLocale()
93+
{
94+
$constraint = new Locale([
95+
'message' => 'myMessage',
96+
]);
97+
98+
$locale = str_repeat('a', (\defined('INTL_MAX_LOCALE_LEN') ? \INTL_MAX_LOCALE_LEN : 85) + 1);
99+
$this->validator->validate($locale, $constraint);
100+
101+
$this->buildViolation('myMessage')
102+
->setParameter('{{ value }}', '"' . $locale . '"')
103+
->setCode(Locale::NO_SUCH_LOCALE_ERROR)
104+
->assertRaised();
105+
}
106+
92107
/**
93108
* @dataProvider getUncanonicalizedLocales
94109
*/

0 commit comments

Comments
 (0)