Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

validate-password

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-password

Strengthen your user's passwords

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Validate Password

JS password validation for the client and the server.

npm version license

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.

Features

  • Lowercase verification
  • Uppercase verification
  • Special Characters verification
  • Numbers verification
  • Strings that are not allowed verification

Installation

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...

Contribute

We would love for you to contribute to validate-password, check the LICENSE file for more info.

Meta

Mike DeWitt – http://devdewitt.com/

Distributed under the MIT license. See LICENSE for more information.

https://github.com/mndewitt/validate-password

FAQs

Package last updated on 20 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc