AuthRule.php 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\company\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|unique:PcAuthRule',
  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. }