1 week ago

Using custom PasswordRequest Rule in PasswordReset

Posted 1 week ago by Loomix

I have written a custom password request rule in \app\Http\Requests\PasswordRequest.php. It works well for user registration and user edit. Now I want to use this rule when the user has requested a new password and enters his new password in \resources\views\auth\passwords\reset.blade.php. How can I refer to or import this rule (in best practise) to use it there? Thanks.

class PasswordRequest extends FormRequest

    public function rules()
        return [
            'old_password' => ['required', 'min:8', new CurrentPasswordCheckRule],
            'password' => ['required', 'min:8', 'regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#[email protected]$%^&*-]).{8,}$/', 'different:old_password', 'confirmed'],
            'password_confirmation' => ['required', 'min:8'],

Please sign in or create an account to participate in this conversation.