RegisterValidates.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\api\user;
  12. use think\Validate;
  13. /**
  14. * 注册验证
  15. * Class RegisterValidates
  16. * @package app\http\validates\api\user
  17. */
  18. class RegisterValidates extends Validate
  19. {
  20. protected $regex = ['phone' => '/^1[3456789]\d{9}$/'];
  21. protected $rule = [
  22. 'phone' => 'require|regex:phone',
  23. 'account' => 'require|regex:phone',
  24. 'captcha' => 'require|length:6',
  25. 'password' => 'require',
  26. ];
  27. protected $message = [
  28. 'phone.require' => '手机号必须填写',
  29. 'phone.regex' => '手机号格式错误',
  30. 'account.require' => '手机号必须填写',
  31. 'account.regex' => '手机号格式错误',
  32. 'captcha.require' => '验证码必须填写',
  33. 'captcha.length' => '验证码长度不正确',
  34. 'password.require' => '密码必须填写',
  35. ];
  36. public function sceneCode()
  37. {
  38. return $this->only(['phone']);
  39. }
  40. public function sceneRegister()
  41. {
  42. return $this->only(['account', 'captcha', 'password']);
  43. }
  44. }