Agent.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\api\validate;
  3. use think\Validate;
  4. class Agent extends Validate
  5. {
  6. protected $rule = [
  7. 'page' => 'integer|egt:1',
  8. 'page_size' => 'integer|between:1,100',
  9. 'time_filter' => 'in:all,recent_7_days,recent_30_days,recent_90_days,current_year,custom',
  10. 'start_date' => 'date|requireIf:time_filter,custom',
  11. 'end_date' => 'date|requireIf:time_filter,custom|afterWith:start_date',
  12. 'search_keyword' => 'max:50',
  13. ];
  14. protected $message = [
  15. 'page.integer' => '页码必须为整数',
  16. 'page.egt' => '页码必须大于等于1',
  17. 'page_size.integer' => '分页大小必须为整数',
  18. 'page_size.between' => '分页大小必须在1-100之间',
  19. 'time_filter.in' => '时间筛选参数无效,必须为:all、recent_7_days、recent_30_days、recent_90_days、current_year、custom中的一个',
  20. 'start_date.date' => '开始日期格式不正确',
  21. 'start_date.requireIf' => '选择自定义时间段时,开始日期不能为空',
  22. 'end_date.date' => '结束日期格式不正确',
  23. 'end_date.requireIf' => '选择自定义时间段时,结束日期不能为空',
  24. 'end_date.afterWith' => '结束日期必须大于等于开始日期',
  25. 'search_keyword.max' => '搜索关键词长度不能超过50个字符',
  26. ];
  27. protected $scene = [
  28. 'team' => ['page', 'page_size', 'time_filter', 'start_date', 'end_date', 'search_keyword'],
  29. ];
  30. }