From f6a8a2804fb08d1ab2fc3952617fd461220e7cd7 Mon Sep 17 00:00:00 2001 From: lilwil Date: Mon, 20 Mar 2017 13:13:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=AD=97=E6=AE=B5=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E6=94=AF=E6=8C=81=E5=AF=B9=E6=AF=94=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index 718ed7a1..89b2f11a 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -456,11 +456,12 @@ class Validate * @access protected * @param mixed $value 字段值 * @param mixed $rule 验证规则 + * @param array $data 数据 * @return bool */ protected function egt($value, $rule) { - return $value >= $rule; + return !is_null($this->getDataValue($data, $rule)) && $value >= $this->getDataValue($data, $rule); } /** @@ -468,11 +469,12 @@ class Validate * @access protected * @param mixed $value 字段值 * @param mixed $rule 验证规则 + * @param array $data 数据 * @return bool */ protected function gt($value, $rule) { - return $value > $rule; + return !is_null($this->getDataValue($data, $rule)) && $value > $this->getDataValue($data, $rule); } /** @@ -480,11 +482,12 @@ class Validate * @access protected * @param mixed $value 字段值 * @param mixed $rule 验证规则 + * @param array $data 数据 * @return bool */ protected function elt($value, $rule) { - return $value <= $rule; + return !is_null($this->getDataValue($data, $rule)) && $value <= $this->getDataValue($data, $rule); } /** @@ -492,11 +495,12 @@ class Validate * @access protected * @param mixed $value 字段值 * @param mixed $rule 验证规则 + * @param array $data 数据 * @return bool */ - protected function lt($value, $rule) + protected function lt($value, $rule, $data) { - return $value < $rule; + return !is_null($this->getDataValue($data, $rule)) && $value < $this->getDataValue($data, $rule); } /** @@ -504,11 +508,12 @@ class Validate * @access protected * @param mixed $value 字段值 * @param mixed $rule 验证规则 + * @param array $data 数据 * @return bool */ - protected function eq($value, $rule) + protected function eq($value, $rule, $data) { - return $value == $rule; + return !is_null($this->getDataValue($data, $rule)) && $value == $this->getDataValue($data, $rule); } /** @@ -1190,8 +1195,8 @@ class Validate // 支持二维数组验证 list($name1, $name2) = explode('.', $key); $value = isset($data[$name1][$name2]) ? $data[$name1][$name2] : null; - } else { - $value = isset($data[$key]) ? $data[$key] : null; + } else { + $value = is_numeric($key) ? $key : (isset($data[$key]) ? $data[$key] : null); } return $value; }