public static function postal($check) { $pattern = '/^[0-9]{3}-[0-9]{4}$/'; return (bool) preg_match($pattern, $check); }
/** * test the postal method of JpValidation * * @return void */ public function testPostal() { $this->assertTrue(JpValidation::postal('020-5045')); $this->assertFalse(JpValidation::postal('0205-504')); }