swatty007/laravel-context-prohibited-rule

Simple validation rule to disallow application related words within passwords.
1,886
Install
composer require swatty007/laravel-context-prohibited-rule
Latest Version:4.0.0
PHP:^8.2
License:MIT
Last Updated:Aug 18, 2026
Links: GitHub  ·  Packagist
Maintainer: swatty

Context prohibited validation rule for Laravel

Package Banner

Latest Version on Packagist License: MIT Build Status Code Style Quality Score Total Downloads

Simple validation rule to disallow application related words within passwords. Its checks that the entered data does not contain your application name, or url to prevent users weakening their passwords.

Installation

You can install the package via composer:

composer require swatty007/laravel-context-prohibited-rule

Laravel's service provider discovery will automatically configure our service provider for you.

Add the validation message to your validation lang file:

For each language add a validation message to validation.php like below

'context_prohibited' => 'Your :attribute shall not contain any of the following words: :prohibited',

Configuration

After installing the package you can publish the configuration file via:

php artisan vendor:publish --provider="Swatty007\LaravelContextProhibitedRule\ContextProhibitedServiceProvider"

It contains some optional configuration parameters and is fully documented.

Usage

After installation, the php context_prohibited validator will be available for use directly in your validation rules.

'password' => 'context_prohibited'
// or preferred
'password' => ['required', new ContextProhibited],

For error message to work correctly you should prefer to initialize the rule object!

Within the context of a registration form, it would look like this:

return Validator::make($data, [
    'name' => 'required|string|max:255',
    'email' => 'required|string|email|max:255|unique:users',
    'password' => 'required|string|min:8|context_prohibited|confirmed',
]);

Testing

Yes we do!

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

TODO

  • Currently None

Pull Requests are welcome :monocle_face:

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email info@martin-niehoff.de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

timacdonald/rule-builder

A fluent rule builder for Laravel validation rule generation.

8,164 101
fadion/rule

An expressive validation rule builder for Laravel.

1,145 13
schuppo/password-strength

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

2,764,593 143
jenky/smart-rule

Laravel smart validation rules

109 0
codezero/laravel-unique-translation

Check if a translated value in a JSON column is unique in the database.

1,101,358 188