5.2.0 • Published 10 months ago

joi-password-complexity v5.2.0

Weekly downloads
3,908
License
MIT
Repository
github
Last release
10 months ago

Joi Password Complexity

Creates a Joi object that validates password complexity.

Requirements

  • Joi v17 or higher

Installation

npm install joi-password-complexity

Examples

No options specified

const passwordComplexity = require("joi-password-complexity");
passwordComplexity().validate("aPassword123!");

When no options are specified, the following are used:

{
  min: 8,
  max: 26,
  lowerCase: 1,
  upperCase: 1,
  numeric: 1,
  symbol: 1,
  requirementCount: 4,
}

Options specified

const passwordComplexity = require("joi-password-complexity");

const complexityOptions = {
  min: 10,
  max: 30,
  lowerCase: 1,
  upperCase: 1,
  numeric: 1,
  symbol: 1,
  requirementCount: 2,
};

passwordComplexity(complexityOptions).validate("aPassword123!");

Error Label (optional) Specified

const label = "Password"

const passwordComplexity = require("joi-password-complexity");
  • For default options:
passwordComplexity(undefined, label).validate("aPassword123!");
  • For specified options:
passwordComplexity(complexityOptions, label).validate("aPassword123!");

The resulting error message: 'Password should be at least 8 characters long'

License

MIT

5.2.0

10 months ago

5.1.0

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago