mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加afterWith和beforeWith验证规则 用于比较日期字段
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user