Пример #1
0
 /**
  * @see       BasicValidator::isValid()
  *
  * @param     ValidatorMap  $map
  * @param     mixed         $value
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $value)
 {
     if (is_null($value) == false && is_numeric($value)) {
         return intval($value) >= intval($map->getValue());
     }
     return false;
 }
Пример #2
0
 /**
  * @see       BasicValidator::isValid()
  *
  * @param     ValidatorMap  $map
  * @param     string        $str
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $str)
 {
     $column = $map->getColumn();
     $c = new Criteria();
     $c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL);
     $table = $column->getTable()->getClassName();
     $clazz = $table . 'Peer';
     $count = call_user_func(array($clazz, 'doCount'), $c);
     $isValid = $count === 0;
     return $isValid;
 }
Пример #3
0
 /**
  * @see       BasicValidator::isValid()
  *
  * @param     ValidatorMap  $map
  * @param     mixed         $value
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $value)
 {
     switch ($map->getValue()) {
         case 'array':
             return is_array($value);
             break;
         case 'bool':
         case 'boolean':
             return is_bool($value);
             break;
         case 'float':
             return is_float($value);
             break;
         case 'int':
         case 'integer':
             return is_int($value);
             break;
         case 'numeric':
             return is_numeric($value);
             break;
         case 'object':
             return is_object($value);
             break;
         case 'resource':
             return is_resource($value);
             break;
         case 'scalar':
             return is_scalar($value);
             break;
         case 'string':
             return is_string($value);
             break;
         case 'function':
             return function_exists($value);
             break;
         default:
             throw new PropelException('Unkonwn type ' . $map->getValue());
             break;
     }
 }
Пример #4
0
 /**
  * Whether the passed string matches regular expression.
  *
  * @param     ValidatorMap  $map
  * @param     string        $str
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $str)
 {
     return preg_match($this->prepareRegexp($map->getValue()), $str) != 0;
 }
Пример #5
0
 /**
  * Add a validator to a table's column
  *
  * @param      string $columnName The name of the validator's column
  * @param      string $name The rule name of this validator
  * @param      string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
  * @param      string $value
  * @param      string $message The error message which is returned on invalid values
  * @return     void
  */
 public function addValidator($columnName, $name, $classname, $value, $message)
 {
     if (false !== ($pos = strpos($columnName, '.'))) {
         $columnName = substr($columnName, $pos + 1);
     }
     $col = $this->getColumn($columnName);
     if ($col !== null) {
         $validator = new ValidatorMap($col);
         $validator->setName($name);
         $validator->setClass($classname);
         $validator->setValue($value);
         $validator->setMessage($message);
         $col->addValidator($validator);
     }
 }
Пример #6
0
 /**
  * @see       BasicValidator::isValid()
  *
  * @param     ValidatorMap  $map
  * @param     string        $str
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $str)
 {
     return in_array($str, preg_split("/[|,]/", $map->getValue()));
 }
Пример #7
0
 /**
  * @see       BasicValidator::isValid()
  *
  * @param     ValidatorMap  $map
  * @param     string        $str
  *
  * @return    boolean
  */
 public function isValid(ValidatorMap $map, $str)
 {
     $len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str);
     return $len >= intval($map->getValue());
 }