dave-arg/zod-php

There is no license information available for the latest version (v1.0.2) of this package.

v1.0.2 2024-10-15 23:51 UTC

This package is auto-updated.

Last update: 2025-08-16 22:54:57 UTC


README

A Zod-like implementation in PHP, inspired by Laravel's code standards.

Installation:

composer require dave-arg/zod-php

Usage:

The usage is pretty simple & straightforward, and is very similar to the original Zod library:

use DaveARG\Zod\Zod as Z;

// Create the schema.
$schema = Z::object([
    'name' => Z::string()->min(3)->max(15),
    'age' => Z::number()->min(0),
    'address' => Z::object([
        'city' => Z::string(),
        'street' => Z::string(),
    ]),
]);

// Validate the data.
$parsed = $schema->parse([
    'name' => 'John Doe',
    'age' => 20,
    'address' => [
        'city' => 'New York',
        'street' => 'Wall Street',
    ],
]);