From 53b455e11b70671e71d29ff5ec06557f960b6f10 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 19 Mar 2016 22:44:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bmodel=E7=B1=BB=E7=9A=84valida?= =?UTF-8?q?te=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index e48ab75d..23bfbc3b 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1893,14 +1893,14 @@ class Model /** * 设置字段验证 * @access public - * @param mixed $field 字段名或者验证规则 true表示自动读取 + * @param mixed $field 字段名或者验证规则 true表示自动读取验证器类 * @param array|null $rule 验证规则 * @return Model */ public function validate($field = true, $rule = null) { - if (is_array($field) || is_null($rule)) { - $this->options['validate'] = true === $field ? $this->name : $field; + if (is_null($rule)) { + $this->options['validate'] = $field; } else { $this->options['validate'][$field] = $rule; }