Go to file
Arandi López 97cb0a5da0 add it locale 2017-06-04 17:06:02 -05:00
src add it locale 2017-06-04 17:06:02 -05:00
tests Identation... If your are using a non supported locale, it wont try to loaded 2017-05-29 13:44:25 -05:00
.gitignore initial commit 2016-07-18 18:28:52 -05:00
.travis.yml travis php versions ^ 5.6 2017-02-21 13:42:58 -06:00
LICENSE add license 2017-05-29 14:44:47 -05:00
README.md readme again 2017-05-29 14:47:48 -05:00
composer.json Support Auto-discovery 2017-06-04 17:03:20 -05:00
composer.lock Support Auto-discovery 2017-06-04 17:03:20 -05:00
phpunit.xml I think it's done 2016-07-18 20:20:02 -05:00

README.md

Laravel Profanity Validator

Latest Stable Version Total Downloads License Daily Downloads composer.lock

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

Instalation

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

How to use

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

    // ...
  }
}

By default the validator will load the default locale in your config/app.php file configuration which by default 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

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

License

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