Skip to content

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

Notifications You must be signed in to change notification settings

StyleShit/zod-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zod-PHP

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

Usage:

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

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

For more information, see the tests.

About

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

Resources

Stars

Watchers

Forks

Languages