Skip to content
An easy to use request sanitizer that allows you to sanitize your form data before validating it.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Use Arr::set instead of deprecated helpers May 4, 2019
tests added several sanitizers and tests for the individual sanitizers Apr 23, 2019
.gitignore initial commit Aug 17, 2018
.travis.yml Tests on php 7.3 Apr 24, 2019 initial commit Aug 17, 2018
composer.json Update phpunit/phpunit requirement from ^6.2|^7.0 to ^6.2|^7.0|^8.0 May 27, 2019
phpunit.xml.dist initial commit Aug 17, 2018

Laravel Request Sanitizer

Build Status Total Downloads

The arondeparon/laravel-request-sanitizer package provides a fluent interface to sanitize form requests before validating them.

Why should I use this package?

Often, validating your request is not enough. The request sanitizer allows you to easily manipulate your form data before passing it to the validator. You can start using it in a matter of minutes and it is fully compatible with Laravel's FormRequest object.

How to use

Syntax is similar to the way rules are added to a Form Request.

class StoreCustomerInformationRequest extends FormRequest
     use SanitizesInputs;
     protected $sanitizers = [
        'lastname' => [
        'mobile_phone' => [


composer require arondeparon/laravel-request-sanitizer


  • Add the SanitizesInputs trait to your form request.
  • Write your own sanitizers or use one of the supplied sanitizers and add them to the $sanitizers property of your form request.
  • Your request data will now be sanitized before being validated.

Predefined Sanitizers

  • Trim - simple PHP trim() implementation
  • TrimDuplicateSpaces replaces duplicate spaces with a single space.
  • RemoveNonNumeric - removes any non numeric character
  • Capitalize - capitalizes the first character of a string
  • Uppercase - converts a string to uppercase
  • Lowercase - converts a string to lowercasse
  • Contributions are appreciated!

Writing your own Sanitizer

Writing your own sanitizer can be done by implementing the Sanitizer interface, which requires only one method.

interface Sanitizer
     public function sanitize($input);


$ composer test



The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.