本文整理汇总了PHP中ValidatorMap类的典型用法代码示例。如果您正苦于以下问题:PHP ValidatorMap类的具体用法?PHP ValidatorMap怎么用?PHP ValidatorMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValidatorMap类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* @see BasicValidator::isValid()
*/
public function isValid(ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value)) {
return intval($value) >= intval($map->getValue());
}
return false;
}
示例2: isValid
public function isValid(ValidatorMap $map, $str)
{
$value = $map->getValue();
$con = Propel::getConnection(RecipePeer::DATABASE_NAME);
$sql = "SELECT id FROM " . $value . " WHERE id = :id";
$stmt = $con->prepare($sql);
$stmt->execute(array(':id' => $str));
$result = $stmt->fetchAll();
return count($result) > 0;
}
示例3: isValid
/**
* @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;
}
示例4: isValid
/**
* @see BasicValidator::isValid()
*/
public function isValid(ValidatorMap $map, $str)
{
$column = $map->getColumn();
$c = new Criteria();
$c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL);
$isValid = false;
try {
$table = $column->getTable()->getPhpName();
$cmd = sprintf('$isValid = %sPeer::doCount($c) == 0;', $table);
eval($cmd);
} catch (PropelException $e) {
/* what to do here ? */
}
return $isValid;
}
示例5: isValid
/**
* @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;
}
}
示例6: isValid
/**
* @see BasicValidator::isValid()
*/
public function isValid(ValidatorMap $map, $str)
{
return strlen($str) >= intval($map->getValue());
}
示例7: addValidator
/**
* 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);
}
}
示例8: isValid
public function isValid(ValidatorMap $map, $value)
{
return gettype($value) == $map->getValue();
}
示例9: isValid
public function isValid(ValidatorMap $map, $str)
{
return in_array($str, explode("|", $map->getValue()));
}
示例10: isValid
/**
* Whether the passed string matches regular expression.
*/
public function isValid(ValidatorMap $map, $str)
{
return preg_match($this->prepareRegexp($map->getValue()), $str) != 0;
}
示例11: isValid
/**
* @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());
}
示例12: isValid
/**
* @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()));
}