public static function postal($check) { $pattern = '/^(0[1-9][0-9][0-9][0-9]|1[0-9][0-9][0-9][0-9]|2[0-9][0-9][0-9][0-9]|3[0-9][0-9][0-9][0-9]|4[0-9][0-9][0-9][0-9]|5[0-9][0-9][0-9][0-9]|6[0-9][0-9][0-9][0-9]|7[0-9][0-9][0-9][0-9]|8[0-9][0-9][0-9][0-9]|9[0-9][0-9][0-9][0-9]|)$/'; return (bool) preg_match($pattern, $check); }
/** * test the postal method of UaValidation * * @return void */ public function testPostal() { $this->assertTrue(UaValidation::postal('85111')); $this->assertTrue(UaValidation::postal('01996')); $this->assertTrue(UaValidation::postal('65000')); $this->assertFalse(UaValidation::postal('019962')); $this->assertFalse(UaValidation::postal('019961')); $this->assertFalse(UaValidation::postal('0199')); }