Methods
digits(countopt)
Rule to mandate the presence of digits in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of digits required |
has()
Rule to invert the effects of 'not'
Apart from that, 'has' is also used
to make the api readable and chainable
is()
Rule to invert the effects of 'not'
Apart from that, 'is' is also used
to make the api readable and chainable
letters(countopt)
Rule to mandate the presence of letters in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of letters required |
lowercase(countopt)
Rule to mandate the presence of lowercase letters in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of lowercase letters required |
max(num)
Rule to specify a maximum length of the password
Parameters:
Name | Type | Description |
---|---|---|
num |
number | maximum length |
min(num)
Rule to specify a minimum length of the password
Parameters:
Name | Type | Description |
---|---|---|
num |
number | minimum length |
not()
Rule to invert the next applied rules.
All the rules applied after 'not' will have opposite effect,
until 'has' rule is applied
oneOf(list)
Rule to whitelist words to be used as password
Parameters:
Name | Type | Description |
---|---|---|
list |
array | list of values allowed |
spaces(countopt)
Rule to mandate the presence of space in the password
It can be used along with 'not' to not allow spaces
in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of spaces required |
symbols(countopt)
Rule to mandate the presence of symbols in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of symbols required |
uppercase(countopt)
Rule to mandate the presence of uppercase letters in the password
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
count |
number |
<optional> |
minimum number of uppercase letters required |
validate(pwd, options) → {boolean|array}
Method to validate the password against schema
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
pwd |
string | password to validate | ||||||||
options |
object | optional options to configure validation
Properties
|
Returns:
Boolean value indicting the validity
of the password as per schema, if 'options.list'
is not set. Otherwise, it returns an array of
property names which failed validations
- Type
- boolean | array