Skip to content

Latest commit

 

History

History
118 lines (87 loc) · 3.09 KB

README.md

File metadata and controls

118 lines (87 loc) · 3.09 KB

check-password-complexity

check-password-complexity: A simple javascript utility to check password strength and complexity.

Demo

Installation

npm  install check-password-complexity

or

yarn  add check-password-complexity

Get started

Simple usage

import { checkPasswordComplexity } from "check-password-complexity";

// OR

const { checkPasswordComplexity } = require("check-password-complexity");

console.log(checkPasswordComplexity("abcdefgh").value); // tooWeak

checkPasswordComplexity("abcdefg8").value; // weak

checkPasswordComplexity("abcdefgh9").value; // medium

checkPasswordComplexity("abcdefgh9F=").value; // strong

Result

Property Type Description
value tooWeak, weak, medium, strong Too Weak, Weak, Medium or Strong
checkedRules (minLength, lowercase, uppercase, number, specialCharacter)[] List of all checked values
length number Length of the password

  checkPasswordComplexity("abcdefg");
  /**
     checkedRules: ['lowercase']
      length: 7
      value: "tooWeak"
   */

  checkPasswordComplexity("abcdefg8");
  /**
     checkedRules: ['lowercase', 'number']
      length: 8
      value: "weak"
   */

  checkPasswordComplexity("abcdefgh9");
  /**
     checkedRules: ['minLength', 'lowercase', 'number']
      length: 9
      value: "medium"
   */

  checkPasswordComplexity("abcdefgh9F=");
  /**
     checkedRules: ['minLength', 'lowercase', 'uppercase', 'number', 'specialCharacter']
      length: 11
      value: "strong"
   */

Options

property type Default value Description
minLength number 8 Number of minimum character
allowedSpecialChar string !@#$%^&*(),.?":{}<>\[\]\\/`~;'_+=- regex for the special character to use

  checkPasswordComplexity("abcdefg", { minLength: 6 });
  /**
     checkedRules: ['minLength', 'lowercase']
      length: 7
      value: "weak"
   */

   // example: "." is the special character to be allowed
  checkPasswordComplexity("abcdefg.", { allowedSpecialChar: "." });
  /**
     checkedRules: ['lowercase', 'specialCharacter']
      length: 8
      value: "weak"
   */

Libraries using check-password-complexity

Contributing

Contributions & pull requests are welcome! Get started here.

If you find this project useful, don't forget to give a ★ on GitHub