data_center/app/common/validate/login/PasswordValidate.php

50 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-09-18 09:11:13 +08:00
<?php
namespace app\common\validate\login;
use app\common\validate\BaseValidate;
/**
* 密码校验
* Class PasswordValidate
* @package app\api\validate
*/
class PasswordValidate extends BaseValidate
{
protected $rule = [
'phone' => 'require|mobile',
'code' => 'require',
'old_password' => 'require',
2023-09-19 17:39:40 +08:00
'password' => 'require|length:6,20|different:old_password',
2023-09-18 09:11:13 +08:00
'password_confirm' => 'require|confirm',
];
protected $message = [
'phone.require' => '请输入手机号',
'phone.mobile' => '请输入正确手机号',
'code.require' => '请填写验证码',
'password.require' => '请输入新密码',
'password.length' => '密码须在6-25位之间',
2023-09-19 17:39:40 +08:00
'password.different' => '新密码不能和原密码一样',
2023-09-18 09:11:13 +08:00
'password_confirm.require' => '请确认密码',
'password_confirm.confirm' => '确认密码和新密码不一致',
'old_password.require' => '请输入原密码',
];
//重置登录密码
public function sceneResetPassword(): PasswordValidate
{
return $this->only(['phone', 'code', 'password', 'password_confirm']);
}
//修改密码场景
public function sceneChangePassword(): PasswordValidate
{
return $this->only(['old_password','password', 'password_confirm']);
}
}