Skip to content

Instantly share code, notes, and snippets.

@rafaelqueiroz88
Created October 4, 2023 00:29
Show Gist options
  • Save rafaelqueiroz88/53ef147a7b60bb1b485b4b9f58dcd3f9 to your computer and use it in GitHub Desktop.
Save rafaelqueiroz88/53ef147a7b60bb1b485b4b9f58dcd3f9 to your computer and use it in GitHub Desktop.
Dart Regular Expression (Refex)
/**
* It forces strong passwords
* @require String password
* @return bool
*
* return true if password has:
* 1 capitalized character
* 1 special character
* 1 number
*/
bool checkPasswordRequirements(String password) {
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$';
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(password);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment