Skip to content

Instantly share code, notes, and snippets.

@sabid
Forked from Michael-Brooks/passwordValidation.php
Created October 10, 2017 23:40
Show Gist options
  • Save sabid/acf44164f5dc2f8e8bd59b8ce4a8a405 to your computer and use it in GitHub Desktop.
Save sabid/acf44164f5dc2f8e8bd59b8ce4a8a405 to your computer and use it in GitHub Desktop.
Laravel Password validation Regex (Contain at least one uppercase/lowercase letters and one number)
/*
* Place this with the rest of your rules.
* Doesn't need to be in an array as there are no pipes.
*/
$rules = array(
'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
);
/*
* Use this one if you also require at least one symbol.
* Needs to be in an array as it contains a pipe symbol.
*/
$rules = array(
'password' => array(
'required',
'min:6',
'regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(_|[^\w])).+$/'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment