password-rules

enforce rules for reasonable passwords

npm install password-rules
28 downloads in the last week
87 downloads in the last month

Build Status

password-rules

Enforce rules on passwords.

install

npm install --save password-rules

Or download password-rules.js for a browser.

api

rules('pw', options)

Options:

  • minimumLength: default 8
  • requireCapital: default true
  • requireLower: default true
  • requireNumber: default true

Returns false if there are no issues. Otherwise, returns an object like

{ sentence: 'Password must be at least 8 letters long, contain a capital letter, and contain a number.',
  issues:
   [ { reason: 'minimumLength',
       message: 'Password must be at least 8 letters long',
       part: 'be at least 8 letters long' },
     { reason: 'requireCapital',
       message: 'Password must contain a capital letter',
       part: 'contain a capital letter' },
     { reason: 'requireNumber',
       message: 'Password must contain a number',
       part: 'contain a number' } ] }
npm loves you