PHPackages                             vod/vod - 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. vod/vod

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

vod/vod
=======

vod, zod style validation for PHP

0.1.0(1y ago)69[5 PRs](https://github.com/vodphp/vod/pulls)MITPHPPHP ^8CI passing

Since Apr 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/vodphp/vod)[ Packagist](https://packagist.org/packages/vod/vod)[ Docs](https://github.com/deanmcpherson/vod)[ GitHub Sponsors](https://github.com/deanmcpherosn)[ RSS](/packages/vod-vod/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (8)Used By (0)

Vod - PHP Validation and Object Definition Library
==================================================

[](#vod---php-validation-and-object-definition-library)

Vod is a powerful PHP library for validating and defining object structures. It provides a fluent API for creating schemas, parsing data, and generating TypeScript definitions and JSON schemas.

[![Latest Version on Packagist](https://camo.githubusercontent.com/314c6fb04918bf0748996abfac79e5a3c469e4c6c6891b3c425dc391d2fdb57d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766f642f766f642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vod/vod)[![GitHub Tests Action Status](https://camo.githubusercontent.com/dcecab3d8600b3124f068212a75b9ec6d5e40d2f4794d8a3f8e9a4ba8669d9a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f642f766f642f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/vodphp/vod/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/60b5a44036d0e7394a06943a2079f18951914362205357f5fc9ad1b0d1484f1f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f642f766f642f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/vodphp/vod/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/14bd7b861056f5e763bd2fa5e7099313f29a625ca9e4acc31210a946e723074d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766f642f766f642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vod/vod)

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

[](#installation)

You can install Vod via Composer:

```
composer require vod/vod
```

Testing
-------

[](#testing)

```
composer test
```

Usage
-----

[](#usage)

### Basic Schema Creation

[](#basic-schema-creation)

To create a schema, use the `v()` function to access the Vod API:

```
use function Vod\Vod\v;
$schema = v()->object([
    'name' => v()->string(),
    'age' => v()->number()->int(),
    'email' => v()->string()->optional(),
]);
```

### Parsing Data

[](#parsing-data)

You can parse data against your schema:

```
$data = ['name' => 'John', 'age' => 30];
$result = $schema->parse($data);
```

### Available Types

[](#available-types)

Vod supports various types:

- `v()->string()`: String type
- `v()->number()`: Number type (can be further specified as `int()` or `float()`)
- `v()->boolean()`: Boolean type
- `v()->array()`: Array type
- `v()->object()`: Object type
- `v()->enum()`: Enum type
- `v()->any()`: Any type
- `v()->date()`: Date type
- `v()->tuple()`: Tuple type
- `v()->union()`: Union type
- `v()->anyOf()`: Alias of Union type
- `v()->intersection()`: Intersection type
- `v()->all()`: Alias of Intersection type

### Optional Fields

[](#optional-fields)

Make fields optional:

```
v()->string()->optional()
```

### Default Values

[](#default-values)

Set default values:

```
v()->string()->default('default value')
```

Note that default values are only used currently if the field is not provided data AND is optional.

### Using Rules

[](#using-rules)

If you are using inside of Laravel, you can use the `rules` method to add rules to your schema. This relies on the Laravel Validator facade, so will only work if it is available.

```
  v()->string()->rules('email')->parse('not an email') // throws an exception
  v()->string()->rules('email')->parse('dean@example.com') // returns dean@example.com
```

### Adding and referencing definitions

[](#adding-and-referencing-definitions)

Add definitions to your schema for reusable components:

```
$schema = v()->object([
    'user' => v()->ref('userSchema'),
    'posts' => v()->array(v()->ref('postSchema')),
])
->define('userSchema', v()->object([
    'id' => v()->number()->int(),
    'name' => v()->string(),
    'email' => v()->string(),
]))
->define('postSchema', v()->object([
    'id' => v()->number()->int(),
    'title' => v()->string(),
    'content' => v()->string(),
]));
```

To add a reference to a defined schema, use `v()->ref('schemaName')`.

Note: Definitions can only be added to a top-level object schema. They are not available for nested objects or other types.

Using definitions can help you create more modular and reusable schemas, especially for complex data structures.

### Generating TypeScript Definitions

[](#generating-typescript-definitions)

Generate TypeScript definitions:

```
$typescript = $schema->toTypescript();
```

### Generating JSON Schemas

[](#generating-json-schemas)

Generate JSON schemas:

```
$jsonSchema = $schema->toJsonSchema();
```

### Adding Descriptions

[](#adding-descriptions)

Add descriptions to your schema for better documentation - this is only used in json schemas currently.

```
$schema = v()->object([
        'name' => v()->string()->description('The user\'s full name'),
        'age' => v()->number()->int()->description('The user\'s age in years'),
])->description('User information schema');
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Dean McPherson](https://github.com/paperform-co)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance72

Regular maintenance activity

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.8% 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 ~31 days

Total

2

Last Release

369d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fab9f6ea398e4c042e274df505383b458fbdb12272ab025cd2f275f1fb716da3?d=identicon)[Dean](/maintainers/Dean)

---

Top Contributors

[![deanmcpherson](https://avatars.githubusercontent.com/u/2773950?v=4)](https://github.com/deanmcpherson "deanmcpherson (66 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelvalidationvodzodvod-validation

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[romegasoftware/laravel-schema-generator

Generate TypeScript Zod validation schemas from Laravel validation rules

288.2k](/packages/romegasoftware-laravel-schema-generator)[stuyam/laravel-phone-validator

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

2861.3k](/packages/stuyam-laravel-phone-validator)[pacerit/laravel-polish-validation-rules

Simple Polish Validation rules for Laravel and Lumen framework

1449.9k](/packages/pacerit-laravel-polish-validation-rules)[laravel-validation-rules/ip

Validate if an ip address is public or private.

1629.7k](/packages/laravel-validation-rules-ip)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)[fab2s/dt0

Immutable DTOs with bidirectional casting. No framework required. 8x faster than the alternative.

101.6k1](/packages/fab2s-dt0)

PHPackages © 2026

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