UserCancel.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\api\validate;
  3. use think\Validate;
  4. class UserCancel extends Validate
  5. {
  6. /**
  7. * 验证规则
  8. */
  9. protected $rule = [
  10. 'type' => 'require|in:mobile,email',
  11. 'mobile' => 'regex:^1\d{10}$|requireIf:type,mobile',
  12. 'email' => 'email|requireIf:type,email',
  13. 'captcha' => 'require',
  14. 'newpassword' => 'require|length:6,30',
  15. ];
  16. /**
  17. * 提示消息
  18. */
  19. protected $message = [
  20. 'type.require' => '验证类型不能为空',
  21. 'type.in' => '验证类型只能是手机号或邮箱',
  22. 'mobile.regex' => '手机号格式不正确',
  23. 'mobile.requireIf' => '手机号不能为空',
  24. 'email.email' => '邮箱格式不正确',
  25. 'email.requireIf' => '邮箱不能为空',
  26. 'captcha.require' => '验证码不能为空',
  27. 'newpassword.require' => '新密码不能为空',
  28. 'newpassword.length' => '新密码长度必须在6-30个字符之间'
  29. ];
  30. /**
  31. * 验证场景
  32. */
  33. protected $scene = [
  34. 'cancel' => ['type', 'mobile', 'email', 'captcha'],
  35. 'resetpwd' => ['type', 'mobile', 'email', 'newpassword', 'captcha'],
  36. ];
  37. }