vertilia / json-schema
JSON schema 验证器
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-08-29 05:50:26 UTC
README
一个轻量级的 Draft 7 JSON Schema 验证器,根据 理解 JSON Schema。
用法
<?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
更多示例在 /tests/
目录中。
安装
cd /your/project/root/
composer require vertilia/json-schema