enforce rules for reasonable passwords

npm install password-rules
1 downloads in the last day
17 downloads in the last week
80 downloads in the last month

Build Status


Enforce rules on passwords.


npm install --save password-rules

Or download password-rules.js for a browser.


rules('pw', 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.',
   [ { 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