PHPackages                             jijoel/sanitization-filters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jijoel/sanitization-filters

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

jijoel/sanitization-filters
===========================

Data sanitizer filters for use with waavi/sanitizer

v0.3.1(7y ago)21.9kMITPHP

Since Jun 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jijoel/sanitization-filters)[ Packagist](https://packagist.org/packages/jijoel/sanitization-filters)[ RSS](/packages/jijoel-sanitization-filters/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (8)Used By (0)

Sanitization Filters
====================

[](#sanitization-filters)

This is a collection of custom sanitization filters to be used in conjunction with [Waavi/Sanitizer](https://github.com/Waavi/Sanitizer).

Example
-------

[](#example)

Given a data array with the following format:

```
$data = [
    'first_name'    =>  'john',
    'last_name'     =>  'DOE',
    'email'         =>  '  JOHn@DoE.com',
    'birthdate'     =>  '06/25/1980',
    'jsonVar'       =>  '{"name":"value"}',
];
```

We can easily format it using our Sanitizer and the some of Sanitizer's default filters:

```
use \Waavi\Sanitizer\Sanitizer;

$filters = [
    'first_name'    =>  'trim|escape|capitalize',
    'last_name'     =>  'trim|escape|capitalize',
    'email'         =>  'trim|escape|lowercase',
    'birthdate'     =>  'trim|format_date:m/d/Y, Y-m-d',
    'jsonVar'       =>  'cast:array',
];

$sanitizer  = new Sanitizer($data, $filters);
var_dump($sanitizer->sanitize());
```

Which will yield:

```
[
    'first_name'    =>  'John',
    'last_name'     =>  'Doe',
    'email'         =>  'john@doe.com',
    'birthdate'     =>  '1980-06-25',
    'jsonVar'       =>  '["name" => "value"]',
];
```

Available Filters
-----------------

[](#available-filters)

FilterDescriptionalphaAlphabetic characters only (a-z)addressStreet AddressescountryCapitalize country name (or abbreviation)dateDate valueslimitTrims the input at a given limitlowerConverts the given string to all lowercasemoneySets the given string to two decimal placesnameConverts the string to a Proper Name (eg, Foo O'Bar)numberReturns the numeric part of the given stringphoneA US Telephone numberproperConverts the given string to Proper (Title) CasestateCapitalize state name (or abbreviation)stripRemove some problematic characters from input. These include: `' ? ; -- / &`title-caseConverts the given string to Title CaseupperConverts the given string to all uppercasezipConverts to a US zip codeInstallation
------------

[](#installation)

Install with composer:

```
composer require jijoel/sanitization-filters

```

We also include a Laravel service provider, via auto-discovery. For versions of Laravel prior to 5.5, add it to your providers array in `config/app.php`:

```
'providers' => [
    ...
    Waavi\Sanitizer\Laravel\SanitizerServiceProvider::class,
    Jijoel\Sanitizer\Laravel\SanitizerServiceProvider::class,
];
```

Usage
-----

[](#usage)

It's recommended to sanitize your data in a FormRequest object before applying rules. The Waavi/Sanitizer package includes a SanitizesInput trait, which handles this automatically for you.

```
use Waavi\Sanitizer\Laravel\SanitizesInput;

class MyFormRequest extends FormRequest
{
    use SanitizesInput;

    public function filters()
    {
        return [
            'name' => 'trim|escape|name',
            'email' => 'trim|escape|lower',
        ];
    }

    public function rules()
    {
        return [
            'name' => 'required',
            'email' => 'required|email',
        ];
    }
```

Please note that at this time, in order for this to work, the Sanitizer facade must exist.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~117 days

Total

7

Last Release

2635d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84b106d0a79e2e500261063a0f7718d6be3a5783bc5a019d129b9233eb48d2fb?d=identicon)[jijoel](/maintainers/jijoel)

---

Top Contributors

[![jijoel](https://avatars.githubusercontent.com/u/3487641?v=4)](https://github.com/jijoel "jijoel (18 commits)")

---

Tags

laravelinputsanitationinput filterinput sanitationinput sanitizertransform input

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jijoel-sanitization-filters/health.svg)

```
[![Health](https://phpackages.com/badges/jijoel-sanitization-filters/health.svg)](https://phpackages.com/packages/jijoel-sanitization-filters)
```

###  Alternatives

[elegantweb/sanitizer

Sanitization library for PHP and the Laravel framework.

115950.4k2](/packages/elegantweb-sanitizer)[waavi/sanitizer

Data sanitizer and Laravel 7 form requests with input sanitation.

433589.2k5](/packages/waavi-sanitizer)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[laravel-validation-rules/phone

Validate that a phone number is in the correct format

69355.5k](/packages/laravel-validation-rules-phone)[timacdonald/rule-builder

A fluent rule builder for Laravel validation rule generation.

1027.7k](/packages/timacdonald-rule-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
