增加afterWith和beforeWith验证规则 用于比较日期字段

This commit is contained in:
thinkphp
2018-10-28 11:32:51 +08:00
parent 64ea8511cd
commit c670734e90

View File

@@ -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