Add support for Caymanian postal code validation

According to Wikipedia[1]:

> A postal code typically consists of an island code, a hyphen
> separator, and a section code.
>
> There are only three island codes: KY1 for Grand Cayman, KY2 for
> Cayman Brac, and KY3 for Little Cayman.

[1]: https://en.wikipedia.org/wiki/Postal_codes_in_the_Cayman_Islands

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Mateusz Burzyński 2019-09-29 19:29:30 +02:00 committed by Henrique Moody
parent b7b67da31e
commit a44f97f4b3
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 6 additions and 0 deletions

View file

@ -105,6 +105,7 @@ final class PostalCode extends AbstractEnvelope
'KP' => '/^(\d{6})$/',
'KR' => '/^(\d{5})$/',
'KW' => '/^(\d{5})$/',
'KY' => '/^KY[1-3]-\d{4}$/',
'KZ' => '/^(\d{6})$/',
'LA' => '/^(\d{5})$/',
'LB' => '/^(\d{4}(\d{4})?)$/',

View file

@ -83,6 +83,10 @@ final class PostalCodeTest extends RuleTestCase
[new PostalCode('EC'), '170515'],
[new PostalCode('IL'), '7019900'],
[new PostalCode('IL'), '94142'],
[new PostalCode('KY'), 'KY1-1102'],
[new PostalCode('KY'), 'KY2-2001'],
[new PostalCode('KY'), 'KY2-2001'],
[new PostalCode('KY'), 'KY3-2500'],
];
}
@ -104,6 +108,7 @@ final class PostalCodeTest extends RuleTestCase
[new PostalCode('KR'), '548940'],
[new PostalCode('KR'), '548-940'],
[new PostalCode('EC'), 'A1234B'],
[new PostalCode('KY'), 'KY4-2500'],
];
}
}