Options
All
  • Public
  • Public/Protected
  • All
Menu

Module source/password

Index

Variables

Variables

Const pwd

pwd: { buildRegex: (options: IPwOptions) => RegExp; isValid: (str: string, options: IPwOptions) => boolean; isValidAdvanced: (str: string, options: IPwOptions, advOptions: IPwOptionsCount) => boolean } = ...

Type declaration

  • buildRegex: (options: IPwOptions) => RegExp
      • Takes min, max, and string of special characters and returns a RegExp for validating passwords

        Basic usage example:

        const pwd = require('stringman').pwd; // or `import {pwd} from 'stringman'`;
        const regEx = pwd.buildRegex({cap: true, lc: true, num: true, min: 8, max: 18, special: '-_=+*&'});
        console.log(regEx); // /^[A-Za-z0-9-_=+*&]{8,18}$/
        

        Parameters

        Returns RegExp

  • isValid: (str: string, options: IPwOptions) => boolean
      • Takes parameters for building a regular expression then validates the string sent and returns a boolean value

        • Basic usage example:
          const pwd = require('stringman').pwd; // or `import {pwd} from 'stringman'`;
          const valid = pwd.isValid('Test-12345*', {cap: true, lc: true, num: true, min: 8, max: 18, special: '-_=+*&'});
          const invalid = pwd.isValid('Test', {cap: true, lc: true, num: true, min: 8, max: 18, special: '-_=+*&'});
          console.log(valid); // true
          console.log(invalid); // false
          

        Parameters

        Returns boolean

  • isValidAdvanced: (str: string, options: IPwOptions, advOptions: IPwOptionsCount) => boolean
      • Validates using regex like isValid but also checks for specific number of different types of characters

        Basic usage example:

        const pwd = require('stringman').pwd; // or `import {pwd} from 'stringman'`;
        const valid = pwd.isValidAdvanced('Test-12345*', {cap: true, lc: true, num: true, min: 8, max: 18, special: '-_=+*&'}, {cap: 2, num: 2, special: 1});
        const invalid = pwd.isValidAdvanced('Test', {cap: true, lc: true, num: true, min: 8, max: 18, special: '-_=+*&'}, {cap: 4, num: 2, special: 1});
        console.log(valid); // true
        console.log(invalid); // false
        

        Parameters

        Returns boolean

Generated using TypeDoc