All Projects → arandilopez → laravel-profane

arandilopez / laravel-profane

Licence: MIT license
Profanity Validator for Laravel

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-profane

Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+303.8%)
Mutual labels:  composer, laravel-package
Base62
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.
Stars: ✭ 16 (-79.75%)
Mutual labels:  composer, laravel-package
video-downloader
Video Downloader for Facebook.
Stars: ✭ 63 (-20.25%)
Mutual labels:  composer, laravel-package
Laravel Server Monitor
Server Monitoring Command for Laravel Applications
Stars: ✭ 424 (+436.71%)
Mutual labels:  composer, laravel-package
Package Skeleton
📦 My base for PHP packages.
Stars: ✭ 6 (-92.41%)
Mutual labels:  composer, laravel-package
Eloquent Tree
Eloquent Tree is a tree model for Laravel Eloquent ORM.
Stars: ✭ 131 (+65.82%)
Mutual labels:  composer, laravel-package
Laravel Stats
📈 Get insights about your Laravel or Lumen Project
Stars: ✭ 1,386 (+1654.43%)
Mutual labels:  composer, laravel-package
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+2700%)
Mutual labels:  composer, laravel-package
forest-laravel
🌱 Laravel Liana for Forest Admin. This repo is no longer maintained. Please use laravel-forestadmin instead: https://github.com/ForestAdmin/laravel-forestadmin
Stars: ✭ 4 (-94.94%)
Mutual labels:  laravel-package
gh-auto-updater
Automatic Updater with GitHub API for WordPress Plugin
Stars: ✭ 42 (-46.84%)
Mutual labels:  composer
routing
Aplus Framework Routing Library
Stars: ✭ 186 (+135.44%)
Mutual labels:  composer
generator-composer
🐘 Yeoman (http://yeoman.io) generator for a PHP Composer project
Stars: ✭ 16 (-79.75%)
Mutual labels:  composer
composer-localdev-plugin
Composer Plugin for local development
Stars: ✭ 31 (-60.76%)
Mutual labels:  composer
tug
Private Composer registry for private PHP packages on AWS Serverless
Stars: ✭ 33 (-58.23%)
Mutual labels:  composer
geoip2-geolite2-composer
This project aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.
Stars: ✭ 15 (-81.01%)
Mutual labels:  composer
composer-file-loader
Tool to load namespaces and classes from composer.json file without composer
Stars: ✭ 64 (-18.99%)
Mutual labels:  composer
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (-22.78%)
Mutual labels:  composer
Minecraft-Skin-Renderer
Minecraft 3D Skin renderer with composer support and flexible rotation configuration
Stars: ✭ 14 (-82.28%)
Mutual labels:  composer
data-import
Laravel Enso XLSX Data Import package, built around the box/spout library, with templating, easy validation and more, for painless imports
Stars: ✭ 19 (-75.95%)
Mutual labels:  laravel-package
sweetalert
Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.
Stars: ✭ 28 (-64.56%)
Mutual labels:  laravel-package

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')
        ]);

        // ...
    }
}

Strict validation

Now you can strictly validate the exact profane word in the content.

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

        // ...
    }
}

This fixes known issues when you get a error in validation for words like class or analysis, as they include ass and anal respectively, but fails the validation for content like sucker69.

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 [email protected]: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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].