JSON Schema validator
A JSON Schema validator written in PHP.
Features:
composer require stefk/jval dev-master
$validator = JVal\Validator::buildDefault();
$violations = $validator->validate($data, $schema);
Data can be anything that might result from a call to json_decode
. The schema
must be the JSON-decoded representation of a JSON Schema, i.e. a stdClass
instance.
If the schema contains relative references to external schemas (either remote
or local), the absolute URI of the base schema will probably be needed as well:
$validator = JVal\Validator::buildDefault();
$violations = $validator->validate($data, $schema, 'file://path/to/the/schema');
bin/jval path/to/data path/to/schema