PasswordValidator

PasswordValidator

new PasswordValidator()

Source:
Creates a password-validator schema

Methods

digits()

Source:
Rule to mendate the presense of digits in the password

has()

Source:
Rule to invert the effects of 'not' Apart from that, 'has' is also used to make the api readable and chainable

is()

Source:
Rule to invert the effects of 'not' Apart from that, 'is' is also used to make the api readable and chainable

letters()

Source:
Rule to mendate the presense of letters in the password

lowercase()

Source:
Rule to mendate the presense of lowercase letters in the password

max(num)

Source:
Rule to specify a maximum length of the password
Parameters:
Name Type Description
num number maximum length

min(num)

Source:
Rule to specify a minimum length of the password
Parameters:
Name Type Description
num number minimum length

not()

Source:
Rule to invert the next applied rules. All the rules applied after 'not' will have opposite effect, until 'has' rule is applied

oneOf(list)

Source:
Rule to whitelist words to be used as password
Parameters:
Name Type Description
list array list of values allowed

spaces()

Source:
Rule to mendate the presense of space in the password It can be used along with 'not' to not allow spaces in the password

symbols()

Source:
Rule to mendate the presense of symbols in the password

uppercase()

Source:
Rule to mendate the presense of uppercase letters in the password

validate(pwd, options) → {boolean|array}

Source:
Method to validate the password against schema
Parameters:
Name Type Description
pwd string password to valdiate
options object optional options to configure validation
Properties
Name Type Attributes Description
list boolean <optional>
asks for a list of validation failures instead of just true/false
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