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
This commit is contained in:
the_undefined 2008-05-19 05:38:22 +00:00
parent 065b8f4281
commit 0662d595cb
2 changed files with 7 additions and 0 deletions

View file

@ -680,6 +680,9 @@ class Validation extends Object {
default: default:
$_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i'; $_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
break; break;
case 'be':
$_this->regex = '/^[1-9]{1}[0-9]{3}$/i';
break;
} }
} }
return $_this->_check(); return $_this->_check();

View file

@ -1416,6 +1416,10 @@ class ValidationTestCase extends UnitTestCase {
$this->assertFalse(Validation::postal('1111', null, 'de')); $this->assertFalse(Validation::postal('1111', null, 'de'));
$this->assertTrue(Validation::postal('13089', 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('111', null, 'it'));
$this->assertFalse(Validation::postal('1111', null, 'it')); $this->assertFalse(Validation::postal('1111', null, 'it'));
$this->assertTrue(Validation::postal('13089', null, 'it')); $this->assertTrue(Validation::postal('13089', null, 'it'));