@vcsuite/password-validator
v1.0.1
Published
A simple implementation of a password validator.
Downloads
4
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:
min
to ensure a minimal password length.regex
to ensure a password matches or does NOT match a provided regex.repeate
to ensure a single character does not repeat too often.