Skip to content

API v4.0.0

Tarun Batra edited this page Jun 28, 2017 · 1 revision

PasswordValidator

Kind: global class

new PasswordValidator()

Creates a password-validator schema

passwordValidator.validate(pwd, options) ⇒ boolean | array

Method to validate the password against schema

Kind: instance method of PasswordValidator
Returns: boolean | array - 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

Param Type Description
pwd string password to valdiate
options object optional options to configure validation
[options.list] boolean asks for a list of validation failures instead of just true/false

passwordValidator.not()

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

Kind: instance method of PasswordValidator

passwordValidator.has()

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

Kind: instance method of PasswordValidator

passwordValidator.is()

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

Kind: instance method of PasswordValidator

passwordValidator.min(num)

Rule to specify a minimum length of the password

Kind: instance method of PasswordValidator

Param Type Description
num number minimum length

passwordValidator.max(num)

Rule to specify a maximum length of the password

Kind: instance method of PasswordValidator

Param Type Description
num number maximum length

passwordValidator.digits()

Rule to mendate the presense of digits in the password

Kind: instance method of PasswordValidator

passwordValidator.letters()

Rule to mendate the presense of letters in the password

Kind: instance method of PasswordValidator

passwordValidator.uppercase()

Rule to mendate the presense of uppercase letters in the password

Kind: instance method of PasswordValidator

passwordValidator.lowercase()

Rule to mendate the presense of lowercase letters in the password

Kind: instance method of PasswordValidator

passwordValidator.symbols()

Rule to mendate the presense of symbols in the password

Kind: instance method of PasswordValidator

passwordValidator.spaces()

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

Kind: instance method of PasswordValidator

passwordValidator.oneOf(list)

Rule to whitelist words to be used as password

Kind: instance method of PasswordValidator

Param Type Description
list array list of values allowed