SmsRegisterValidate.php 901 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-05-18
  7. *
  8. *
  9. */
  10. namespace app\validate\admin;
  11. use think\Validate;
  12. class SmsRegisterValidate extends Validate
  13. {
  14. protected $failException = true;
  15. protected $rule = [
  16. 'account|账号' => 'require',
  17. 'password|密码' => 'require',
  18. 'phone|手机号' => 'require|isPhone',
  19. 'code|验证码' => 'require',
  20. 'url|域名' => 'require|url',
  21. 'sign|短信签名' => 'require|max:8'
  22. ];
  23. protected function isPhone($val)
  24. {
  25. if (!preg_match('/^1[3456789]{1}\d{9}$/', $val))
  26. return '请输入正确的手机号';
  27. else
  28. return true;
  29. }
  30. public function isLogin()
  31. {
  32. unset($this->rule['phone|手机号'], $this->rule['code|验证码'], $this->rule['url|域名'], $this->rule['sign|短信签名']);
  33. return $this;
  34. }
  35. }