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

Skip to content

Commit 209a9cb

Browse files
committed
[Validator] Adapted to latest Intl changes
1 parent f2a0aec commit 209a9cb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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

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

4141
$value = (string) $value;
42+
$countries = Intl::getRegionBundle()->getCountryNames();
4243

43-
if (!in_array($value, array_keys(Intl::getRegionBundle()->getCountryNames(\Locale::getDefault())))) {
44+
if (!isset($countries[$value])) {
4445
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
4546
}
4647
}

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

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

4141
$value = (string) $value;
42+
$languages = Intl::getLanguageBundle()->getLanguageNames();
4243

43-
if (!in_array($value, array_keys(Intl::getLanguageBundle()->getLanguageNames(\Locale::getDefault())))) {
44+
if (!isset($languages[$value])) {
4445
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
4546
}
4647
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function validate($value, Constraint $constraint)
3939
}
4040

4141
$value = (string) $value;
42-
$locales = Intl::getLocaleBundle()->getLocaleNames(\Locale::getDefault());
42+
$locales = Intl::getLocaleBundle()->getLocaleNames();
4343

4444
if (!isset($locales[$value])) {
4545
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));

0 commit comments

Comments
 (0)