public static function postal($check) { $pattern = '/^(lt)?[\\s-]?[\\d]{5}$/i'; return (bool) preg_match($pattern, $check); }
/** * test the postal method of LtValidation * * @return void */ public function testPostal() { $this->assertTrue(LtValidation::postal('89104')); $this->assertTrue(LtValidation::postal('LT-13089')); $this->assertTrue(LtValidation::postal('lt-13022')); $this->assertTrue(LtValidation::postal('Lt 13047')); $this->assertFalse(LtValidation::postal('111')); $this->assertFalse(LtValidation::postal('1111')); $this->assertFalse(LtValidation::postal('130896')); $this->assertFalse(LtValidation::postal('13089-333')); $this->assertFalse(LtValidation::postal('lu-55621')); $this->assertFalse(LtValidation::postal('LY-52147')); $this->assertFalse(LtValidation::postal('Nv 52125')); }