RegisterValidates.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\http\validates\user;
  3. use think\Validate;
  4. /**
  5. * 注册验证
  6. * Class RegisterValidates
  7. * @package app\http\validates\user
  8. */
  9. class RegisterValidates extends Validate
  10. {
  11. protected $regex = [ 'phone' => '/^1[3456789]\d{9}$/'];
  12. protected $rule = [
  13. 'phone' => 'require|regex:phone',
  14. 'account' => 'require|regex:phone',
  15. 'captcha' => 'require|length:6',
  16. 'password' => 'require',
  17. 'payment_pas' => 'require|length:6'
  18. ];
  19. protected $message = [
  20. 'phone.require' => '手机号必须填写',
  21. 'phone.regex' => '手机号格式错误',
  22. 'account.require' => '手机号必须填写',
  23. 'account.regex' => '手机号格式错误',
  24. 'captcha.require' => '验证码必须填写',
  25. 'captcha.length' => '验证码不能超过6个字符',
  26. 'password.require' => '密码必须填写',
  27. 'payment_pas.require' => '支付密码不能为空',
  28. 'payment_pas.length' => '支付密码是六位数'
  29. ];
  30. public function sceneCode()
  31. {
  32. return $this->only(['phone']);
  33. }
  34. public function sceneRegister()
  35. {
  36. return $this->only(['account','captcha','password','payment_pas']);
  37. }
  38. }