Constants

CHECK_MODE_NONE

CHECK_MODE_NONE = 0

CHECK_MODE_NORMAL

CHECK_MODE_NORMAL = 1

CHECK_MODE_TYPE_CAST

CHECK_MODE_TYPE_CAST = 2

CHECK_MODE_COERCE_TYPES

CHECK_MODE_COERCE_TYPES = 4

CHECK_MODE_APPLY_DEFAULTS

CHECK_MODE_APPLY_DEFAULTS = 8

CHECK_MODE_EXCEPTIONS

CHECK_MODE_EXCEPTIONS = 16

CHECK_MODE_DISABLE_FORMAT

CHECK_MODE_DISABLE_FORMAT = 32

CHECK_MODE_ONLY_REQUIRED_DEFAULTS

CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 128

CHECK_MODE_VALIDATE_SCHEMA

CHECK_MODE_VALIDATE_SCHEMA = 256

Properties

$wording

$wording : array|array<mixed,string>

Type

array|array<mixed,string> — type wordings for validation error messages

$inlineSchemaProperty

$inlineSchemaProperty : 

Type

$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

check()

check(  $value = null,   $schema = null, \JsonSchema\Entity\JsonPointer  $path = null,   $i = null) 

{@inheritdoc}

Parameters

$value
$schema
\JsonSchema\Entity\JsonPointer $path
$i

incrementPath()

incrementPath(\JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i) : \JsonSchema\Constraints\JsonPointer;

Bubble down the path

Parameters

\JsonSchema\Entity\JsonPointer|null $path

Current path

mixed $i

What to append to the path

Returns

\JsonSchema\Constraints\JsonPointer;

checkArray()

checkArray(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null) 

Validates an array

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i

checkObject()

checkObject(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $properties = null, mixed  $additionalProperties = null, mixed  $patternProperties = null,   $appliedDefaults = array()) 

Validates an object

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $properties
mixed $additionalProperties
mixed $patternProperties
$appliedDefaults

checkType()

checkType(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null) 

Validates the type of a property

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i

checkUndefined()

checkUndefined(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null,   $fromDefault = false) 

Checks a undefined element

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i
$fromDefault

checkString()

checkString(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null) 

Checks a string element

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i

checkNumber()

checkNumber(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer  $path = null, mixed  $i = null) 

Checks a number element

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer $path
mixed $i

checkEnum()

checkEnum(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null) 

Checks a enum element

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i

checkFormat()

checkFormat(mixed  $value, mixed  $schema = null, \JsonSchema\Entity\JsonPointer|null  $path = null, mixed  $i = null) 

Checks format of an element

Parameters

mixed $value
mixed $schema
\JsonSchema\Entity\JsonPointer|null $path
mixed $i

convertJsonPointerIntoPropertyPath()

convertJsonPointerIntoPropertyPath(\JsonSchema\Entity\JsonPointer  $pointer) : string

Parameters

\JsonSchema\Entity\JsonPointer $pointer

Returns

string —

property path

validateTypesArray()

validateTypesArray(mixed  $value, array  $type, array  $validTypesWording, boolean  $isValid,   $path) 

Validates the given $value against the array of types in $type. Sets the value of $isValid to true, if at least one $type mateches the type of $value or the value passed as $isValid is already true.

Parameters

mixed $value

Value to validate

array $type

TypeConstraints to check agains

array $validTypesWording

An array of wordings of the valid types of the array $type

boolean $isValid

The current validation value

$path

implodeWith()

implodeWith(array  $elements, string  $delimiter = ', ', boolean  $listEnd = false) : string

Implodes the given array like implode() with turned around parameters and with the difference, that, if $listEnd isn't false, the last element delimiter is $listEnd instead of $delimiter.

Parameters

array $elements

The elements to implode

string $delimiter

The delimiter to use

boolean $listEnd

The last delimiter to use (defaults to $delimiter)

Returns

string

validateTypeNameWording()

validateTypeNameWording(string  $type) 

Validates the given $type, if there's an associated self::$wording. If not, throws an exception.

Parameters

string $type

The type to validate

Throws

\UnexpectedValueException

validateType()

validateType(mixed  $value, string  $type) : boolean

Verifies that a given value is of a certain type

Parameters

mixed $value

Value to validate

string $type

TypeConstraint to check against

Throws

\JsonSchema\Exception\InvalidArgumentException

Returns

boolean

toBoolean()

toBoolean(  $value) : boolean|mixed

Converts a value to boolean. For example, "true" becomes true.

Parameters

$value

The value to convert to boolean

Returns

boolean|mixed

toNumber()

toNumber(mixed  $value) : integer|float|mixed

Converts a numeric string to a number. For example, "4" becomes 4.

Parameters

mixed $value

the value to convert to a number

Returns

integer|float|mixed

toInteger()

toInteger(  $value) 

Parameters

$value