Squeaky: A Powerful Laravel Validation Rule for Clean Data

Created by Jon Purvis, Squeaky is powered by Profanify, which we recently covered. Based on user feedback, he has extracted a standalone validation rule, making Squeaky a powerful tool right from the start. It also supports multiple locales, not just English.

Install this package using Composer:

composer require jonpurvis/squeaky

 

Example

namespace App\Http\Controllers
 
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use JonPurvis\Squeaky\Rules\Clean;
 
class EventController extends Controller
{
        public function store(Request $request): RedirectResponse
        {
            $request->validate([
                    'name' => ['required', 'string', 'max:255', new Clean],
                    'description' => ['required', 'string', new Clean],
                    'event_date' => 'required|date'
            ]);
 
            // ...
 
            return redirect('/events');
        }
}

 

If your application supports multiple languages, you can pass additional locales to the rule to accommodate them.

use JonPurvis\Squeaky\Rules\Clean;
 
'name' => ['required', 'string', 'max:255', new Clean(['en', 'pt_BR'])],

Learn more about this package and view the source code on GitHub.

Profanify GitHub Repository

Laravel News Article on Profanify

Squeaky GitHub Repository