Skip to content

tarunbatra/password-validator-python

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Password Validator
pypi version Build Code Coverage Python version GitHub release

password_validator

This is a python port of npm package password-validator.

Install

pip install password-validator

Usage

from password_validator import PasswordValidator

# Create a schema
schema = PasswordValidator()

# Add properties to it
schema\
.min(8)\
.max(100)\
.has().uppercase()\
.has().lowercase()\
.has().digits()\
.has().no().spaces()\

# Validate against a password string
print(schema.validate('validPASS123'));
# => True
print(schema.validate('invalidPASS'));
# => False

Rules

Rules supported as of now are:

Rules Descriptions
digits() specifies password must include digits
letters() specifies password must include letters
lowercase() specifies password must include lowercase letters
uppercase() specifies password must include uppercase letters
symbols() specifies password must include symbols
spaces() specifies password must include spaces
min(len) specifies minimum length
max(len) specifies maximum length
no([regex]) inverts the result of validations applied next
has([regex]) inverts the effect of no() and applies a regex (optional)

For more examples and complete API reference, check the documentation.

License

MIT License