From 7ce4d935f66592b87e6edc676b81617e29c9e089 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 6 Dec 2016 14:23:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bconfirm=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E8=A7=84=E5=88=99=20=E6=94=AF=E6=8C=81=20password=20=E5=8F=8A?= =?UTF-8?q?=20password=5Fconfirm=20=E8=87=AA=E5=8A=A8=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index e2b07875..101bb2ef 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -422,13 +422,21 @@ class Validate /** * 验证是否和某个字段的值一致 * @access protected - * @param mixed $value 字段值 + * @param mixed $value 字段值 * @param mixed $rule 验证规则 * @param array $data 数据 + * @param string $field 字段名 * @return bool */ - protected function confirm($value, $rule, $data) + protected function confirm($value, $rule, $data, $field) { + if ('' == $rule) { + if (strpos($field, '_confirm')) { + $rule = strstr($field, '_confirm', true); + } else { + $rule = $field . '_confirm'; + } + } return $this->getDataValue($data, $rule) == $value; }