diff --git a/library/think/Validate.php b/library/think/Validate.php index 1c43f80c..a88043a2 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -68,6 +68,7 @@ class Validate 'allowIp' => '不允许的IP访问', 'denyIp' => '禁止的IP访问', 'confirm' => ':attribute和字段 :rule 不一致', + 'different' => ':attribute和字段 :rule 不能相同', 'egt' => ':attribute必须大于等于 :rule', 'gt' => ':attribute必须大于 :rule', 'elt' => ':attribute必须小于等于 :rule', @@ -400,6 +401,19 @@ class Validate return $this->getDataValue($data, $rule) == $value; } + /** + * 验证是否和某个字段的值是否不同 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function different($value, $rule, $data) + { + return $this->getDataValue($data, $rule) != $value; + } + /** * 验证是否大于等于某个值 * @access protected