ManageBlockResource.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\validate;
  3. use think\Validate;
  4. class ManageBlockResource extends Validate
  5. {
  6. /**
  7. * 验证规则
  8. */
  9. protected $rule = [
  10. // 'name' => 'require|format|unique:AuthRule',
  11. 'block_id' => 'require|number|gt:0',
  12. 'type' => 'require|in:1,2',
  13. 'book_id' => 'requireIf:type,1|number|gt:0',
  14. 'url' => 'requireIf:type,2|url',
  15. 'free_stime' => 'requireIf:block_id,3|requireIf:block_id,4|dateFormat:Y-m-d H:i:s|lt:free_etime',
  16. 'free_etime' => 'requireIf:block_id,3|requireIf:block_id,4|dateFormat:Y-m-d H:i:s|gt:free_stime',
  17. ];
  18. /**
  19. * 提示消息
  20. */
  21. protected $message = [
  22. // 'name.format' => 'URL规则只能是小写字母、数字、下划线和/组成'
  23. 'block_id.require' => '块ID不能为空',
  24. 'block.number' => '块ID必须为大于零数字',
  25. 'block.gt' => '块ID必须为大于零数字',
  26. 'type.require' => '类型不能为空',
  27. 'type.in' => '类型错误',
  28. 'book_id.requireIf' => '书籍ID不能为空',
  29. 'book_id.number' => '书籍ID必须为大于零数字',
  30. 'book_id.gt' => '书籍ID必须为大于零数字',
  31. 'url.requireIf' => '跳转URL不能为空',
  32. 'url.url' => '跳转URL不是有效的URL或IP地址',
  33. 'free_stime.requireIf' => '限免开始时间错误',
  34. 'free_stime.dateFormat' => '限免开始时间错误',
  35. 'free_stime.lt' => '限免开始时间必须小于结束时间',
  36. 'free_etime.requireIf' => '限免结束时间错误',
  37. 'free_etime.dateFormat' => '限免结束时间错误',
  38. 'free_etime.gt' => '限免结束时间必须大于开始时间',
  39. ];
  40. /**
  41. * 验证场景
  42. */
  43. protected $scene = [
  44. 'add' => ['block_id','book_id'],
  45. 'edit' => [],
  46. ];
  47. }