diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 647e46261..2af075603 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -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')); diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 91f828ab5..accd571df 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -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':