
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
validate-password
Advanced tools
JS password validation for the client and the server.
Enforce stronger passwords for users by checking for uppercase/lowercase letters, numbers, and special characters.
You can also check passwords for certain strings. This is ideal for preventing users from entering their name or email in the password. Or, you can search the password for common words, to further encourage the user to pick a strong password.
Install via NPM:
npm install validate-password
##Usage
This can be used as a stand alone package:
<script src="node_modules/validate-password/dist/validate-password.min.js"></script>
or as a CommonJS module:
var ValidatePassword = require('validate-password');
Start by instantiating the password validator:
var validator = new ValidatePassword();
...And use the .checkPassword()
method to validate the password.
.checkPassword()
accepts two arguments - first, the password as a string:
var passwordData = validator.checkPassword('aaaaa');
console.log(passwordData.isValid); // false
console.log(passwordData.validationMessage); // 'The password must contain at least one uppercase letter'
And, optionally, an array of strings that are not allowed to be in the password:
var checkPasswordForName = validator.checkPassword('cat123aaBa$%^#$%#$%', ['cat123']);
console.log(passwordData.isValid); // false
console.log(passwordData.validationMessage); // 'The password cannot contain cat123'
See the examples directory for more detailed use cases...
##Options
By default, the validator checks for uppercase/lowercase letters, numbers, and special characters.
You can also pass in custom configuration options when instantiating the validator, to loosen these default rules:
var options = {
enforce: {
lowercase: true,
uppercase: true,
specialCharacters: false,
numbers: true
}
};
var validator = new ValidatePassword(options);
The validator will now not check the password for special characters...
We would love for you to contribute to validate-password, check the LICENSE
file for more info.
Mike DeWitt – http://devdewitt.com/
Distributed under the MIT license. See LICENSE
for more information.
FAQs
Strengthen your user's passwords
The npm package validate-password receives a total of 0 weekly downloads. As such, validate-password popularity was classified as not popular.
We found that validate-password demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.