lithium\util\Validator::__callStatic()
Maps method calls to validation rule names. For example, a validation rule that would
normally be called as Validator::rule('email', 'foo@bar.com')
can also be called as
Validator::isEmail('foo@bar.com')
.
Parameters
-
string
$method
The name of the method called, i.e.
'isEmail'
or'isCreditCard'
. -
array
$args
Returns
booleanSource
public static function __callStatic($method, $args = []) {
if (!isset($args[0])) {
return false;
}
$args = array_filter($args) + [0 => $args[0], 1 => 'any', 2 => []];
$rule = preg_replace("/^is([A-Z][A-Za-z0-9]+)$/", '$1', $method);
$rule[0] = strtolower($rule[0]);
return static::rule($rule, $args[0], $args[1], $args[2]);
}