Download the PHP package ropi/json-schema-evaluator without Composer
On this page you can find all versions of the php package ropi/json-schema-evaluator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package json-schema-evaluator
A modern JSON Schema evaluator for PHP
This library is a PHP based implementation for evaluating and validating JSON Schemas. The library can be easily extended with your own keywords and drafts.
Requirements
- PHP >= 8.1
- ext-bcmath
- ext-mbstring
- ext-fileinfo
Table of contents
- Installation
- Supported drafts
- Basic examples
- Basic usage
- Read individual error results
- Formatting results
- Mutations
- Default values
- Content decoding
- Advanced examples
- Assert content media type
- Assert format
- Short-circuiting
- Big numbers
- Custom keywords
Installation
The library can be installed from a command line interface by using composer.
Supported drafts
Draft 2020-12 (Core and Validation)
Passes all tests of official JSON schema test suite except the following optional tests:
- optional/refOfUnknownKeyword.json: This means that you cannot use the $ref keyword to reference schemas that are located inside unknown keywords.
- optional/ecmascript-regex.json: This means that the specifics of Ecmascript regular expressions are not respected. Instead, regular expressions are evaluated as PERL regular expressions.
Basic examples
Basic usage
Read individual error results
Output of above example:
Formatting results
In the following example, the results are formatted as Basic Output Structure. In addition, only the Flag Output Structure is also currently supported.
Output of above example:
Mutations
Default values
If a default value is defined with the default keyword, it can be automatically applied during evaluation.
Content decoding
If encoded content is defined with the contentEncoding keyword, it can be automatically decoded during evaluation.
Advanced examples
Assert content media type
If content media type is defined with the contentMediaType keyword, it can be respected during evaluation.
Assert format
If format is defined with the format keyword, it can be respected during evaluation.
Short-circuiting
By default, all keywords are evaluated, even if the first keyword validation fails. If short circuiting is activated, the evaluation stops at the first negative validation result.
Big numbers (interpret numeric strings as numbers)
Custom keywords
It is possible to add custom keywords to a draft.\ The following example shows how to implement a keyword where the instance must match a specific md5 hash.
All versions of json-schema-evaluator with dependencies
ext-mbstring Version *
ext-fileinfo Version *
php Version >=8.1.0
guzzlehttp/psr7 Version ^2.0
symfony/polyfill-intl-idn Version ^1.23