PremisesValidate.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\admin\validate\marketing;
  3. use support\Validate;
  4. class PremisesValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'premises_id' => 'require|integer',
  8. 'join_premises_category_id' => 'require|integer',
  9. 'premises_status' => 'require|in:ACTIVED,DISABLED',
  10. 'premises_category' => 'alphaDash|max:32',
  11. 'premises_code' => 'max:32',
  12. 'premises_name' => 'max:64',
  13. 'premises_city' => 'max:64',
  14. 'premises_contact_json' => 'isJson',
  15. 'premises_config_json' => 'isJson',
  16. 'premises_remark' => 'max:128',
  17. 'premises_extend_json' => 'isJson'
  18. ];
  19. protected $message = [];
  20. protected $scene = [
  21. 'add' => ['join_premises_category_id', 'premises_status', 'premises_category', 'premises_code', 'premises_name',
  22. 'premises_city', 'premises_contact_json', 'premises_config_json', 'premises_remark', 'premises_extend_json'],
  23. 'update' => ['premises_id', 'join_premises_category_id', 'premises_status', 'premises_category', 'premises_code', 'premises_name',
  24. 'premises_city', 'premises_contact_json', 'premises_config_json', 'premises_remark', 'premises_extend_json'],
  25. 'updateStatus' => ['premises_id', 'premises_status'],
  26. ];
  27. /**
  28. * @Desc 验证json
  29. * @Author Gorden
  30. * @Date 2024/3/6 15:23
  31. *
  32. * @param $value
  33. * @return string|true
  34. */
  35. public function isJson($value)
  36. {
  37. if (is_json($value)) {
  38. return true;
  39. }
  40. return "数据格式错误~";
  41. }
  42. }