Skip to content

luca-rath/php-json-schema

Repository files navigation

PHP JSON Schema

License Latest tag GitHub Actions Scrutinizer build Scrutinizer coverage Scrutinizer code quality

PHP classes to help create json schemas

Installation

composer require luca-rath/php-json-schema

Usage

use JsonSchema\Keyword\FormatKeyword;
use JsonSchema\Property\Property;
use JsonSchema\Schema\IntegerSchema;
use JsonSchema\Schema\ObjectSchema;
use JsonSchema\Schema\StringSchema;

ObjectSchema::create()
    ->title('Registration form')
    ->properties([
        Property::create('email', true, StringSchema::create()
            ->format(FormatKeyword::FORMAT_EMAIL)
            ->examples(['[email protected]'])),
        Property::create('password', true, StringSchema::create()
            ->minLength(8)
            ->description('The password must be at least eight characters long')),
        Property::create('age', false, IntegerSchema::create()
            ->nullable()
            ->minimum(18)),
    ]);

About

PHP classes to help create json schemas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages