vertilia / json-schema
JSON schema validator
v0.8
2021-05-02 22:31 UTC
Requires
- php: ^7.1
Suggests
- phpunit/phpunit: To run tests
This package is auto-updated.
Last update: 2024-10-29 06:36:19 UTC
README
A lightweight Draft 7 JSON Schema validator, according to Understanding JSON Schema.
Usage
<?php $validator = new Vertilia\JsonSchema\JsonSchema('{ "type": "array", "items": {"type": "number"} }'); print_r($validator->isValid('[1, 2, 3]')); // true, array of numbers print_r($validator->isValid('[1, 2, "3"]')); // false, array of numbers and a string
More examples available in /tests/
.
Installation
cd /your/project/root/
composer require vertilia/json-schema