This is a small package to help you easily validate usernames against a list of
commonly banned usernames, for example: json
, admin
, security
, etc. You
can also add your own custom allowed and disallowed usernames.
You can see the full list of disallowed usernames in the config file, or the source repo from which the list came from.
You can install the package via composer:
composer require wyattcast44/laravel-safe-username
use Wyattcast44\SafeUsername\Rules\AllowedUsername;
Validator::make($request, [
'username' => ['required', 'string', new AllowedUsername],
]);
You can publish the configuration file with the command below. This will publish a config file called safe-username.php
.
php artisan vendor:publish --provider="Wyattcast44\SafeUsername\SafeUsernameServiceProvider"
Once you have published the config file you can add additional usernames to disallow, or add usernames that should pass the validation.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.