skip to Main Content

It is not working in Laravel 10, How can I develop it in a proper way?

'password' => [
    'required|confirmed',
    Password::min(8)
        ->letters()
        ->mixedCase()
        ->numbers()
        ->symbols()
        ->uncompromised()
],

Trying strong password validation in Laravel 10 but it does not work. Hope an expert helps me to develop this.

2

Answers


  1. Chosen as BEST ANSWER

    Solution:

    'password' => 'required|confirmed|min:8|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[$@$!%*?&])[A-Za-zd$@$!%*?&]+$/',
    

  2. I’m not a expert but I can try helping you
    Laravel Validation have alot of rules

        $request->validate([
        'password' => 'required|min:8|regex:^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*W).+$',
    ]);
    

    Explanation of this regex pattern:

    ^ asserts the start of the line.
    (?=.*[a-z]) means there must be at least one lowercase letter.

    (?=.*[A-Z]) means there must be at least one uppercase letter.

    (?=.*d) means there must be at least one digit.

    (?=.*W) means there must be at least one special character (not a letter or digit).

    .+ matches any character (letters, digits, symbols) one or more times.

    $ asserts the end of the line.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search