Fix Regex for Canadian postal code

Removes the errant space in the CA PostalCode regex.
This space was introduced by 5a067fa.

It also adds unit tests for the CA PostalCode to validate
the fix.

Reviewed-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
This commit is contained in:
Brian Johnson 2018-11-02 20:11:43 -06:00 committed by Emmerson Siqueira
parent 48b06254c4
commit f8c90fa368
No known key found for this signature in database
GPG key ID: C6404BA651DA5B69
2 changed files with 3 additions and 1 deletions

View file

@ -41,7 +41,7 @@ class PostalCode extends Regex
'BN' => '/^([A-Z]{2}\d{4})$/',
'BR' => '/^\d{5}-?\d{3}$/',
'BY' => '/^(\d{6})$/',
'CA' => '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$ /',
'CA' => '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/',
'CH' => '/^(\d{4})$/',
'CL' => '/^(\d{7})$/',
'CN' => '/^(\d{6})$/',

View file

@ -86,6 +86,7 @@ class PostalCodeTest extends \PHPUnit_Framework_TestCase
return [
['BR', '02179-000'],
['BR', '02179000'],
['CA', 'A1A 2B2'],
['GB', 'GIR 0AA'],
['GB', 'PR1 9LY'],
['US', '02179'],
@ -125,6 +126,7 @@ class PostalCodeTest extends \PHPUnit_Framework_TestCase
return [
['BR', '02179'],
['BR', '02179.000'],
['CA', '1A1B2B'],
['GB', 'GIR 00A'],
['GB', 'GIR0AA'],
['GB', 'PR19LY'],