@vcsuite/password-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@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:

  1. min to ensure a minimal password length.
  2. regex to ensure a password matches or does NOT match a provided regex.
  3. repeate to ensure a single character does not repeat too often.

Readme

Keywords

none

Package Sidebar

Install

npm i @vcsuite/password-validator

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

27.9 kB

Total Files

7

Last publish

Collaborators

  • bkuster
  • jbolling