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.
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',
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.
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',
]);
Yes we do!
composer test
Please see CHANGELOG for more information what has changed recently.
- Currently None
Pull Requests are welcome 🧐
Please see CONTRIBUTING for details.
If you discover any security related issues, please email info@martin-niehoff.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.