PHPackages                             code-pros/password-policy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. code-pros/password-policy

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

code-pros/password-policy
=========================

Create a password policy and validate strings against it

1.0.0(4y ago)02.2k↓33.3%MITPHPPHP ^7.1 || ^8.0

Since Jun 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/code-pros/password-policy)[ Packagist](https://packagist.org/packages/code-pros/password-policy)[ RSS](/packages/code-pros-password-policy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

README
======

[](#readme)

Create a Password Policy and validate passwords against it.

Useful for when a user is creating/updating their password.

Installation
------------

[](#installation)

Use Composer to manage your dependencies:

`composer require code-pros/password-policy`

Example
-------

[](#example)

```
/**
 * Setup a password policy
 * This policy is from OWASP's security cheat sheet.  Look it up for good reading!
 *
 * Must match 3/4 of the following
 * - Lowercase character
 * - Uppercase character
 * - Special character
 * - Digit
 * Must match all of the following
 * - between 10 and 128 characters
 * - no consecutive characters more than twice
 */
$childPolicy = \CodePros\PasswordPolicy\Builder::create()
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Lowercase(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Uppercase(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Digit(1))
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Special(1))
        ->pctRulesMustPass(75)
        ->build();

$policy = \CodePros\PasswordPolicy\Builder::create()
        ->addMustRule(new \CodePros\PasswordPolicy\Rules\Characters\Length(10, 128))
        ->addMustNotRule(new \CodePros\PasswordPolicy\Rules\ConsecutiveCharacters(3))
        ->mustPassPolicy($childPolicy)
        ->build();

/**
 * Validate a password
 */
$valid = $policy->validate('user supplied password');

/**
 * Get back a list of rules and whether the last validation passed each.
 */
$messages = $policy->getDetailedStatus();

```

Development
-----------

[](#development)

### Development Process

[](#development-process)

1. Make your changes.
2. Test with PHPUnit.

### Build Process

[](#build-process)

1. Choose a new version number according to [semver](http://semver.org/).
2. Summarize your changes in CHANGELOG with the new version number.
3. Create a git tag with the version number.
4. Push the changes and tag.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1795d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/488a562660d03dc9fb64e40fffe0c686f91cbd7a2caa80fc5c5faffb7c6297c5?d=identicon)[JohnWE](/maintainers/JohnWE)

---

Top Contributors

[![JohnWE](https://avatars.githubusercontent.com/u/2379622?v=4)](https://github.com/JohnWE "JohnWE (16 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/code-pros-password-policy/health.svg)

```
[![Health](https://phpackages.com/badges/code-pros-password-policy/health.svg)](https://phpackages.com/packages/code-pros-password-policy)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
