From 0662d595cb7c00bd181709b30d142ab29094fde7 Mon Sep 17 00:00:00 2001 From: the_undefined Date: Mon, 19 May 2008 05:38:22 +0000 Subject: [PATCH] Added postal code verification for belgium, fixes #4192 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6948 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/validation.php | 3 +++ cake/tests/cases/libs/validation.test.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index fa276304d..fcf5e62df 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -680,6 +680,9 @@ class Validation extends Object { default: $_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i'; break; + case 'be': + $_this->regex = '/^[1-9]{1}[0-9]{3}$/i'; + break; } } return $_this->_check(); diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 38970a9e9..3c5f57e15 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -1416,6 +1416,10 @@ class ValidationTestCase extends UnitTestCase { $this->assertFalse(Validation::postal('1111', null, 'de')); $this->assertTrue(Validation::postal('13089', null, 'de')); + $this->assertFalse(Validation::postal('111', null, 'be')); + $this->assertFalse(Validation::postal('0123', null, 'be')); + $this->assertTrue(Validation::postal('1204', null, 'be')); + $this->assertFalse(Validation::postal('111', null, 'it')); $this->assertFalse(Validation::postal('1111', null, 'it')); $this->assertTrue(Validation::postal('13089', null, 'it'));