8000 [Validator] Fix the locale validator so it treats a locale alias as a… · symfony/symfony@649c17e · GitHub
[go: up one dir, main page]

Skip to content

Commit 649c17e

Browse files
committed
[Validator] Fix the locale validator so it treats a locale alias as a valid locale
1 parent 6d5dbf7 commit 649c17e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Component/Validator/Constraints/LocaleValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ public function validate($value, Constraint $constraint)
3838

3939
$value = (string) $value;
4040
$locales = Intl::getLocaleBundle()->getLocaleNames();
41+
$aliases = Intl::getLocaleBundle()->getAliases();
4142

42-
if (!isset($locales[$value])) {
43+
if (!isset($locales[$value]) && !array_search($value, $aliases)) {
4344
$this->context->addViolation($constraint->message, array(
4445
'{{ value }}' => $this->formatValue($value),
4546
));

src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function getValidLocales()
6161
array('pt'),
6262
array('pt_PT'),
6363
array('zh_Hans'),
64+
array('fil_PH'),
6465
);
6566
}
6667

0 commit comments

Comments
 (0)
0