PHPackages                             nebalus/sanitizr - 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. nebalus/sanitizr

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

nebalus/sanitizr
================

v1.3.0(2mo ago)4414MITPHPPHP &gt;=8.3CI passing

Since Jul 25Pushed 3mo agoCompare

[ Source](https://github.com/Nebalus/Sanitizr)[ Packagist](https://packagist.org/packages/nebalus/sanitizr)[ RSS](/packages/nebalus-sanitizr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (11)Used By (0)

 [![Sanitizr](imgs/logo.jpg?raw=true)](https://github.com/Nebalus/Sanitizr)

===============================================================================

[](#------)

#### A [Zod](https://zod.dev) inspired Validation and Filter Framework written in PHP.

[](#a-zod-inspired-validation-and-filter-framework-written-in-php)

 [Key Features](#key-features) • [How To Use](#how-to-use) • [Credits](#credits) • [Related](#related) • [License](#license)

Key Features
------------

[](#key-features)

- **Zod-inspired API:** Familiar, fluent interface for schema definitions, validation, and filtering.
- **Composable schemas:** Build complex validators from primitives and custom rules.
- **Extensible:** Easily extend with your own filters and validation logic.
- **Zero dependencies:** Lightweight and easy to integrate.

How To Use
----------

[](#how-to-use)

### Installation

[](#installation)

```
composer require nebalus/sanitizr
```

### Basic Example

[](#basic-example)

```
use Nebalus\Sanitizr\SanitizrStatic as S;

// Define a schema
$userSchema = S::object([
    'name' => S::string()->min(1),
    'email' => S::string()->email(),
    'age' => S::int()->min(0)->optional(),
]);

// Define input
$input = [
    'name' => 'Alex',
    'email' => 'alex@example.com',
];

$result = $userSchema->safeParse($input);

if ($result->isValid()) {
    $user = $result->getValue();
    // Use sanitized data
    echo $user["name"]; // Outputs: Alex
    echo $user["email"]; // Outputs: alex@example.com
} else {
    $errorMessage = $result->getErrorMessage();
    // Handle validation errors
}
```

### Advanced Usage

[](#advanced-usage)

- **Custom filters:**
    Create your own filters and add them to schemas.
- **Nested objects &amp; arrays:**
    Compose validators for deeply nested data.

See the [examples directory](https://github.com/Nebalus/Sanitizr/tree/dev/examples) and [API Reference](https://github.com/Nebalus/Sanitizr/wiki) for more details.

Credits
-------

[](#credits)

- Inspired by [Zod](https://zod.dev) (TypeScript) and the wider PHP validation ecosystem.
- Created and maintained by [Nebalus](https://github.com/Nebalus).

Related
-------

[](#related)

- [Zod (TypeScript)](https://zod.dev)

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](https://github.com/Nebalus/Sanitizr/blob/dev/LICENSE) file for details.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance83

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% 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 ~39 days

Recently: every ~58 days

Total

7

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5dba86b8fcf50104eb6c2bc2c6f6d58f135201aa4f1e4fa06b9ba68c20496f25?d=identicon)[Nebalus](/maintainers/Nebalus)

---

Top Contributors

[![Nebalus](https://avatars.githubusercontent.com/u/56486387?v=4)](https://github.com/Nebalus "Nebalus (179 commits)")[![coderabbitai[bot]](https://avatars.githubusercontent.com/in/347564?v=4)](https://github.com/coderabbitai[bot] "coderabbitai[bot] (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

phpvalidationzod

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nebalus-sanitizr/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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