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
================

v2.1.0(1mo ago)5561[1 PRs](https://github.com/Nebalus/Sanitizr/pulls)MITPHPPHP &gt;=8.3CI passing

Since Jul 25Pushed 1mo agoCompare

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

READMEChangelog (9)Dependencies (9)Versions (15)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

48

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~36 days

Recently: every ~15 days

Total

9

Last Release

51d ago

Major Versions

v1.2.0 → v2.0.02026-03-15

v1.3.0 → v2.1.02026-05-12

### 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 (182 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

jsonphpsanitizationschemavalidationzod

###  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

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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