jeudi 8 octobre 2015

How to validate passwords with Laravel 5.1

I would like to validate a password so that it meets the following:

  • is at least 8 characters long
  • contains at least 1 uppercase letter
  • contains at least 1 lowercase letter
  • contains at least 1 special character
  • matches a confirmation field

Currently i have:

$validator = \Validator::make($request, [
    'password' => 'min:8|confirmed'
],[
    'password.confirmed' => 'Both `password` and `password_confirmation` are required',
    'password.min' => 'The password must contain at least 8 characters'
]);

This will take care of the min length and the confirmation but i can find a good way to do the other check. Any help will be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire