PHPackages                             actengage/sanitize - 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. actengage/sanitize

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

actengage/sanitize
==================

A collection of common sanitizer functions.

v3.0.0(2mo ago)12.1k↓50%MITPHPPHP ^8.2CI passing

Since Sep 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ActiveEngagement/sanitize)[ Packagist](https://packagist.org/packages/actengage/sanitize)[ RSS](/packages/actengage-sanitize/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (16)Used By (0)

Sanitize
========

[](#sanitize)

A collection of classes used to sanitize common inputs like email addresses, phone numbers, and zip codes.

Installation
------------

[](#installation)

```
composer require actengage/sanitize
```

Basic Usage
-----------

[](#basic-usage)

```
use Actengage\Sanitize\Facades\Sanitize;

Sanitize::email(' JOHN.doe @gmail.com '); // johndoe@gmail.com
Sanitize::phone('(888) 123-1234'); // 8881231234
Sanitize::zip('12345'); // 12345
```

Attribute Casts
---------------

[](#attribute-casts)

You can cast Eloquent attributes as sanitized values.

```
use Actengage\Sanitize\Casts\Email;
use Actengage\Sanitize\Casts\Phone;
use Actengage\Sanitize\Casts\Zip;

class User extends Model
{
    protected $guarded = [];

    protected $casts = [
        'email' => Email::class,
        'phone' => Phone::class,
        'zip' => Zip::class,
    ];
}

$user = User::create([
    'email' => ' john.doe@gmail.com ',
    'phone' => '1-800-567-1234',
    'zip' => '1234',
]);

$user->email; // johndoe@gmail.com
$user->phone; // 8005671234
$user->zip;   // 01234
```

Validation Rules
----------------

[](#validation-rules)

Validation rules are included for each sanitizer.

```
use Actengage\Sanitize\Rules\Email;
use Actengage\Sanitize\Rules\Phone;
use Actengage\Sanitize\Rules\Zip;

$request->validate([
    'email' => ['required', new Email],
    'phone' => ['required', new Phone],
    'zip' => ['required', new Zip],
]);
```

Middleware
----------

[](#middleware)

The `SanitizeInputs` middleware automatically sanitizes matching request fields.

```
use Actengage\Sanitize\Http\Middleware\SanitizeInputs;

Route::middleware(SanitizeInputs::class)->group(function () {
    // Request inputs for email, phone, and zip are sanitized automatically
});
```

Custom Sanitizer Macros
-----------------------

[](#custom-sanitizer-macros)

You can add additional sanitizer functions using macros.

```
use Actengage\Sanitize\Facades\Sanitize;

Sanitize::macro('number', function (?string $value) {
    return is_numeric($value) ? $value : null;
});

Sanitize::number('123'); // "123"
Sanitize::number('abc'); // null
```

Publishing a New Release
------------------------

[](#publishing-a-new-release)

This package uses [changesets](https://github.com/changesets/changesets) for automated versioning and releases.

1. Create a branch and make your changes
2. Add a changeset describing the change: ```
    pnpm changeset

    ```

    Select the bump level (patch, minor, or major) and write a summary. See the [changeset skill](.claude/skills/changeset.md) for semver rules specific to this package.
3. Open a PR — CI runs Pint, PHPStan, Rector, and Pest
4. Merge the PR — the release workflow creates a "Version Packages" PR that bumps the version in `package.json` and updates `CHANGELOG.md`
5. Review and merge the "Version Packages" PR — a git tag and GitHub Release are created automatically

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 70% 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 ~107 days

Recently: every ~153 days

Total

13

Last Release

62d ago

Major Versions

v1.1.2 → v2.0.02024-07-11

v2.2.0 → v3.0.02026-03-17

PHP version history (3 changes)v1.0.0-beta.1PHP ^8.0

v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3751e573441701b44fab996c721a3249349c97f023d99986c2f6d646947727e5?d=identicon)[actengage](/maintainers/actengage)

---

Top Contributors

[![actengage](https://avatars.githubusercontent.com/u/33735047?v=4)](https://github.com/actengage "actengage (7 commits)")[![mitchellsolomon](https://avatars.githubusercontent.com/u/39250034?v=4)](https://github.com/mitchellsolomon "mitchellsolomon (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

validationzipphonesanitizeemails

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/actengage-sanitize/health.svg)

```
[![Health](https://phpackages.com/badges/actengage-sanitize/health.svg)](https://phpackages.com/packages/actengage-sanitize)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)[orkhanahmadov/laravel-zip-validator

Laravel ZIP file content validator

12424.9k](/packages/orkhanahmadov-laravel-zip-validator)[dniccum/phone-number

A Laravel Nova phone number field with input masking and validation support.

71432.7k](/packages/dniccum-phone-number)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)[carsdotcom/laravel-json-schema

Json Schema validation for Laravel projects

1036.7k3](/packages/carsdotcom-laravel-json-schema)

PHPackages © 2026

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