Search code examples
laravelrestapiionic-frameworkunsafe

Unsafe character in password rest api false


How to handling unsafe character ( " < > # % { } | \ ^ ~ [ ] `") in my password using rest api laravel. example : <<@Dmin91. my authenticate attempt always get false in return.


Solution

  • Use Regular expression to allow special characters

    ^.(?=.{3,})(?=.[a-zA-Z])(?=.[0-9])(?=.[\d\x])(?=.[!$#%]).$

    E.g.

    'password' => 'required| min:6|
               regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/|
               confirmed',