swatty007/laravel-context-prohibited-rule

Simple validation rule to disallow application related words within passwords.

2.0.0 2023-09-26 16:03 UTC

This package is auto-updated.

Last update: 2024-10-26 19:32:38 UTC


README

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 🧐

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.