JS>> JVal>> 返回
项目作者: stefk

项目描述 :
JSON Schema validator
高级语言: PHP
项目地址: git://github.com/stefk/JVal.git
创建时间: 2015-10-09T11:07:15Z
项目社区:https://github.com/stefk/JVal

开源协议:MIT License

下载


JVal

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

  1. $validator = JVal\Validator::buildDefault();
  2. $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:

  1. $validator = JVal\Validator::buildDefault();
  2. $violations = $validator->validate($data, $schema, 'file://path/to/the/schema');

CLI

  1. bin/jval path/to/data path/to/schema