PHPackages                             chubbyphp/chubbyphp-parsing - 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. chubbyphp/chubbyphp-parsing

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

chubbyphp/chubbyphp-parsing
===========================

Allows parsing data of various structures, meaning the population and validation of data into a defined structure. For example, converting an API request into a Data Transfer Object (DTO).

2.5.2(1mo ago)2890.0k—10%1[1 PRs](https://github.com/chubbyphp/chubbyphp-parsing/pulls)2MITPHPPHP ^8.3CI failing

Since Feb 10Pushed 2mo ago1 watchersCompare

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

READMEChangelogDependencies (14)Versions (25)Used By (2)

chubbyphp-parsing
=================

[](#chubbyphp-parsing)

[![CI](https://github.com/chubbyphp/chubbyphp-parsing/actions/workflows/ci.yml/badge.svg)](https://github.com/chubbyphp/chubbyphp-parsing/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/d21dd0d67113f9194ebf24836c2ea3d051d46683018e209fd7db3448a8986e13/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6368756262797068702f6368756262797068702d70617273696e672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/chubbyphp/chubbyphp-parsing?branch=master)[![Mutation testing badge](https://camo.githubusercontent.com/e7b3ddec3dac27e3322a331c24ea02c88fb90e364d58ce3c7a69a335cdc2038f/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532466368756262797068702532466368756262797068702d70617273696e672532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/chubbyphp-parsing/master)[![Latest Stable Version](https://camo.githubusercontent.com/a6e480e0f6ad551c06debf69a791d79a48020ed85a5b62908c477f9395eb2b65/68747470733a2f2f706f7365722e707567782e6f72672f6368756262797068702f6368756262797068702d70617273696e672f76)](https://packagist.org/packages/chubbyphp/chubbyphp-parsing)[![Total Downloads](https://camo.githubusercontent.com/a61a0e9f880907b4b5acaf1e449549cc7c00326e8547b2dfbf49a23f919e96b8/68747470733a2f2f706f7365722e707567782e6f72672f6368756262797068702f6368756262797068702d70617273696e672f646f776e6c6f616473)](https://packagist.org/packages/chubbyphp/chubbyphp-parsing)[![Monthly Downloads](https://camo.githubusercontent.com/9f047b3fa27c2c2297ffa444ce4131e2c761c587a357d052a551237308f5237d/68747470733a2f2f706f7365722e707567782e6f72672f6368756262797068702f6368756262797068702d70617273696e672f642f6d6f6e74686c79)](https://packagist.org/packages/chubbyphp/chubbyphp-parsing)

[![bugs](https://camo.githubusercontent.com/cbf7afdbce28797c2800936be5b3535ebe2c913c3fd934da84714cbc3de991c2/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d62756773)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![code_smells](https://camo.githubusercontent.com/4ce01525298871b4c6cd6dc9be332c0acd75fea6b1d236359a0fc2e5c6f470fd/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d636f64655f736d656c6c73)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![coverage](https://camo.githubusercontent.com/af6f420018b73e8f749cef79613508171d2c906b32d6e2d9b05614039d2b2595/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d636f766572616765)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![duplicated_lines_density](https://camo.githubusercontent.com/b73293b9f76866b43be49e9ea537039227329621a2d00b7b49d512ee37027a15/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d6475706c6963617465645f6c696e65735f64656e73697479)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![ncloc](https://camo.githubusercontent.com/171d783638e2a05b75b34e1959b78c7cc4d21747db9da5d4cad4ddecb4a492ea/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d6e636c6f63)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![sqale_rating](https://camo.githubusercontent.com/301e0ded554f765d8a27a761314c0bac9f19a8bfe507da6a529a4ce24ea764bf/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![alert_status](https://camo.githubusercontent.com/a219d76d456eea01b67b51164449daff4541feac873e4f7f0d45c6a68a3550f7/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![reliability_rating](https://camo.githubusercontent.com/e42494518e6477f0660ec3c417ba61e102fe59f7306d074324b5f8009d162395/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![security_rating](https://camo.githubusercontent.com/b98d12fc412274f7cc4df0ee0eecc084d082e3d9d845cf75d1d89aad76e4ab87/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![sqale_index](https://camo.githubusercontent.com/1dcfb423a3655acf321d0e9aeb2c0c9e89a7ba2b41ee67186f249dab3a1a2da4/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)[![vulnerabilities](https://camo.githubusercontent.com/c6b14464110a597e5c9c08d072a8eb41b20ef4b9e548495081fbbf8cc1493bd3/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6368756262797068705f6368756262797068702d70617273696e67266d65747269633d76756c6e65726162696c6974696573)](https://sonarcloud.io/dashboard?id=chubbyphp_chubbyphp-parsing)

Description
-----------

[](#description)

Allows parsing data of various structures, meaning the population and validation of data into a defined structure. For example, converting an API request into a Data Transfer Object (DTO).

Heavily inspired by the well-known TypeScript library [zod](https://github.com/colinhacks/zod).

Requirements
------------

[](#requirements)

- php: ^8.3

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

[](#installation)

Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-parsing](https://packagist.org/packages/chubbyphp/chubbyphp-parsing).

```
composer require chubbyphp/chubbyphp-parsing "^2.5"
```

Quick Start
-----------

[](#quick-start)

```
use Chubbyphp\Parsing\Parser;

$p = new Parser();

// Define a schema
$userSchema = $p->object([
    'name' => $p->string()->minLength(1)->maxLength(100),
    'email' => $p->string()->email(),
    'age' => $p->int()->minimum(0)->maximum(150),
]);

// Parse and validate data
$user = $userSchema->parse([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'age' => 30,
]);
```

Schema Types
------------

[](#schema-types)

### Primitives

[](#primitives)

SchemaDescriptionDocumentation`string()`String validation with length, pattern, format checks[StringSchema](doc/Schema/StringSchema.md)`int()`Integer validation with numeric constraints[IntSchema](doc/Schema/IntSchema.md)`float()`Float validation with numeric constraints[FloatSchema](doc/Schema/FloatSchema.md)`bool()`Boolean validation[BoolSchema](doc/Schema/BoolSchema.md)`dateTime()`DateTime validation with range constraints[DateTimeSchema](doc/Schema/DateTimeSchema.md)### Complex Types

[](#complex-types)

SchemaDescriptionDocumentation`array()`Arrays with item validation[ArraySchema](doc/Schema/ArraySchema.md)`assoc()`Associative arrays with field schemas[AssocSchema](doc/Schema/AssocSchema.md)`object()`Objects/DTOs with field schemas[ObjectSchema](doc/Schema/ObjectSchema.md)`tuple()`Fixed-length arrays with positional types[TupleSchema](doc/Schema/TupleSchema.md)`record()`Key-value maps with uniform value types[RecordSchema](doc/Schema/RecordSchema.md)### Union Types

[](#union-types)

SchemaDescriptionDocumentation`union()`Value matches one of several schemas[UnionSchema](doc/Schema/UnionSchema.md)`discriminatedUnion()`Tagged unions with a discriminator field[DiscriminatedUnionSchema](doc/Schema/DiscriminatedUnionSchema.md)### Special Types

[](#special-types)

SchemaDescriptionDocumentation`const()`Exact value matching[ConstSchema](doc/Schema/ConstSchema.md)`backedEnum()`PHP BackedEnum validation[BackedEnumSchema](doc/Schema/BackedEnumSchema.md)`lazy()`Recursive/self-referencing schemas[LazySchema](doc/Schema/LazySchema.md)`respectValidation()`Integration with Respect/Validation[RespectValidationSchema](doc/Schema/RespectValidationSchema.md)Common Schema Methods
---------------------

[](#common-schema-methods)

All schemas support these methods:

```
$schema->nullable();              // Allow null values
$schema->default($value);         // Provide default when input is null
$schema->preParse($fn);           // Transform input before parsing
$schema->postParse($fn);          // Transform output after parsing
$schema->parse($input);           // Parse and throw on error
$schema->safeParse($input);       // Parse and return Result object
$schema->catch($fn);              // Handle errors and provide fallback
```

Error Handling
--------------

[](#error-handling)

```
use Chubbyphp\Parsing\ErrorsException;

try {
    $schema->parse($input);
} catch (ErrorsException $e) {
    $e->errors->jsonSerialize();                   // JSON structure
    $e->errors->toApiProblemInvalidParameters();   // RFC 7807 format
    $e->errors->toTree();                          // Hierarchical structure
}
```

See [Error Handling](doc/ErrorHandling.md) for detailed documentation.

Documentation
-------------

[](#documentation)

- **Schema Types**: [doc/Schema/](doc/Schema/)
- **Error Handling**: [doc/ErrorHandling.md](doc/ErrorHandling.md)
- **Migration**: [1.x to 2.x](doc/Migration/1.x-2.x.md)

Copyright
---------

[](#copyright)

2026 Dominik Zogg

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance86

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Recently: every ~12 days

Total

20

Last Release

57d ago

Major Versions

1.4.1 → 2.0.02025-10-12

PHP version history (3 changes)1.0.0PHP ^8.1

1.3.0PHP ^8.2

2.1.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/55048de83ca5e5d8c67164a19c78edcaad413b0c1a4ae10d92edf8d77bedd90f?d=identicon)[dominikzogg](/maintainers/dominikzogg)

---

Top Contributors

[![dominikzogg](https://avatars.githubusercontent.com/u/1011217?v=4)](https://github.com/dominikzogg "dominikzogg (183 commits)")

---

Tags

chubbyphpdtoparsingpopulationvalibotvalidationyupzodvalidationparsingdtozodchubbyphppopulation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chubbyphp-chubbyphp-parsing/health.svg)

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

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

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

3.0k35.7M107](/packages/propaganistas-laravel-phone)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8912.9M47](/packages/giggsey-libphonenumber-for-php-lite)[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1062.8k1](/packages/yorcreative-laravel-argonaut-dto)

PHPackages © 2026

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