|
@@ -2,7 +2,7 @@
|
|
|
// +----------------------------------------------------------------------
|
|
// +----------------------------------------------------------------------
|
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
|
// +----------------------------------------------------------------------
|
|
// +----------------------------------------------------------------------
|
|
|
-// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
|
|
|
|
|
|
|
+// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
|
|
|
// +----------------------------------------------------------------------
|
|
// +----------------------------------------------------------------------
|
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
|
// +----------------------------------------------------------------------
|
|
// +----------------------------------------------------------------------
|
|
@@ -126,10 +126,10 @@ class Validate
|
|
|
'alpha' => '/^[A-Za-z]+$/',
|
|
'alpha' => '/^[A-Za-z]+$/',
|
|
|
'alphaNum' => '/^[A-Za-z0-9]+$/',
|
|
'alphaNum' => '/^[A-Za-z0-9]+$/',
|
|
|
'alphaDash' => '/^[A-Za-z0-9\-\_]+$/',
|
|
'alphaDash' => '/^[A-Za-z0-9\-\_]+$/',
|
|
|
- 'chs' => '/^[\x{4e00}-\x{9fa5}]+$/u',
|
|
|
|
|
- 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u',
|
|
|
|
|
- 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9]+$/u',
|
|
|
|
|
- 'chsDash' => '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-]+$/u',
|
|
|
|
|
|
|
+ 'chs' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}]+$/u',
|
|
|
|
|
+ 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z]+$/u',
|
|
|
|
|
+ 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9]+$/u',
|
|
|
|
|
+ 'chsDash' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9\_\-]+$/u',
|
|
|
'mobile' => '/^1[3-9]\d{9}$/',
|
|
'mobile' => '/^1[3-9]\d{9}$/',
|
|
|
'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/',
|
|
'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/',
|
|
|
'zip' => '/\d{6}/',
|
|
'zip' => '/\d{6}/',
|
|
@@ -1180,10 +1180,10 @@ class Validate
|
|
|
if (is_string($rule) && strpos($rule, ',')) {
|
|
if (is_string($rule) && strpos($rule, ',')) {
|
|
|
[$rule, $param] = explode(',', $rule);
|
|
[$rule, $param] = explode(',', $rule);
|
|
|
} elseif (is_array($rule)) {
|
|
} elseif (is_array($rule)) {
|
|
|
- $param = $rule[1] ?? null;
|
|
|
|
|
|
|
+ $param = $rule[1] ?? 0;
|
|
|
$rule = $rule[0];
|
|
$rule = $rule[0];
|
|
|
} else {
|
|
} else {
|
|
|
- $param = null;
|
|
|
|
|
|
|
+ $param = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param);
|
|
return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param);
|
|
@@ -1605,6 +1605,11 @@ class Validate
|
|
|
return $this->errorMsgIsArray($msg, $rule, $title);
|
|
return $this->errorMsgIsArray($msg, $rule, $title);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // rule若是数组则转为字符串
|
|
|
|
|
+ if (is_array($rule)) {
|
|
|
|
|
+ $rule = implode(',', $rule);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (is_scalar($rule) && false !== strpos($msg, ':')) {
|
|
if (is_scalar($rule) && false !== strpos($msg, ':')) {
|
|
|
// 变量替换
|
|
// 变量替换
|
|
|
if (is_string($rule) && strpos($rule, ',')) {
|
|
if (is_string($rule) && strpos($rule, ',')) {
|