mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Tighten Canadian postal code validation.
D, F, I, O, Q, U should not be valid anywhere in a canadian postal code. Fixes #3708
This commit is contained in:
parent
3f94d1d481
commit
83de70efcf
2 changed files with 7 additions and 1 deletions
|
@ -2126,6 +2126,10 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::postal('BAA 0ABC', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('B2A AABC', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('B2A 2AB', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('K1A 1D1', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('K1O 1Q1', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('A1A 1U1', null, 'ca'));
|
||||
$this->assertFalse(Validation::postal('A1F 1B1', null, 'ca'));
|
||||
$this->assertTrue(Validation::postal('X0A 0A2', null, 'ca'));
|
||||
$this->assertTrue(Validation::postal('G4V 4C3', null, 'ca'));
|
||||
|
||||
|
|
|
@ -646,7 +646,9 @@ class Validation {
|
|||
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
||||
break;
|
||||
case 'ca':
|
||||
$regex = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]\\b\\z/i';
|
||||
$district = '[ABCEGHJKLMNPRSTVYX]';
|
||||
$letters = '[ABCEGHJKLMNPRSTVWXYZ]';
|
||||
$regex = "/\\A\\b{$district}[0-9]{$letters} [0-9]{$letters}[0-9]\\b\\z/i";
|
||||
break;
|
||||
case 'it':
|
||||
case 'de':
|
||||
|
|
Loading…
Add table
Reference in a new issue