示例#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()));
 }
 /**
  * @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());
 }