PasswordValidate.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\validate;
  15. use app\common\validate\BaseValidate;
  16. /**
  17. * 密码校验
  18. * Class PasswordValidate
  19. * @package app\api\validate
  20. */
  21. class PasswordValidate extends BaseValidate
  22. {
  23. protected $rule = [
  24. 'mobile' => 'require|mobile',
  25. 'code' => 'require',
  26. 'password' => 'require|length:6,20|alphaNum',
  27. 'password_confirm' => 'require|confirm',
  28. ];
  29. protected $message = [
  30. 'mobile.require' => '请输入手机号',
  31. 'mobile.mobile' => '请输入正确手机号',
  32. 'code.require' => '请填写验证码',
  33. 'password.require' => '请输入密码',
  34. 'password.length' => '密码须在6-25位之间',
  35. 'password.alphaNum' => '密码须为字母数字组合',
  36. 'password_confirm.require' => '请确认密码',
  37. 'password_confirm.confirm' => '两次输入的密码不一致'
  38. ];
  39. /**
  40. * @notes 重置登录密码
  41. * @return PasswordValidate
  42. * @author 段誉
  43. * @date 2022/9/16 18:11
  44. */
  45. public function sceneResetPassword()
  46. {
  47. return $this->only(['mobile', 'code', 'password', 'password_confirm']);
  48. }
  49. /**
  50. * @notes 修改密码场景
  51. * @return PasswordValidate
  52. * @author 段誉
  53. * @date 2022/9/20 19:14
  54. */
  55. public function sceneChangePassword()
  56. {
  57. return $this->only(['password', 'password_confirm']);
  58. }
  59. }