You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
988 B

  1. <?php
  2. namespace app\admin\validate;
  3. use think\Validate;
  4. class AuthRule extends Validate
  5. {
  6. /**
  7. * 正则
  8. */
  9. protected $regex = ['format' => '[a-z0-9_\/]+'];
  10. /**
  11. * 验证规则
  12. */
  13. protected $rule = [
  14. 'name' => 'require|format|unique:AuthRule',
  15. 'title' => 'require',
  16. ];
  17. /**
  18. * 提示消息
  19. */
  20. protected $message = [
  21. 'name.format' => 'URL规则只能是小写字母、数字、下划线和/组成'
  22. ];
  23. /**
  24. * 字段描述
  25. */
  26. protected $field = [
  27. ];
  28. /**
  29. * 验证场景
  30. */
  31. protected $scene = [
  32. ];
  33. public function __construct(array $rules = [], $message = [], $field = [])
  34. {
  35. $this->field = [
  36. 'name' => __('Name'),
  37. 'title' => __('Title'),
  38. ];
  39. $this->message['name.format'] = __('Name only supports letters, numbers, underscore and slash');
  40. parent::__construct($rules, $message, $field);
  41. }
  42. }