Validator
extends BaseConstraint
in package
A JsonSchema Constraint
Tags
Table of Contents
Constants
- ERROR_ALL = 0xffffffff
- ERROR_DOCUMENT_VALIDATION = 0x1
- ERROR_NONE = 0x0
- ERROR_SCHEMA_VALIDATION = 0x2
- SCHEMA_MEDIA_TYPE = 'application/schema+json'
Properties
- $errorMask : int
- $errors : array<string|int, mixed>
- $factory : Factory
Methods
- __construct() : mixed
- addError() : mixed
- addErrors() : mixed
- arrayToObjectRecursive() : object
- Recursively cast an associative array to an object
- check() : mixed
- Alias to validate(), to maintain backwards-compatibility with the previous API
- coerce() : mixed
- Alias to validate(), to maintain backwards-compatibility with the previous API
- getErrorMask() : int
- Get the error mask
- getErrors() : mixed
- isValid() : mixed
- numErrors() : mixed
- reset() : mixed
- Clears any reported errors. Should be used between multiple validation checks.
- validate() : mixed
- 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.
Constants
ERROR_ALL
public
mixed
ERROR_ALL
= 0xffffffff
ERROR_DOCUMENT_VALIDATION
public
mixed
ERROR_DOCUMENT_VALIDATION
= 0x1
ERROR_NONE
public
mixed
ERROR_NONE
= 0x0
ERROR_SCHEMA_VALIDATION
public
mixed
ERROR_SCHEMA_VALIDATION
= 0x2
SCHEMA_MEDIA_TYPE
public
mixed
SCHEMA_MEDIA_TYPE
= 'application/schema+json'
Properties
$errorMask
protected
int
$errorMask
= \JsonSchema\Validator::ERROR_NONE
All error types which have occurred
$errors
protected
array<string|int, mixed>
$errors
= array()
Errors
$factory
protected
Factory
$factory
Methods
__construct()
public
__construct([Factory $factory = null ]) : mixed
Parameters
- $factory : Factory = null
addError()
public
addError([JsonPointer $path = null ], mixed $message[, mixed $constraint = '' ][, array<string|int, mixed> $more = null ]) : mixed
Parameters
- $path : JsonPointer = null
- $message : mixed
- $constraint : mixed = ''
- $more : array<string|int, mixed> = null
addErrors()
public
addErrors(array<string|int, mixed> $errors) : mixed
Parameters
- $errors : array<string|int, mixed>
arrayToObjectRecursive()
Recursively cast an associative array to an object
public
static arrayToObjectRecursive(array<string|int, mixed> $array) : object
Parameters
- $array : array<string|int, mixed>
Return values
objectcheck()
Alias to validate(), to maintain backwards-compatibility with the previous API
public
check(mixed $value, mixed $schema) : mixed
Parameters
- $value : mixed
- $schema : mixed
coerce()
Alias to validate(), to maintain backwards-compatibility with the previous API
public
coerce(mixed &$value, mixed $schema) : mixed
Parameters
- $value : mixed
- $schema : mixed
getErrorMask()
Get the error mask
public
getErrorMask() : int
Return values
intgetErrors()
public
getErrors([mixed $errorContext = Validator::ERROR_ALL ]) : mixed
Parameters
- $errorContext : mixed = Validator::ERROR_ALL
isValid()
public
isValid() : mixed
numErrors()
public
numErrors([mixed $errorContext = Validator::ERROR_ALL ]) : mixed
Parameters
- $errorContext : mixed = Validator::ERROR_ALL
reset()
Clears any reported errors. Should be used between multiple validation checks.
public
reset() : mixed
validate()
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.
public
validate(mixed &$value[, mixed $schema = null ][, mixed $checkMode = null ]) : mixed
The validation works as defined by the schema proposal in http://json-schema.org.
Note that the first argument is passed by reference, so you must pass in a variable.
Parameters
- $value : mixed
- $schema : mixed = null
- $checkMode : mixed = null