public function isValid($value) { // this line populates the "%value%" variables in the error messages $this->_setValue($value); // check format if (!Inspekt::isZip($value)) { // this line will insert the error message in the list of errors to // be returned to the caller $this->_error(self::NOT_ZIPCODE); return false; } return true; }
/** * Returns value if it is a valid US ZIP, FALSE otherwise. * * @param mixed $key * @return mixed * * @tag validator */ function testZip($key) { if (!$this->keyExists($key)) { return false; } if (Inspekt::isZip($this->_getValue($key))) { return $this->_getValue($key); } return FALSE; }
/** * */ public function testIsZip2() { $input = '46544-4142'; $this->assertTrue(Inspekt::isZip($input)); }
/** * Returns value if it is a valid US ZIP, FALSE otherwise. * * @param mixed $key * @return mixed * @throws Exception * @tag validator */ public function testZip($key) { $value = $this->getValueOrNull($key); if (!is_null($value) && Inspekt::isZip($value)) { return $value; } return false; }