public static function postal($check)
{
$pattern = '/^[1-9]{1}[0-9]{3}-[0-9]{3}$/';
return (bool) preg_match($pattern, $check);
}
/** * test the postal method of PtValidation * * @return void */ public function testPostal() { $this->assertFalse(PtValidation::postal('111')); $this->assertFalse(PtValidation::postal('1111')); $this->assertFalse(PtValidation::postal('130896')); $this->assertFalse(PtValidation::postal('13089-33333')); $this->assertFalse(PtValidation::postal('1000 333')); $this->assertFalse(PtValidation::postal('0000 333')); $this->assertFalse(PtValidation::postal('13A89-4333')); $this->assertTrue(PtValidation::postal('1389-333')); }