Validate.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
// +---------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +---------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +---------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +---------------------------------------------------------------------
// | Author: catman <catman@thinkcmf.com>
// +---------------------------------------------------------------------
// ThinkPHP5.0兼容ThinkPHP5.1代码,用法请看ThinkPHP5.1文档
namespace think\facade;
use think\Validate as ThinValidate;
/**
* Class Validate
* @package think\facade
* @method bool is($value, $rule, $data = []) static 验证字段值是否为有效格式
* @method bool isDate($value) static 验证是否为有效的日期
* @method bool isEmail($value) static 验证是否为有效邮箱地址
*/
class Validate extends ThinValidate
{
public static function __callStatic($method, $params)
{
$class = self::make();
if (method_exists($class, $method)) {
return call_user_func_array([$class, $method], $params);
} else if ('is' == strtolower(substr($method, 0, 2))) {
$method = substr($method, 2);
array_push($params, lcfirst($method));
return call_user_func_array([$class, 'is'], $params);
} else {
throw new \BadMethodCallException('method not exists:' . __CLASS__ . '->' . $method);
}
}
}