[Validator] Fix the locale validator so it treats a locale alias as a valid locale
This commit is contained in:
parent
6d5dbf7a75
commit
fbb12d89d1
@ -38,8 +38,9 @@ class LocaleValidator extends ConstraintValidator
|
|||||||
|
|
||||||
$value = (string) $value;
|
$value = (string) $value;
|
||||||
$locales = Intl::getLocaleBundle()->getLocaleNames();
|
$locales = Intl::getLocaleBundle()->getLocaleNames();
|
||||||
|
$aliases = Intl::getLocaleBundle()->getAliases();
|
||||||
|
|
||||||
if (!isset($locales[$value])) {
|
if (!isset($locales[$value]) && !in_array($value, $aliases)) {
|
||||||
$this->context->addViolation($constraint->message, array(
|
$this->context->addViolation($constraint->message, array(
|
||||||
'{{ value }}' => $this->formatValue($value),
|
'{{ value }}' => $this->formatValue($value),
|
||||||
));
|
));
|
||||||
|
@ -61,6 +61,7 @@ class LocaleValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('pt'),
|
array('pt'),
|
||||||
array('pt_PT'),
|
array('pt_PT'),
|
||||||
array('zh_Hans'),
|
array('zh_Hans'),
|
||||||
|
array('fil_PH'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/common": "~2.3",
|
"doctrine/common": "~2.3",
|
||||||
"symfony/http-foundation": "~2.1",
|
"symfony/http-foundation": "~2.1",
|
||||||
"symfony/intl": "~2.3",
|
"symfony/intl": "^2.3.21",
|
||||||
"symfony/yaml": "~2.0,>=2.0.5",
|
"symfony/yaml": "~2.0,>=2.0.5",
|
||||||
"symfony/config": "~2.2"
|
"symfony/config": "~2.2"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user