8000 Update validation messages · symfony/symfony@45e7de2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45e7de2

Browse files
committed
Update validation messages
1 parent 8835af6 commit 45e7de2

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,16 @@ public function getDefaultOption()
6969
*/
7070
private function formatExtraInfo($zone, $countryCode = null)
7171
{
72-
if (!$zone) {
73-
return '';
74-
}
75-
$r = new \ReflectionClass('\DateTimeZone');
76-
$consts = $r->getConstants();
77-
78-
if (!$value = array_search($zone, $consts, true)) {
79-
$value = $zone;
80-
}
81-
82-
$value = ' for "'.$value.'" zone';
83-
8472
if ($countryCode) {
85-
$value = ' for ISO 3166-1 country code '.$countryCode;
73+
$value = ' for ISO 3166-1 country code "'.$countryCode.'"';
74+
} else {
75+
$r = new \ReflectionClass('\DateTimeZone');
76+
$consts = $r->getConstants();
77+
if ($value = array_search($zone, $consts, true)) {
78+
$value = ' for "'.$value.'" zone';
79+
} else {
80+
$value = ' for zone with identifier '.$zone;
81+
}
8682
}
8783

8884
return $this->formatValue($value);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function getInvalidGroupedTimezones()
154154
array('America/Barbados', \DateTimeZone::ANTARCTICA, ' for "ANTARCTICA" zone'),
155155
array('Europe/Kiev', \DateTimeZone::ARCTIC, ' for "ARCTIC" zone'),
156156
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN, ' for "INDIAN" zone'),
157-
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA, ' for "260" zone'),
157+
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA, ' for zone with identifier 260'),
158158
);
159159
}
160160

@@ -214,8 +214,8 @@ public function testInvalidGroupedTimezonesByCountry($timezone, $what, $country,
214214
public function getInvalidGroupedTimezonesByCountry()
215215
{
216216
return array(
217-
array('America/Argentina/Cordoba', \DateTimeZone::PER_COUNTRY, 'FR', ' for ISO 3166-1 country code FR'),
218-
array('America/Barbados', \DateTimeZone::PER_COUNTRY, 'PT', ' for ISO 3166-1 country code PT'),
217+
array('America/Argentina/Cordoba', \DateTimeZone::PER_COUNTRY, 'FR', ' for ISO 3166-1 country code "FR"'),
218+
array('America/Barbados', \DateTimeZone::PER_COUNTRY, 'PT', ' for ISO 3166-1 country code "PT"'),
219219
);
220220
}
221221
}

0 commit comments

Comments
 (0)
0