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

alya_alsiyabi's avatar

Password validation

I am trying to validate the password, but it doesn't work. I could not understand why ?so When I put numbers only or only letters the code accept them

   $this->validate($request, [
        'name' => 'required',
        'email' => 'required|email|unique:users,email',
        'password' =>  ['required', 'confirmed',Password::min(8)
        ->letters()
        ->mixedCase()
        ->numbers()
        ->symbols()
        ->uncompromised()    ],
        'roles' => 'required',
     ]);
0 likes
2 replies
alya_alsiyabi's avatar

@SilenceBringer When I put numbers only or only letters the code accept them

'password' => ['required', 
            'min:8','string','regex:/[a-z]/', 'regex:/[A-Z]/','regex:/[0-9]/', 'regex:/[@$!%*#?&]/',
             'confirmed'],

and this one

                'password' => 'required|min:8|string|regex:/[a-z]/|regex:/[0-9]/|regex:/[A-Z]|regex:/[@$!%*#?&]|confirmed',

Please or to participate in this conversation.