UserChangePwdRequest.php
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Request;
use App\Helpers\PasswordHelper;
use Hikoon\LaravelApi\Support\ApiRequest;
class UserChangePwdRequest extends ApiRequest
{
/**
* @return void
*/
protected function passedValidation(): void
{
if ($this->has('password')) {
$this->getInputSource()?->set('password', PasswordHelper::make($this->input('password')));
optional($this->getValidatorInstance())->setData($this->all());
}
}
/**
* @inheritDoc
*/
public function rules(): array
{
return [
'password' => 'required|string|confirmed|min:6|max:20',
];
}
/**
* @return string[]
*/
public function messages(): array
{
return [
'password.required' => '请输入新的密码',
'password.min' => '新的密码不能低于:min位',
'password.max' => '新的密码不能高于:max位',
'password.confirmed' => '确认密码与新密码不一致'
];
}
}