User.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User:林志杰
  5. * Email:[email protected]
  6. * Motto:纵有疾风起,人生不言弃!
  7. * Time:2020/1/11 23:40
  8. */
  9. declare(strict_types=1);
  10. namespace app\api\validate;
  11. use think\Validate;
  12. class User extends Validate
  13. {
  14. protected $rule = [
  15. 'username' => 'require',
  16. 'phoneNumber' => 'require',
  17. 'code' => 'require|number|min:4',
  18. 'type' => 'require|in:1,2',
  19. 'sex' => 'require|in:0,1,2'
  20. ];
  21. protected $message = [
  22. 'username' => '用户名必须',
  23. 'phoneNumber' => '电话号码必须',
  24. 'code.require' => '短信验证码必须',
  25. 'code.number' => '短信验证码为数字',
  26. 'code.min' => '短信验证码长度不得低于4',
  27. 'type.require' => '类型必须',
  28. 'type.in' => '类型数值错误',
  29. 'sex.require' => '性别必须',
  30. 'sex.in' => '性别数值错误',
  31. ];
  32. protected $scene = [
  33. 'send_code' => ['phoneNumber'],
  34. 'login' => ['phoneNumber', 'code', 'type'],
  35. 'update_user' => ['username', 'sex']
  36. ];
  37. }