UserCheck.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021 勾股工作室
  4. * @license https://opensource.org/licenses/Apache-2.0
  5. * @link https://www.gougucms.com
  6. */
  7. namespace app\home\validate;
  8. use think\Validate;
  9. class UserCheck extends Validate
  10. {
  11. protected $regex = [ 'checkUser' => '/^[A-Za-z]{1}[A-Za-z0-9_-]{4,19}$/'];
  12. protected $rule = [
  13. 'name' => 'require',
  14. 'password' => 'require',
  15. 'username' => 'require|regex:checkUser|unique:user',
  16. 'pwd' => 'require|min:6|confirm',
  17. 'captcha' => 'require|captcha',
  18. ];
  19. protected $message = [
  20. 'name.require' => '账号不能为空',
  21. 'password.require' => '密码不能为空',
  22. 'username.require' => '账号不能为空',
  23. 'username.regex' => '账号必须是以字母开头,只能包含字母数字下划线和减号,5到20位',
  24. 'username.unique' => '同样的登录账号已经存在',
  25. 'pwd.require' => '密码不能为空',
  26. 'pwd.min' => '密码必须6位以上',
  27. 'pwd.confirm' => '两次密码不一致', //confirm自动相互验证
  28. 'captcha.require' => '验证码不能为空',
  29. 'captcha.captcha' => '验证码不正确',
  30. ];
  31. protected $scene = [
  32. 'login' => ['name', 'password', 'captcha'],
  33. 'reg' => ['username', 'pwd', 'captcha'],
  34. ];
  35. }