本文整理匯總了PHP中lithium\util\Validator::reset方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::reset方法的具體用法?PHP Validator::reset怎麽用?PHP Validator::reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lithium\util\Validator
的用法示例。
在下文中一共展示了Validator::reset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testStateReset
/**
* Tests that the rules state is reset when calling `Validator::reset()`.
*/
public function testStateReset()
{
$this->assertNull(Validator::rules('foo'));
Validator::add('foo', '/foo/');
$this->assertEqual('/foo/', Validator::rules('foo'));
Validator::reset();
$this->assertNull(Validator::rules('foo'));
}
示例2: tearDown
public function tearDown()
{
Catalog::reset();
Validator::reset();
Catalog::config($this->_backup['catalogConfig']);
}
示例3: _checkFormats
* and an array specifying which formats within the rule to use.
*
* @param array $rules All available rules.
* @return \Closure Function returning boolean `true` if validation succeeded, `false` otherwise.
*/
protected static function _checkFormats($rules)
{
return function ($self, $params, $chain) use($rules) {
$value = $params['value'];
$format = $params['format'];
$options = $params['options'];
$defaults = array('all' => true);
$options += $defaults;
$formats = (array) $format;
$options['all'] = $format === 'any';
foreach ($rules as $index => $check) {
if (!$options['all'] && !(in_array($index, $formats) || isset($formats[$index]))) {
continue;
}
$regexPassed = is_string($check) && preg_match($check, $value);
$closurePassed = is_object($check) && $check($value, $format, $options);
if ($regexPassed || $closurePassed) {
return true;
}
}
return false;
};
}
}
Validator::reset();