PHPackages                             arxeiss/passwordrule - 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. arxeiss/passwordrule

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

arxeiss/passwordrule
====================

Password rule for Laravel framework

v1.0.4(4y ago)2509WTFPLPHPPHP ^7.0 || ^8.0

Since Aug 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/arxeiss/PasswordRule)[ Packagist](https://packagist.org/packages/arxeiss/passwordrule)[ Docs](https://github.com/arxeiss/PasswordRule)[ RSS](/packages/arxeiss-passwordrule/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (7)Used By (0)

Password validation from Laravel 8.39+
--------------------------------------

[](#password-validation-from-laravel-839)

> **Deprecation:** This tool is deprecated, since Password validation was added into Laravel core in version 8.39. Read more in [Laravel News](https://laravel-news.com/password-validation-rule-object-in-laravel-8) and in [Laravel documentation](https://laravel.com/docs/validation#validating-passwords)

Password Rule for Laravel 5.5+
==============================

[](#password-rule-for-laravel-55)

Package contains `PasswordRule` class for validation password fields with Laravel validator. Nowadays passwords containing numbers, lower and upper case characters (and symbols) are not enough. But it is still better than simple minimum length rule.

Custom Rule created with `Illuminate\Contracts\Validation\Rule` interface was introduced in Laravel 5.5. But you can simply copy logic and use in earlier Laravel version too.

**IMPORTANT NOTE** - Don't miss [Add to predefined Laravel Auth controllers](#add-to-predefined-Laravel-auth-controllers) section, as in original Controllers must be rules changed as well.

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#instalation)
- [Configuration](#configuration)
- [What PasswordRule can do](#what-passwordrule-can-do)
    - [Message format](#message-format)
- [Usage](#usage)
    - [Overriding global settings](#overriding-global-settings)
    - [Add to predefined Laravel Auth controllers](#add-to-predefined-Laravel-auth-controllers)
- [Changelog](#changelog)

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

[](#installation)

Installing via composer is suggested:

```
composer require arxeiss/passwordrule
```

No more steps are needed, as Laravel 5.5+ provides [automatic package discovery](https://laravel.com/docs/5.5/packages).

Configuration
-------------

[](#configuration)

By default, package contains *English* and *Czech* translations and default config is shown below. Do not change config file or translations in `vendor` folder. Run command

```
php artisan vendor:publish --provider="PasswordRule\PasswordRuleServiceProvider"
```

to publish config file `config/passwordrule.php` and translation files into `resources/lang/vendor/passwordrule/`.

What PasswordRule can do
------------------------

[](#what-passwordrule-can-do)

PasswordRule can be used in Laravel to validate password input with four optional rules.

- **Minimum length** - mandatory rule, which test minimum length of password
- **Camel case** - optional rule. Password is tested if contains lower and upper case character
- **Numbers** - optional rule to test, if password contains number
- **Special characters** - optional rule to test, if password contains at least 1 special character from the list of characters

All settings can be set via global config file as well as in constructor for each instance.

### Message format

[](#message-format)

PasswordRule returns always single message, which is built according to settings. There is basic phrase, which is used always. According to settings above are then added more or less phrases. In language file are specified two join phrases. `join_comma` is used to join all phrases except the last one. Before the last one is inserted `join_and`.

Result message can looks like this:

- Password must contains at least 6 characters
- Password must contains at least 8 characters `and` number
- Password must contains at least 6 characters`,` lower and upper case character `and` number
- Password must contains at least 7 characters`,` lower and upper case character`,` number `and` at least 1 special symbol from @#%

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

**Form Request validation**:

```
/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        'password' => ['required', new PasswordRule\PasswordRule, 'confirmed'],
    ];
}
```

**Request validation**:

```
public function store(Request $request)
{
    $request->validate([
        'password' => ['required', new PasswordRule\PasswordRule, 'confirmed'],
    ]);
}
```

### Overriding global settings

[](#overriding-global-settings)

PasswordRule constructor accepts 4 parameters, which can override global settings `new PasswordRule($minLength, $camelCase, $numbers, $specialChars)`. Pass `null` to load specific setting from global config.

```
return [
    // Password must be at least 8 characters long and must contains "_"
    'password' => ['required', new PasswordRule\PasswordRule(8, false, false, "_"), 'confirmed'],
];
```

### Add to predefined Laravel Auth controllers

[](#add-to-predefined-laravel-auth-controllers)

Laravel in his starter package [laravel/laravel](https://github.com/laravel/laravel) provides basic Auth controllers. Important now are **RegisterController** and **ResetPasswordController**, because in both controllers are original password rules.

In RegisterController are rules directly written, it is easy to change. But in ResetPasswordController must be overridden method `rules()` as shown in code below.

```
/**
 * Get the password reset validation rules.
 *
 * @return array
 */
protected function rules()
{
    $rules = parent::rules();
    $rules['password'] = ["required", new PasswordRule, "confirmed"];
    return $rules;
}
```

Changelog
---------

[](#changelog)

### \[1.0\] - 14.8.2018

[](#10---1482018)

- First public release

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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

Every ~257 days

Recently: every ~312 days

Total

6

Last Release

1538d ago

PHP version history (2 changes)v1.0PHP &gt;=7.0.0

v1.0.3PHP ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1347794365895adc762fab67e3e8bd39460ab7be355626bd666ec2c28e53dd49?d=identicon)[arxeiss](/maintainers/arxeiss)

---

Top Contributors

[![arxeiss](https://avatars.githubusercontent.com/u/5103109?v=4)](https://github.com/arxeiss "arxeiss (9 commits)")

---

Tags

laravelpasswordsecurityvalidationlaravelvalidationpassword

### Embed Badge

![Health badge](/badges/arxeiss-passwordrule/health.svg)

```
[![Health](https://phpackages.com/badges/arxeiss-passwordrule/health.svg)](https://phpackages.com/packages/arxeiss-passwordrule)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M106](/packages/propaganistas-laravel-phone)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[schuppo/password-strength

This package provides a validator for ensuring strong passwords in Laravel 4 applications.

1432.7M1](/packages/schuppo-password-strength)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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