swatty007 / laravel-context-prohibited-rule
Simple validation rule to disallow application related words within passwords.
Installs: 1 347
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/support: ^9.0|^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18|^3
- orchestra/testbench: ^v8.0.0
- phpmd/phpmd: @stable
- phpmetrics/phpmetrics: ^2.7
- phpunit/phpunit: ^10
README
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.