改进confirm验证规则 支持 password 及 password_confirm 自动规则识别

This commit is contained in:
thinkphp
2016-12-06 14:23:08 +08:00
parent 1cff11b9cc
commit 7ce4d935f6

View File

@@ -425,10 +425,18 @@ class Validate
* @param mixed $value 字段值 * @param mixed $value 字段值
* @param mixed $rule 验证规则 * @param mixed $rule 验证规则
* @param array $data 数据 * @param array $data 数据
* @param string $field 字段名
* @return bool * @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; return $this->getDataValue($data, $rule) == $value;
} }