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

49 lines
1.2 KiB
PHP

<?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',
'password' => 'require|length:6,20',
'password_confirm' => 'require|confirm',
];
protected $message = [
'phone.require' => '请输入手机号',
'phone.mobile' => '请输入正确手机号',
'code.require' => '请填写验证码',
'password.require' => '请输入新密码',
'password.length' => '密码须在6-25位之间',
'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']);
}
}