本文整理汇总了PHP中Respect\Validation\Validator::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::validate方法的具体用法?PHP Validator::validate怎么用?PHP Validator::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Execute la suite de tests.
*
* @param mixed $void Ne sert à rien. Ne pas utiliser.
* @return null|boolean Si vaut null, cela signifie que la valeur à tester n'existe pas.<br/>
* Vaut TRUE ou FALSE selon la réussite de la suite des assertions.
*/
public function validate($void = '')
{
if ($this->_bReturnNull) {
return null;
}
return parent::validate($this->_mValueToTest);
}
示例2: validateField
/**
* Validate a field's value with a given $rule
*
* @param $value mixed Value to validate
* @param $rule mixed Rule(s) to use for validation
* @return bool
*/
public static function validateField($value, $rule)
{
// only validate non-empty fields
if ($value == "") {
return true;
}
// validate
$validator = new Validator();
// create rules
if (!is_array($rule)) {
$validator->addRule(Validator::buildRule($rule));
} else {
foreach ($rule as $rule_key => $params) {
$params = Helper::ensureArray($params);
$validator->addRule(Validator::buildRule($rule_key, $params));
}
}
return $validator->validate($value);
}
示例3: handleValidationRule
/**
* Smart method to process fields, regardless of data type
*
* @param string $field Field to validate
* @param mixed $rule Rule (or rules) to chain and validate with
* @return bool
*/
private function handleValidationRule($field, $rule)
{
if ($field == '') {
return true;
}
# only validate non-empty fields.
$spawn = new v();
if (!is_array($rule)) {
$spawn->addRule(v::buildRule($rule));
} else {
foreach ($rule as $rule_key => $params) {
$params = !is_array($params) ? (array) $params : $params;
# make sure params are an array
$spawn->addRule(v::buildRule($rule_key, $params));
}
}
return $spawn->validate($field);
}