Overview

Namespaces

  • Webmozart
    • Json

Classes

  • JsonDecoder
  • JsonEncoder
  • JsonError
  • JsonValidator

Exceptions

  • DecodingFailedException
  • EncodingFailedException
  • FileNotFoundException
  • InvalidSchemaException
  • ValidationFailedException
  • Overview
  • Namespace
  • Class

Class JsonValidator

Validates decoded JSON values against a JSON schema.

This class is a wrapper for JsonSchema\Validator that adds exceptions and validation of schema files. A few edge cases that are not handled by JsonSchema\Validator are handled by this class.

Namespace: Webmozart\Json
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at JsonValidator.php
Methods summary
public string[]
# validate( mixed $data, string|object $schema )

Validates JSON data against a schema.

Validates JSON data against a schema.

The schema may be passed as file path or as object returned from json_decode($schemaFile).

Parameters

$data
The decoded JSON data.
$schema
The schema file or object.

Returns

string[]

The errors found during validation. Returns an empty array if no errors were found.

Throws

Webmozart\Json\InvalidSchemaException
If the schema is invalid.
Webmozart JSON API API documentation generated by ApiGen