@vcsuite/password-validator
v1.0.1
Published
A simple implementation of a password validator.
Readme
@vcsuite/password-validator
A simple implementation of a password validator.
Usage
You pass the password and a set of rules. The validation returns true if all rules pass or an array of booleans indicating
which rules passed and which rules failed.
import { validate } from '@vcsuite/password-validator';
validate('foob', [{ type: 'min', length: 4 }]); // true
validate('foobar', [
{ type: 'min', length: 4 },
{ type: 'regex', regex: '[A-Z]' },
{ type: 'repeat', maxOccurrence: 2 },
]); // [true, false, true]Rules
There are 3 rules to choose from:
minto ensure a minimal password length.regexto ensure a password matches or does NOT match a provided regex.repeateto ensure a single character does not repeat too often.
