ConfigValidate.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\admin\validate\sys_manage;
  3. use support\Validate;
  4. class ConfigValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'config_status|状态' => 'require|in:ACTIVED,DISABLED',
  8. 'config_category|分类' => 'require|in:SYSTEM,APP',
  9. 'config_key|标识' => 'require|alphaDash',
  10. 'config_name|名称' => 'max:255',
  11. 'config_alias|别名' => 'max:255',
  12. 'config_value_json|配置内容' => 'isJson',
  13. 'config_sort|排序' => 'integer',
  14. 'config_groupby|分组' => 'max:255',
  15. 'config_extend_json' => 'isJson'
  16. ];
  17. protected $message = [];
  18. protected $scene = [
  19. 'add' => ['config_status', 'config_category', 'config_key', 'config_name', 'config_alias', 'config_value_json', 'config_sort', 'config_groupby', 'config_extend_json'],
  20. 'update' => ['config_category', 'config_key', 'config_name', 'config_alias', 'config_value_json', 'config_sort', 'config_groupby', 'config_extend_json'],
  21. 'update_status' => ['config_status']
  22. ];
  23. protected function isJson($value)
  24. {
  25. if (is_json($value)) {
  26. return true;
  27. }
  28. return '数据格式错误~';
  29. }
  30. }