Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kisaw88's avatar

How to change the password reset validation

How to change the validation of the password when reseting a password Laravel 5.8 ?

0 likes
6 replies
Snapey's avatar
Snapey
Best Answer
Level 122

In the ResetPasswordController there is a trait which includes a lot of the code, and the validation rules.

In a class, you can override the trait by including the same name method, so if you copy the code from the trait to your class you can amend it how you need.

Create a method (in Auth/ResetPasswordController.php) as below;

    /**
     * Get the password reset validation rules.
     *
     * @return array
     */
    protected function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ];
    }

And change the rule as you require

5 likes
franzag's avatar

there is a way to specify the messages of that rules? like:

return Validator::make($data, [
            'username' => ['required', 'string', 'min:4', 'max:255', 'unique:users'],
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            // 'password' => ['required', 'string', 'min:8', 'confirmed'],
            'password' => ['required', 'string', 'min:8', 'confirmed', 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$/'],
        ],['password.regex' => 'Las contraseñas deben contener letras, números y simbolos']);
Snapey's avatar

@donclemenzo doesn't work for YOU? Why not start a question with your own circumstances and explain what 'doesn't work' means

axis80's avatar

Just a note to confirm that the code posted by Snapey worked for me in Laravel 8.

Please or to participate in this conversation.