PasswordValidator

PasswordValidator

new PasswordValidator()

Source:
Creates a password-validator schema

Methods

digits(countopt, descriptionopt) → {PasswordValidator}

Source:
Rule to mandate the presence of digits in the password
Parameters:
Name Type Attributes Description
count number <optional>
minimum number of digits required
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

has(patternopt, descriptionopt) → {PasswordValidator}

Source:
Rule to invert the effects of 'not' Apart from that, 'has' is also used to make the api readable and chainable
Parameters:
Name Type Attributes Description
pattern string | RegExp <optional>
pattern to match
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

is() → {PasswordValidator}

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

letters(countopt, descriptionopt) → {PasswordValidator}

Source:
Rule to mandate the presence of letters in the password
Parameters:
Name Type Attributes Description
count number <optional>
minimum number of letters required
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

lowercase(countopt, descriptionopt) → {PasswordValidator}

Source:
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
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

max(num, descriptionopt) → {PasswordValidator}

Source:
Rule to specify a maximum length of the password
Parameters:
Name Type Attributes Description
num number maximum length
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

min(num, descriptionopt) → {PasswordValidator}

Source:
Rule to specify a minimum length of the password
Parameters:
Name Type Attributes Description
num number minimum length
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

not(patternopt, descriptionopt) → {PasswordValidator}

Source:
Rule to invert the next applied rules. All the rules applied after 'not' will have opposite effect, until 'has' rule is applied
Parameters:
Name Type Attributes Description
pattern string | RegExp <optional>
pattern to not match
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

oneOf(list, descriptionopt) → {PasswordValidator}

Source:
Rule to whitelist words to be used as password
Parameters:
Name Type Attributes Description
list array list of values allowed
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

spaces(countopt, descriptionopt) → {PasswordValidator}

Source:
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
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

symbols(countopt, descriptionopt) → {PasswordValidator}

Source:
Rule to mandate the presence of symbols in the password
Parameters:
Name Type Attributes Description
count number <optional>
minimum number of symbols required
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

uppercase(countopt, descriptionopt) → {PasswordValidator}

Source:
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
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

usingPlugin(fn, descriptionopt) → {PasswordValidator}

Source:
Insert a plugin function into the validation chain
Parameters:
Name Type Attributes Description
fn Plugin A plugin function
description string <optional>
description of the validation
Returns:
instance of PasswordValidator schema
Type
PasswordValidator

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

Source:
Method to validate the password against schema
Parameters:
Name Type Attributes Description
pwd string password to validate
options object <optional>
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
details boolean <optional>
asks for more details about failed validations including arguments, and error messages
Returns:
Boolean value indicting the validity of the password as per schema, if 'options.list' or 'options.details' is not set. Otherwise, it returns an array of property names which failed validations
Type
boolean | array