From 62a6a0270bd67619e4d2220a79d4fc9147759b6e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 9 Aug 2017 11:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BrequireIf=20requireWith=20req?= =?UTF-8?q?uireCallback=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=E5=8F=8A?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index e5efbd2b..72b9307b 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -900,7 +900,7 @@ class Validate { list($field, $val) = explode(',', $rule); if ($this->getDataValue($data, $field) == $val) { - return !empty($value); + return !empty($value) || '0' == $value; } else { return true; } @@ -918,7 +918,7 @@ class Validate { $result = call_user_func_array($rule, [$value, $data]); if ($result) { - return !empty($value); + return !empty($value) || '0' == $value; } else { return true; } @@ -936,7 +936,7 @@ class Validate { $val = $this->getDataValue($data, $rule); if (!empty($val)) { - return !empty($value); + return !empty($value) || '0' == $value; } else { return true; } @@ -1226,6 +1226,8 @@ class Validate $msg = $this->message[$attribute]; } elseif (isset(self::$typeMsg[$type])) { $msg = self::$typeMsg[$type]; + } elseif (0 === strpos($type, 'require')) { + $msg = self::$typeMsg['require']; } else { $msg = $title . '规则错误'; }