From 01e978dbbdcf6b4880733d702abf1de883c262a8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 22 Mar 2016 11:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 6 +++--- tests/thinkphp/library/think/modelTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index ebae5f63..c3264913 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -585,12 +585,12 @@ class Validate */ protected function filter($value, $rule) { - if (is_int($rule)) { - $param = null; - } elseif (is_string($rule) && strpos($rule, ',')) { + if (is_string($rule) && strpos($rule, ',')) { list($rule, $param) = explode(',', $rule); } elseif (is_array($rule)) { $param = isset($rule[1]) ? $rule[1] : null; + } else { + $param = null; } return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param); } diff --git a/tests/thinkphp/library/think/modelTest.php b/tests/thinkphp/library/think/modelTest.php index 22c3075a..74f3595b 100644 --- a/tests/thinkphp/library/think/modelTest.php +++ b/tests/thinkphp/library/think/modelTest.php @@ -49,7 +49,7 @@ class modelTest extends \PHPUnit_Framework_TestCase ]; $validate = [ - ['username', 'length:5,15|unique:user', '用户名长度为5到15个字符|用户名已经存在'], + ['username', 'length:5,15', '用户名长度为5到15个字符'], ['nickname', 'require', '请填昵称'], ['password', '[\w-]{6,15}', '密码长度为6到15个字符'], ['repassword', 'confirm:password', '两次密码不一到致'],