Skip to content

DaveARG/zod-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zod-PHP

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',
    ],
]);

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%