1.0.1-alpha • Published 1 year ago

@neiwad/pwdckr v1.0.1-alpha

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

🔑 PWDCKR

Pwdckr is a simple librairy to check password validation.

demo.gif

How to use?

pnpm install @neiwad/pwdckr

Create a Pwdckr instance with default validators

import { Pwdckr } from '@neiwad/pwdckr'
const pwdckr = new Pwdckr()

Create a Pwdckr instance with custom validators

import { Pwdckr } from '@neiwad/pwdckr'
const pwdckr = new Pwdckr({
    minLength: 10, 
    hasUpperCase: true,
    hasSpecialChar: true,
    hasLowerCase: false, //Don't check pwd for lowercase(s)
    hasNumber: false, //Don't check pwd for number(s)
})

Params

Param NameTypeDefault
minLengthint8
maxLengthint16
hasNumberbooleantrue
hasSpecialCharbooleantrue
hasUpperCasebooleantrue
hasLowerCasebooleantrue

hasSpecialChar note: currently pwdckr doesnt allow custom regex for special characteres checking. The current special char regex is: [!@#$%^&()_+-=[]{};':"\|,.<>\/?]*

Methods

Update the value of the password

pwdckr.updateValue(value)

Variables

Global status of pwdckr

pwdckr.isValid //return the global status of pwdckr (true | false)

Global status of validators

pwdckr.validators //return the status of validators

Example of validators status

minLength: {
    "value": 8, //Defined only for minLength and maxLength
    "isValid": true,
    "isActive": true
},
maxLength: {
    "value": 8, //Defined only for minLength and maxLength
    "isValid": true,
    "isActive": true
},
hasNumber: {
    "isValid": true,
    "isActive": true
},
hasSpecialChar: {
    "isValid": true,
    "isActive": true
},
hasUpperCase: {
    "isValid": true,
    "isActive": true
},
hasLowerCase: {
    "isValid": true,
    "isActive": true
}