SupplierValidate.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\admin\validate\sys_manage;
  3. use support\Validate;
  4. class SupplierValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'supplier_id' => 'require|integer',
  8. 'join_supplier_category_id' => 'integer',
  9. 'supplier_status|状态' => 'require|in:ACTIVED,DISABLED',
  10. 'supplier_category|分类' => 'max:32',
  11. 'supplier_name|名称' => 'require|max:64',
  12. 'supplier_contact_json' => 'isJson',
  13. 'supplier_config_json' => 'isJson',
  14. 'supplier_extend_json' => 'isJson'
  15. ];
  16. protected $message = [];
  17. protected $scene = [
  18. 'add' => ['join_supplier_category_id', 'supplier_status', 'supplier_category', 'supplier_name', 'supplier_contact_json', 'supplier_config_json', 'supplier_extend_json'],
  19. 'update' => ['supplier_id', 'join_supplier_category_id', 'supplier_status', 'supplier_category', 'supplier_name', 'supplier_contact_json', 'supplier_config_json', 'supplier_extend_json'],
  20. ];
  21. /**
  22. * @Desc 验证json数据
  23. * @Author Gorden
  24. * @Date 2024/3/27 13:18
  25. *
  26. * @param $value
  27. * @return string|true
  28. */
  29. public function isJson($value)
  30. {
  31. if (is_json($value)) {
  32. return true;
  33. }
  34. return "数据格式错误";
  35. }
  36. }