Beispiel #1
0
 /**
  * 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');
     }
 }
Beispiel #2
0
 /**
  * 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');
     }
 }
Beispiel #3
0
 /**
  * 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');
     }
 }
Beispiel #4
0
 /**
  * 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');
     }
 }
Beispiel #5
0
 /**
  * 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');
         }
     }
 }
Beispiel #6
0
 /**
  * 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');
             }
         }
     }
 }