User.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\validate;
  4. use think\Validate;
  5. class User extends Validate
  6. {
  7. /**
  8. * 定义验证规则
  9. * 格式:'字段名' => ['规则1','规则2'...]
  10. *
  11. * @var array
  12. */
  13. protected $rule = [
  14. 'name' => 'require|max:25|chs',
  15. 'type' => 'require|max:25',
  16. 'contacts' => 'require|max:25|chs',
  17. 'post' => 'require|max:25',
  18. 'phone' => 'require|mobile',
  19. 'password' => 'require|alphaNum|min:6',
  20. ];
  21. /**
  22. * 定义错误信息
  23. * 格式:'字段名.规则名' => '错误信息'
  24. *
  25. * @var array
  26. */
  27. protected $message = [
  28. 'name.require' => '企业名称必填',
  29. 'type.require' => '企业类型必填',
  30. 'post.require' => '职务名称必填',
  31. 'password.require' => '密码必填',
  32. 'name.chs' => '姓名必须为汉字',
  33. 'contacts.chs' => '联系人姓名必须为汉字',
  34. 'contacts.max' => '联系人姓名不能超过25个字符',
  35. 'contacts.require' => '联系人姓名必填',
  36. 'name.max' => '姓名最多不能超过25个字符',
  37. 'phone.mobile' => '联系电话不合法',
  38. 'password.alphaNum'=> '密码必须数字和字母',
  39. 'password.min'=> '密码最低为6位',
  40. ];
  41. }