diff --git a/library/think/Validate.php b/library/think/Validate.php index 864d88ec..64fb1be7 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -1118,7 +1118,6 @@ class Validate */ protected function after($value, $rule, $data) { - $rule = $this->getDataValue($data, $rule); return strtotime($value) >= strtotime($rule); } @@ -1132,10 +1131,37 @@ class Validate */ protected function before($value, $rule, $data) { - $rule = $this->getDataValue($data, $rule); return strtotime($value) <= strtotime($rule); } + /** + * 验证日期字段 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function afterWith($value, $rule, $data) + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) >= strtotime($rule); + } + + /** + * 验证日期字段 + * @access protected + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + protected function beforeWith($value, $rule, $data) + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) <= strtotime($rule); + } + /** * 验证有效期 * @access protected