Agent.php 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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. ];
  13. protected $message = [
  14. 'page.integer' => '页码必须为整数',
  15. 'page.egt' => '页码必须大于等于1',
  16. 'page_size.integer' => '分页大小必须为整数',
  17. 'page_size.between' => '分页大小必须在1-100之间',
  18. 'time_filter.in' => '时间筛选参数无效,必须为:all、recent_7_days、recent_30_days、recent_90_days、current_year、custom中的一个',
  19. 'start_date.date' => '开始日期格式不正确',
  20. 'start_date.requireIf' => '选择自定义时间段时,开始日期不能为空',
  21. 'end_date.date' => '结束日期格式不正确',
  22. 'end_date.requireIf' => '选择自定义时间段时,结束日期不能为空',
  23. 'end_date.afterWith' => '结束日期必须大于等于开始日期',
  24. ];
  25. protected $scene = [
  26. 'team' => ['page', 'page_size', 'time_filter', 'start_date', 'end_date'],
  27. ];
  28. }