Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3854889

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

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
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

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"doctrine/common": "~2.3",
2424
"symfony/http-foundation": "~2.1",
25-
"symfony/intl": "~2.3",
25+
"symfony/intl": "^2.3.21",
2626
"symfony/yaml": "~2.0,>=2.0.5",
2727
"symfony/config": "~2.2"
2828
},

0 commit comments

Comments
 (0)