Skip to main content

Password Validator Pro

A configurable Python library for password policy validation and password strength analysis.

Version: 1.0.0
Python: 3.10+
License: MIT

What it provides

Password Validator Pro separates two concerns:

  1. Password policy validation — determines whether a password satisfies the configured rules.
  2. Password strength analysis — analyzes password characteristics and patterns, produces a score, identifies a strength level, and generates improvement suggestions.

Core capabilities

  • Minimum and maximum password length validation
  • Uppercase, lowercase, digit, and special-character rules
  • Configurable special-character set
  • Environment-based configuration through .env files and process environment variables
  • Custom validation rules through the Rule abstraction
  • Rule registration and removal through RuleRegistry
  • Repeated-character analysis
  • Repeated-group analysis
  • Sequential-pattern analysis
  • Keyboard-pattern analysis
  • Dictionary and common-password analysis
  • Character composition and estimated entropy metrics
  • Configurable strength scoring weights
  • Password-strength suggestions
  • Structured validation and strength result objects
  • src/ package layout suitable for modern Python packaging

Installation

From PyPI

python -m pip install password-validator-s

From source

git clone https://github.com/ShamimurRahmanShuvo/password-validator.git
cd password-validator
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .

For Windows PowerShell, activate the environment with:

.venv\Scripts\Activate.ps1

See docs/installation.md for the complete installation and packaging guide.

Quick start

from password_validator import PasswordValidator

validator = PasswordValidator()
result = validator.validate("MySecurePassword123!")

print(result.valid)
print(result.passed)
print(result.failed)
print(result.errors)

The validator uses the package's default password policy unless a PasswordRuleConfig is supplied.

Configure the password policy

from password_validator import PasswordValidator
from password_validator.config.settings import PasswordRuleConfig

config = PasswordRuleConfig(
    min_length=12,
    max_length=64,
    require_uppercase=True,
    require_lowercase=True,
    require_digit=True,
    require_special=True,
    special_characters="!@#$%^&*()-_=+[]{}|;:'\",.<>?/`~",
)

validator = PasswordValidator(config=config)
result = validator.validate("MySecurePassword123!")

The package also supports environment-driven configuration. See docs/configuration.md.

Password strength scoring

from password_validator import PasswordStrengthScorer

scorer = PasswordStrengthScorer()
result = scorer.score("MySecurePassword123!")

print(result.score)
print(result.level)
print(result.metrics)
print(result.suggestion_message)

Strength scoring is independent of policy validation. A password can be policy-valid while still receiving a relatively low strength score, or vice versa.

See docs/strength-analysis.md.

Custom validation rules

Rules implement the Rule interface and return a RuleResult.

from password_validator.rules.base import Rule, RuleResult


class NoUsernameRule(Rule):
    name = "no_username"

    def __init__(self, username: str):
        self.username = username

    def validate(self, password: str) -> RuleResult:
        if self.username.lower() in password.lower():
            return self._failed(
                message="Password must not contain the username",
                code="USERNAME_IN_PASSWORD",
            )

        return self._passed(message="Password does not contain the username")

You can pass custom rules directly to PasswordValidator:

validator = PasswordValidator(rules=[NoUsernameRule("shuvo")])
result = validator.validate("MySecurePassword123!")

See docs/rules.md and docs/plugins.md.

Documentation

Project layout

password-validator/
├── config/
│   └── .env.example
├── docs/
├── examples/
├── src/
│   ├── password_validator/
│   │   ├── config/
│   │   ├── engine/
│   │   ├── loaders/
│   │   ├── rules/
│   │   ├── strength/
│   │   ├── constants.py
│   │   ├── enums.py
│   │   ├── exceptions.py
│   │   ├── models.py
│   │   └── version.py
│   └── plugins/
├── tests/
├── pyproject.toml
├── requirements-dev.txt
└── README.md

Important security note

This library validates and analyzes passwords; it is not a password storage system. Never store plaintext passwords or log them. Application code should hash passwords using an appropriate password-hashing mechanism and should avoid placing credentials in exception messages, telemetry, traces, or request logs.

License

MIT. See LICENSE.

Release files for password-validator-s 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for password-validator-s 1.0.2
File Size Uploaded
password_validator_s-1.0.2.tar.gz 30.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for password-validator-s 1.0.2
File Interpreter ABI Platform
password_validator_s-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 71.8 kB

Release files / password_validator_s-1.0.2.tar.gz

Download URL password_validator_s-1.0.2.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ef304aca60c14200c24c481118a78e8b151771a7edcc2328da8c8271e21b6a67
BLAKE2b-256 checksum
How to use checksums
5651247bd281a3a8da77d817cd4f7cce5206fad1631046422995601d015b5f17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / password_validator_s-1.0.2-py3-none-any.whl

Download URL password_validator_s-1.0.2-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
245d5ab7c104ca4c659ea0ed681e4b6d2f1c63e1fdef911562e3d4e5cd042fd2
BLAKE2b-256 checksum
How to use checksums
f471a71d183ff1722b842ae3ff9e4adb92663e0d0a48e3676c1704e6769785ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page