Validate Password complexity with Joi and zxcvbn
npm install --save joi-zxcvbn
or
yarn add joi-zxcvbn
var joiZxcvbn = require('joi-zxcvbn')
var PlainJoi = require('joi');
var Joi = PlainJoi.extend(joiZxcvbn(PlainJoi));
var minimumScore = 3; // default - must in 0...4
var userInputs = ['janedoe', '[email protected]']; // optional & best practice
Joi.string().min(4).zxcvbn(minimumScore, userInputs).validate('👍🐴🔋❤️', function (err) {
console.log(err ? 'Invalid' : 'Valid')
})
Have a look at the tests.js
to see how to parse its results. feedback, score, calc_time
are
passed trough. calc_time
is renamed to calcTime
just because.
For configuration options, see dropbox/zxcvbn