https://github.com/divineomega/laravel-offensive-validation-rule
🤬🤠Laravel validation rule that checks if a string is offensive.
https://github.com/divineomega/laravel-offensive-validation-rule
laravel laravel-5-package laravel-validation offensive offensive-language php
Last synced: about 1 month ago
JSON representation
🤬🤠Laravel validation rule that checks if a string is offensive.
- Host: GitHub
- URL: https://github.com/divineomega/laravel-offensive-validation-rule
- Owner: DivineOmega
- License: lgpl-3.0
- Created: 2018-05-07T12:56:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-21T20:48:35.000Z (about 5 years ago)
- Last Synced: 2025-02-28T06:04:32.180Z (about 2 months ago)
- Topics: laravel, laravel-5-package, laravel-validation, offensive, offensive-language, php
- Language: PHP
- Size: 45.9 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🤬🤠Laravel Offensive Validation Rule
This package provides a Laravel validation rule that checks if a string is offensive. It can be useful
to check user supplied data that may be publicly displayed, such as usernames or comments.
## Installation
To install, just run the following Composer command.
```
composer require divineomega/laravel-offensive-validation-rule
```Please note that this package requires Laravel 5.5 or above.
## Usage
The following code snippet shows an example of how to use the offensive validation rule.
```php
use DivineOmega\LaravelOffensiveValidationRule\Offensive;$request->validate([
'username' => ['required', new Offensive],
]);
```### Custom word lists
If the defaults are too strict (or not strict enough), you can optionally specify a custom list
of offensive words and custom whitelist. Below is an example of using a custom blacklist and whitelist.```php
use DivineOmega\LaravelOffensiveValidationRule\Offensive;
use DivineOmega\IsOffensive\OffensiveChecker;$blacklist = ['moist', 'stinky', 'poo'];
$whitelist = ['poop'];$request->validate([
'username' => ['required', new Offensive(new OffensiveChecker($blacklist, $whitelist))],
]);
```