Skip to content

Instantly share code, notes, and snippets.

@brunokiafuka
Created May 24, 2021 17:53
Show Gist options
  • Save brunokiafuka/ea841ff9a0433b8364a3296b0813636d to your computer and use it in GitHub Desktop.
Save brunokiafuka/ea841ff9a0433b8364a3296b0813636d to your computer and use it in GitHub Desktop.
Check Password Strength.
const strongPassword = new RegExp(
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})'
);
const mediumPassword = new RegExp(
'^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})'
);
export const isPasswordStrong = (value = ''): boolean => {
if (strongPassword.test(value)) {
return true;
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment