The function can be imported using ES6 syntax from the "password-strength-tester" package:
import { passwordStrengthTester } from 'multiform-validator';Alternatively, you can import the function using CommonJS syntax with require (Node.js):
const { passwordStrengthTester } = require('multiform-validator');password (string) - The password to be evaluated for strength.options (object) - An optional object that can be passed to the function to customize the strength criteria.isVeryWeak (password: string, passwordLength: number) -> booleanisWeak (password: string, passwordLength: number) -> booleanisRegular (password: string, passwordLength: number) -> booleanisStrong (password: string, passwordLength: number) -> booleanisVeryStrong (password: string, passwordLength: number) -> boolean import { passwordStrengthTester } from 'multiform-validator';
const password = "P@ssw0rd123";
const customOptions = {
isVeryWeak: (password, passwordLength) => passwordLength < 6,
isWeak: (password, passwordLength) => passwordLength >= 6 && passwordLength < 8,
isRegular: (password, passwordLength) => passwordLength >= 8 && passwordLength < 10,
isStrong: (password, passwordLength) => passwordLength >= 10 && passwordLength < 12,
isVeryStrong: (password, passwordLength) => passwordLength >= 12,
};
const customResult = passwordStrengthTester(password, customOptions);
console.log(customResult); // "Strong"