Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 66dfe69

Browse files
committed
chore: changed default country error message
1 parent 9eb9f3f commit 66dfe69

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/Rule/Country.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Country extends AbstractRule implements RuleInterface
1717
self::ALPHA_3_CODE
1818
];
1919

20-
private string $message = 'The {{ name }} value is not a valid {{ code }} country code, {{ value }} given.';
20+
private string $message = 'The {{ name }} value is not a valid country, {{ value }} given.';
2121

2222
public function __construct(
2323
private readonly string $code = self::ALPHA_2_CODE,
@@ -37,8 +37,8 @@ public function assert(mixed $value, ?string $name = null): void
3737
throw new UnexpectedTypeException('string', get_debug_type($value));
3838
}
3939

40-
// Keep original value for parameters
41-
$input = strtoupper($value);
40+
// keep original value for parameters
41+
$input = \strtoupper($value);
4242

4343
if (
4444
($this->code === self::ALPHA_2_CODE && !Countries::exists($input))

tests/CountryTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ public static function provideRuleUnexpectedValueData(): \Generator
2121
$unexpectedCodeMessage = '/Invalid code "(.*)"\. Accepted values are\: "(.*)"\./';
2222
$unexpectedTypeMessage = '/Expected value of type "string", (.*) given\./';
2323

24-
yield 'invalid code' => [new Country('invalid'), 'PT', $unexpectedCodeMessage];
24+
yield 'invalid code' => [new Country('invalid'), 'pt', $unexpectedCodeMessage];
2525
yield 'invalid type' => [new Country(), 123, $unexpectedTypeMessage];
2626
}
2727

2828
public static function provideRuleFailureConditionData(): \Generator
2929
{
3030
$exception = CountryException::class;
31-
$message = '/The (.*) value is not a valid (.*) country code, (.*) given\./';
31+
$message = '/The (.*) value is not a valid country, (.*) given\./';
3232

3333
yield 'default' => [new Country(), 'PRT', $exception, $message];
34-
yield 'alpha2' => [new Country(code: 'alpha-2'), 'PRT', $exception, $message];
35-
yield 'alpha3' => [new Country(code: 'alpha-3'), 'PT', $exception, $message];
34+
yield 'alpha2' => [new Country(code: 'alpha-2'), 'prt', $exception, $message];
35+
yield 'alpha3' => [new Country(code: 'alpha-3'), 'pt', $exception, $message];
3636
}
3737

3838
public static function provideRuleSuccessConditionData(): \Generator
3939
{
40-
yield 'default' => [new Country(), 'PT'];
41-
yield 'alpha2' => [new Country(code: 'alpha-2'), 'PT'];
40+
yield 'default' => [new Country(), 'pt'];
41+
yield 'alpha2' => [new Country(code: 'alpha-2'), 'pt'];
4242
yield 'alpha2 lowercase' => [new Country(code: 'alpha-2'), 'pt'];
43-
yield 'alpha3' => [new Country(code: 'alpha-3'), 'PRT'];
43+
yield 'alpha3' => [new Country(code: 'alpha-3'), 'prt'];
4444
yield 'alpha3 lowercase' => [new Country(code: 'alpha-3'), 'prt'];
4545
}
4646

tests/TimezoneTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ class TimezoneTest extends AbstractTest
1919
public static function provideRuleUnexpectedValueData(): \Generator
2020
{
2121
$unexpectedMissingCountryCodeMessage = '/A country code is required when timezone group is "\\\DateTimeZone::PER_COUNTRY"\./';
22-
$unexpectedCountryCodeMessage = '/The (.*) value is not a valid (.*) country code, (.*) given\./';
22+
$unexpectedCountryCodeMessage = '/The (.*) value is not a valid country, (.*) given\./';
2323

2424
yield 'missing country code' => [
2525
new Timezone(\DateTimeZone::PER_COUNTRY),
2626
'Europe/Lisbon',
2727
$unexpectedMissingCountryCodeMessage
2828
];
2929
yield 'invalid country code' => [
30-
new Timezone(\DateTimeZone::PER_COUNTRY, 'PRT'),
30+
new Timezone(\DateTimeZone::PER_COUNTRY, 'prt'),
3131
'Europe/Lisbon',
3232
$unexpectedCountryCodeMessage
3333
];

0 commit comments

Comments
 (0)