Grant.php 835 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\sys\validate;
  3. use think\Validate;
  4. class Grant extends Validate
  5. {
  6. // 验证规则
  7. protected $rule = [
  8. 'id' => 'require|number',
  9. 'grant_id' => 'require|number',
  10. 'auth' => 'require|array',
  11. 'title' => 'require|max:10',
  12. ];
  13. // 验证消息
  14. protected $message = [
  15. 'title.require' => '请输入权限名',
  16. 'title.max' => '权限名最长10个字符',
  17. 'grant_id.require' => '缺少参数',
  18. 'grant_id.number' => '参数错误',
  19. 'auth.require' => '请选择权限',
  20. 'auth.array' => '参数错误',
  21. ];
  22. // 验证场景
  23. protected $scene = [
  24. 'add_grant' => ['title', 'auth'],
  25. 'edit_grant' => ['title', 'auth', 'grant_id'],
  26. 'edit' => ['grant_id'],
  27. 'del' => ['id']
  28. ];
  29. }