AdvValidate.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\admin\validate\sys_manage;
  3. use support\Validate;
  4. class AdvValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'adv_id' => 'require|integer',
  8. 'join_adv_category_id|所属分类' => 'integer',
  9. 'adv_status|状态' => 'in:PENDING,ACTIVED,DISABLED',
  10. 'adv_category|广告分类' => 'max:32',
  11. 'adv_name|名称' => 'require|max:64',
  12. 'adv_title|标题' => 'require|max:64',
  13. 'adv_carrier载体页面' => 'max:64',
  14. // 'adv_media|多媒体信息' => 'isJson',
  15. 'adv_href|跳转链接' => 'max:64',
  16. 'adv_config_json|配置信息' => 'isJson',
  17. 'content_sort|排序' => 'integer',
  18. 'content_groupby|分组' => 'max:32',
  19. 'content_remark|备注' => 'max:128',
  20. 'content_extend_json' => 'isJson'
  21. ];
  22. protected $message = [];
  23. protected $scene = [
  24. 'add' => ['join_adv_category_id', 'adv_status', 'adv_category', 'adv_name', 'adv_title', 'adv_carrier',
  25. 'adv_href', 'adv_config_json', 'content_sort', 'content_groupby', 'content_remark', 'content_extend_json'],
  26. 'update' => ['adv_id', 'join_adv_category_id', 'adv_status', 'adv_category', 'adv_name', 'adv_title', 'adv_carrier',
  27. 'adv_href', 'adv_config_json', 'content_sort', 'content_groupby', 'content_remark', 'content_extend_json'],
  28. ];
  29. /**
  30. * @Desc 验证json
  31. * @Author Gorden
  32. * @Date 2024/3/5 10:05
  33. *
  34. * @param $value
  35. * @return bool
  36. */
  37. protected function isJson($value)
  38. {
  39. if (is_json($value)) {
  40. return true;
  41. }
  42. return false;
  43. }
  44. }