Пример #1
0
 /**
  * Checks given directory for existance.
  * @param unknown_type $directory
  * @throws \InvalidArgumentException
  */
 protected function validate($directory)
 {
     parent::validate($directory);
     if (!is_dir($directory)) {
         throw new ErrorException("'{$directory}' is not directory!");
     }
 }
Пример #2
0
 public function validate($value)
 {
     parent::validate();
     if (!preg_match("/\\d{1,3}(\\.\\d{1,3}){3}/is", $value)) {
         throw new ErrorException("Ip-address has to be like '123.45.67.189' (four numbers 0-255 seperated by dots)!");
     }
 }
Пример #3
0
 /**
  * Check for datatype string.
  * @param string $value
  * @throws  Exception\Error
  */
 protected function validate($value)
 {
     parent::validate($value);
     if (substr_count($value, "\n") > 0) {
         throw new Exception\InvalidValue("A one-liner text cannot contain a line-break!");
     }
 }
Пример #4
0
 public function validate($value)
 {
     parent::validate($value);
     $allowedChars = ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
     if (strlen($value) !== 32 || str_replace($allowedChars, '', $value) !== '') {
         throw new Exception\InvalidValue("Not a valid hash: '{$value}'!");
     }
 }
Пример #5
0
 /**
  * Validates the mail-address using Zend.
  * @param string $value
  * @throws InvalidArgumentException
  */
 protected function validate($value)
 {
     parent::validate($value);
     $validator = new EmailValidator();
     if (!$validator->isValid($value)) {
         throw new ErrorException("Email address '{$value}' is invalid!");
     }
 }
Пример #6
0
 protected static function filter($value)
 {
     return trim(parent::filter($value));
 }