From afa1376941d8692c8c0a0b191b4055392b353f47 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 17:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index ed12083c..d40a0f63 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -348,16 +348,21 @@ class Validate $result = call_user_func_array($rule, [$value, $data]); } else { // 判断验证类型 - if (is_numeric($key) && strpos($rule, ':')) { - list($type, $rule) = explode(':', $rule, 2); - if (isset($this->alias[$type])) { - // 判断别名 - $type = $this->alias[$type]; + if (is_numeric($key)) { + if (strpos($rule, ':')) { + list($type, $rule) = explode(':', $rule, 2); + if (isset($this->alias[$type])) { + // 判断别名 + $type = $this->alias[$type]; + } + $info = $type; + } elseif (method_exists($this, $rule)) { + $type = $rule; + $info = $rule; + } else { + $type = 'is'; + $info = $rule; } - $info = $type; - } elseif (is_numeric($key)) { - $type = 'is'; - $info = $rule; } else { $info = $type = $key; }