stefk/jval

JSON Schema validator

Maintainers

πŸ‘ stefk

Package info

github.com/stefk/JVal

pkg:composer/stefk/jval

Statistics

Installs: 317 411

Dependents: 5

Suggesters: 1

Stars: 16

Open Issues: 5

dev-master 2024-10-06 09:47 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3315e44fb8eb0ad036f5781ab6bdfb5468aba8f9

  • StΓ©phane Klein <stephaneklein221.woop@gmail.com>

jsonvalidationJSON Schema

This package is not auto-updated.

Last update: 2026-06-21 05:09:03 UTC


README

A JSON Schema validator written in PHP.

Features:

  • Full draft 4 support (passes the whole official [test suite] (https://github.com/json-schema/JSON-Schema-Test-Suite), except for the two tests that require big nums to be treated as integers, which is not feasible in PHP)
  • Distinct steps for references resolution, syntax parsing and data validation.

πŸ‘ Build Status
πŸ‘ Code Coverage
πŸ‘ Scrutinizer Code Quality

Installation

composer require stefk/jval dev-master

Basic usage

$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');

CLI

bin/jval path/to/data path/to/schema