\JsonSchemaValidator

A JsonSchema Constraint

Summary

Methods
Properties
Constants
__construct()
addError()
addErrors()
getErrors()
numErrors()
isValid()
reset()
getErrorMask()
arrayToObjectRecursive()
validate()
check()
coerce()
No public properties found
SCHEMA_MEDIA_TYPE
ERROR_NONE
ERROR_ALL
ERROR_DOCUMENT_VALIDATION
ERROR_SCHEMA_VALIDATION
No protected methods found
$errors
$errorMask
$factory
N/A
No private methods found
No private properties found
N/A

Constants

SCHEMA_MEDIA_TYPE

SCHEMA_MEDIA_TYPE = 'application/schema+json'

ERROR_NONE

ERROR_NONE = 0

ERROR_ALL

ERROR_ALL = 4294967295

ERROR_DOCUMENT_VALIDATION

ERROR_DOCUMENT_VALIDATION = 1

ERROR_SCHEMA_VALIDATION

ERROR_SCHEMA_VALIDATION = 2

Properties

$errors

$errors : array

Type

array — Errors

$errorMask

$errorMask : integer

Type

integer — All error types which have occurred

Methods

addError()

addError(\JsonSchema\Entity\JsonPointer  $path = null,   $message,   $constraint = '', array  $more = null) 

Parameters

\JsonSchema\Entity\JsonPointer $path
$message
$constraint
array $more

addErrors()

addErrors(array  $errors) 

Parameters

array $errors

getErrors()

getErrors(  $errorContext = \JsonSchema\Validator::ERROR_ALL) 

Parameters

$errorContext

numErrors()

numErrors(  $errorContext = \JsonSchema\Validator::ERROR_ALL) 

Parameters

$errorContext

isValid()

isValid() 

reset()

reset() 

Clears any reported errors. Should be used between multiple validation checks.

getErrorMask()

getErrorMask() : integer

Get the error mask

Returns

integer

arrayToObjectRecursive()

arrayToObjectRecursive(array  $array) : object

Recursively cast an associative array to an object

Parameters

array $array

Returns

object

validate()

validate(  $value,   $schema = null,   $checkMode = null) 

Validates the given data against the schema and returns an object containing the results Both the php object and the schema are supposed to be a result of a json_decode call.

The validation works as defined by the schema proposal in http://json-schema.org.

Note that the first argument is passwd by reference, so you must pass in a variable.

{@inheritdoc}

Parameters

$value
$schema
$checkMode

check()

check(  $value,   $schema) 

Alias to validate(), to maintain backwards-compatibility with the previous API

Parameters

$value
$schema

coerce()

coerce(  $value,   $schema) 

Alias to validate(), to maintain backwards-compatibility with the previous API

Parameters

$value
$schema