You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.6 KiB
68 lines
1.6 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\validate;
|
|
|
|
use think\facade\Db;
|
|
use think\Validate;
|
|
|
|
class AdData extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => 'number|length:1,10',
|
|
'ad_id' => "require|number|length:1,50",
|
|
'link' => 'url',
|
|
'sort' => 'number',
|
|
'start_time' => 'require',
|
|
'end_time' => 'require|gt:start_time',
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [
|
|
'ad_id.require' => '请输入广告位ID',
|
|
'ad_id.number' => '广告位ID必须是数字',
|
|
'ad_id.length' => '广告位ID需在1~50位之间',
|
|
// 'start_time.dateFormat' => '开始时间格式不正确',
|
|
// 'end_time.dateFormat' => '结束时间格式不正确',
|
|
// 'end_time.gt' => '结束时间必须大于开始时间',
|
|
'end_time.require' => '结束时间不能为空',
|
|
'start_time.require' => '结束时间不能为空',
|
|
];
|
|
|
|
/**
|
|
* 验证场景规则
|
|
* @var array
|
|
*/
|
|
protected $scene = [
|
|
'read' => ['id'],
|
|
];
|
|
|
|
/**
|
|
* 修改场景验证
|
|
* @return Manager
|
|
*/
|
|
public function sceneUpdate()
|
|
{
|
|
return $this->remove('name', 'require');
|
|
}
|
|
|
|
/**
|
|
* 自定义查询场景验证 可灵活设置验证字段
|
|
* @return Manager
|
|
*/
|
|
public function sceneLists()
|
|
{
|
|
|
|
}
|
|
}
|
|
|