/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if (0 < strlen($data) && false === filter_var($data, FILTER_VALIDATE_EMAIL)) { throw $this->throwError('Not an email address'); } }
/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if (false === filter_var($data, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))) { throw $this->throwError('Not an IPv4 address'); } }
/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if ('0' !== $data && '1' !== $data && '' !== $data) { throw $this->throwError('Not a switcher'); } }
/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if (!$this->regExp) { throw $this->throwInternalError('Regular expression is empty'); } if (0 < strlen($data) && !preg_match($this->regExp, $data)) { throw $this->throwError('Regular expression does not match'); } }
/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if (0 < strlen($data)) { $state = $this->sanitize($data); if (!$state) { throw $this->throwError('Not a state id'); } } }
/** * Validate * * @param mixed $data Data * * @return void * @throws \XLite\Core\Validator\Exception */ public function validate($data) { parent::validate($data); if (0 < strlen($data)) { $country = $this->sanitize($data); if (!$country) { throw $this->throwError('Not a country code'); } else { if ($this->onlyEnabled && !$country->getEnabled()) { throw $this->throwError('Country is not enabled'); } } } }