public static function postal($check) { $pattern = '/^(5[0-2]|[0-4][0-9])[0-9]{3}$/'; return (bool) preg_match($pattern, $check); }
/** * test the postal method of EsValidation * * @return void */ public function testPostal() { $this->assertTrue(EsValidation::postal('02300')); $this->assertFalse(EsValidation::postal('2300')); $this->assertFalse(EsValidation::postal('230000')); }