common-password-rules
Validation methods for some common password policies.
Install
npm install common-password-rules
Usage
const cPR = ; cPR; // => true
API
- commonPasswordRules
- .containsLowerCase(password, [times]) ⇒
Boolean
- .containsUpperCase(password, [times]) ⇒
Boolean
- .containsDigit(password, [times]) ⇒
Boolean
- .containsSpecialChar(password, [times]) ⇒
Boolean
- .contains(password, charSet, [times]) ⇒
Boolean
- .excludesRecurringChars(password, [times]) ⇒
Boolean
- .excludesSequentialLetters(password, [times]) ⇒
Boolean
- .excludesSequentialDigits(password, [times]) ⇒
Boolean
- .excludesBirthDate(password) ⇒
Boolean
- .containsLowerCase(password, [times]) ⇒
Boolean
containsLowerCase(password, [times]) ⇒ Checks whether the given password contains a lowercase letter.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
1 |
Minimum number of required lowercase letters |
Boolean
containsUpperCase(password, [times]) ⇒ Checks whether the given password contains an uppercase letter.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
1 |
Minimum number of required uppercase letters |
Boolean
containsDigit(password, [times]) ⇒ Checks whether the given password contains a digit.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
1 |
Minimum number of required digits |
Boolean
containsSpecialChar(password, [times]) ⇒ Checks whether the given password contains a special (non-word) character.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
1 |
Minimum number of required special characters |
Boolean
contains(password, charSet, [times]) ⇒ Checks whether the given password contains a character from the given set.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
charSet | String |
A regex character set | |
[times] | Integer |
1 |
Minimum number of required characters |
Boolean
excludesRecurringChars(password, [times]) ⇒ Checks that the given password does not contain recurring alphanumeric characters.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
3 |
Minimum recursion number |
Boolean
excludesSequentialLetters(password, [times]) ⇒ Checks that the given password does not contain sequential case-insensitive letters.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
3 |
Minimum sequence |
Boolean
excludesSequentialDigits(password, [times]) ⇒ Checks that the given password does not contain sequential digits.
Param | Type | Default | Description |
---|---|---|---|
password | String |
Password string | |
[times] | Integer |
3 |
Minimum sequence |
Boolean
excludesBirthDate(password) ⇒ Checks that the given password does not a possible birth-date.
Param | Type | Description |
---|---|---|
password | String |
Password string |