arandilopez / laravel-profane by arandilopez

Laravel Profanity Valitador
140,728
87
4
Package Data
Maintainer Username: arandilopez
Maintainer Contact: arandilopez.93@gmail.com (Arandi Lopez)
Package Create Date: 2016-07-19
Package Last Update: 2024-02-15
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:16:30
Package Statistics
Total Downloads: 140,728
Monthly Downloads: 4,738
Daily Downloads: 206
Total Stars: 87
Total Watchers: 4
Total Forks: 33
Total Open Issues: 12

Laravel Profanity Validator

Latest Stable Version Total Downloads License Daily Downloads composer.lock StyleCI

I made this package to perform a validation for swearwords using Laravel validation service.

Installation

Install via composer

composer require arandilopez/laravel-profane

Configuration

Add the ProfaneServiceProvider class in your config/app.php file.

<?php
return [
    // ...

    'providers' => [
        // ...
        LaravelProfane\ProfaneServiceProvider::class,
    ];

    // ...
];

Publish vendor lang files if you need to replace by your own.

php artisan vendor:publish

Usage

This package register a custom validator. You can use in your controller's validate function.

<?php
// ...
class MyController extends Controller
{
    public function store(Request $request)
    {
        $this->validate($request, [
            'username' => 'required|profane'
        ]);

        // ...
    }
}

The validator will load the default locale in your config/app.php file configuration which by is en. If your locale is not supported, please post an issue for this project

If you want to use others dictionaries you can pass them as parameters in the validator.

<?php
// ...
class MyController extends Controller
{
    public function store(Request $request)
    {
        $this->validate($request, [
            'username' => 'required|profane:es,en'
        ]);

        // ...
    }
}

You can also send as parameter a path of a file which is a dictionary in order to replace the default dictionary or add a new non supported locale.

<?php
// ...
class MyController extends Controller
{
    public function store(Request $request)
    {
        $this->validate($request, [
            'username' => 'required|profane:es,en,'.resource_path('lang/fr/dict.php')
        ]);

        // ...
    }
}

Getting Help

If you're stuck getting something to work, or need to report a bug, please post an issue in the Github Issues for this project.

Contributing

If you're interesting in contributing code to this project, clone it by running:

git clone git@github.com:arandilopez/laravel-profane.git

Please read the CONTRIBUTING file.

Pull requests are welcome, but please make sure you provide unit tests to cover your changes. You can help to add and support more locales!

Thanks to @dorianneto for his contributions.

Supported Locales

License

This project is open-sourced software licensed under the MIT license.