Validates the given PasswordRequirements instance's values.
This returns a mutated copy of the config instance where the values satisfy "sane minimum requirements" suitable for any password.
config
The phrase "sane minimum requirements" implies
length is not less than 10
length
To avoid repetitions, length is not more than
specials character count does not overrule the required number of
specials
decimal
decimal character count does not overrule the required number of
If this function finds a conflict between the specified number of specials characters and decimal, then decimal integers takes precedence.
For example:
const cpg = require('@mk-pass/mk-pass');const assert = require('node:assert/strict');let config = { length: 16, specials: 15, decimal: 15};let expected = { length: 16, decimal: 13, specials: 1, firstIsLetter: true};assert.isDeepStrictEqual( validateRequirements(config), expected); Copy
const cpg = require('@mk-pass/mk-pass');const assert = require('node:assert/strict');let config = { length: 16, specials: 15, decimal: 15};let expected = { length: 16, decimal: 13, specials: 1, firstIsLetter: true};assert.isDeepStrictEqual( validateRequirements(config), expected);
Validates the given PasswordRequirements instance's values.
This returns a mutated copy of the
configinstance where the values satisfy "sane minimum requirements" suitable for any password.The phrase "sane minimum requirements" implies
lengthis not less than 10To avoid repetitions,
lengthis not more thanspecialscharacter count does not overrule the required number ofdecimalis specified as non-zero value)decimalcharacter count does not overrule the required number ofspecialsis specified as non-zero value)About resolving conflicts
If this function finds a conflict between the specified number of
specialscharacters anddecimal, then decimal integers takes precedence.For example: