Skip to content

Commit 35666f0

Browse files
committed
bug #18049 [Validator] Fix the locale validator so it treats a locale alias as a valid locale (jakzal)
This PR was merged into the 2.3 branch. Discussion ---------- [Validator] Fix the locale validator so it treats a locale alias as a valid locale | Q | A | ------------- | --- | Branch | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12583 | License | MIT | Doc PR | - Commits ------- fbb12d8 [Validator] Fix the locale validator so it treats a locale alias as a valid locale
2 parents 6d5dbf7 + fbb12d8 commit 35666f0

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]) && !in_array($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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy