Register.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Module\User\Validation;
  3. use App\Module\Common\Validator\Phone;
  4. use App\Module\Ulogic\Validator\Model2Unit;
  5. use App\Module\User\Validator\UsernameNt;
  6. use UCore\ValidationCore;
  7. use App\Module\User\Validator\CanLogin;
  8. use App\Module\User\Validator\Username;
  9. /**
  10. * 注册验证器
  11. *
  12. */
  13. class Register extends ValidationCore
  14. {
  15. /**
  16. * @var \App\Module\Ulogic\Unit\User
  17. */
  18. public $userLogic;
  19. /**
  20. * 用户模型
  21. * @var \App\Module\User\Unit\User
  22. */
  23. public $user;
  24. public function rules($rules = []): array
  25. {
  26. return [
  27. [
  28. 'username,password,password2', 'required'
  29. ],
  30. [
  31. 'username',
  32. new UsernameNt($this),
  33. 'msg' => '用户名重复'
  34. ],
  35. [
  36. 'username',new Phone($this),
  37. 'msg'=>'手机号码不正确'
  38. ],
  39. [
  40. 'username','alphaNum',
  41. 'msg'=>'用户名只能包含字母和数字'
  42. ],
  43. [
  44. 'password', 'eqField', 'password2',
  45. 'msg' => '两次密码不一致'
  46. ]
  47. ];
  48. }
  49. }