From c670734e900aef572a8c2a237c8f36c370fda5eb Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 28 Oct 2018 11:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0afterWith=E5=92=8CbeforeWith?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=20=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E6=97=A5=E6=9C=9F=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 | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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