Skip to content

Commit 06ad8f9

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

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
@@ -91,6 +91,21 @@ public static function getInvalidLocales()
9191
];
9292
}
9393

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

0 commit comments

Comments
 (0)