Index

ArrayValidator

MMO\core\schemas · 1 symbol · generated 5 Oct 2026

class

ArrayValidator

Validator.php:472

Validator for a PHP array value -- which, per JSON Schema, can be EITHER the 'array' type (a list) or the 'object' type (a map): $testArray/$testObject decide which, from the value's own shape (a list vs an associative array; an empty array is ambiguously treated as valid for both, matching JSON's own []/{} ambiguity for an empty PHP array). Handles every list-keyword ('items'/'prefixItems'/'contains'/...) and every map-keyword ('properties'/'required'/'patternProperties'/...), each only actually applied when the value is being tested as the matching JSON type. $content accumulates each item/property's own sub-validator as it's evaluated, both to avoid re-validating it under 'unevaluatedItems'/'unevaluatedProperties' and (via merge) to propagate what a branch of 'allOf'/'anyOf'/'oneOf'/'if' evaluated back to this validator.

class MMO\core\schemas\ArrayValidator extends MMO\core\schemas\Validator
Namespace
MMO\core\schemas
Extends
Validator

Index

KEYS
content
testArrayTrue if the value is a JSON-Schema-'array'-shaped (list) value.
testObjectTrue if the value is a JSON-Schema-'object'-shaped (map) value.
isValidType($types)
merge($validator)Merge another (sibling, e.g.
validate_additionalProperties()'additionalProperties': validate every key not already evaluated by 'properties'/'patternProperties' against this schema (commonly false, to reject any key outside the explicitly declared ones).
validate_contains()'contains'/'minContains'/'maxContains': at least (default 1)/at most this many items must validate against the given schema.
validate_dependentRequired()'dependentRequired': when a listed key is present, its own required-companion keys must be present too.
validate_dependentSchemas()'dependentSchemas': when a listed key is present, the whole value must also validate against that key's schema.
validate_items()'items': validate every item not already evaluated by 'prefixItems' against this one schema.
validate_maxItems()'maxItems': at most this many items (a 'array'-only keyword -- ignored when testing as 'object').
validate_maxProperties()'maxProperties': at most this many keys.
validate_minItems()'minItems': at least this many items.
validate_minProperties()'minProperties': at least this many keys.
validate_patternProperties()'patternProperties': every key matching a given regex pattern must validate against that pattern's schema (a key can match, and be validated by, more than one pattern).
validate_prefixItems()'prefixItems': validate the first N items positionally against N corresponding schemas (any item beyond that is left for 'items').
validate_properties()'properties': validate each named key present in the value against its own schema.
validate_propertyNames()'propertyNames': every key itself (as a string) must validate against the given schema.
validate_required()'required': every listed key must be present (its value may still be null).
validate_unevaluatedItems()'unevaluatedItems': validate every item not already evaluated by 'prefixItems'/'items'/'contains' (or merged in from an 'allOf'/'anyOf'/'oneOf'/'if' branch -- see merge) against this schema.
validate_unevaluatedProperties()'unevaluatedProperties': validate every key not already evaluated by anything else (including keys merged in from an 'allOf'/'anyOf'/'oneOf'/'if' branch -- see merge) against this schema.
validate_uniqueItems()'uniqueItems': no two items may be equal (skipped when the keyword is false, i.e.
__construct($schema, $value)

Constants1

KEYS

const KEYS = […24 items]

Properties3

content

array $content = []
Type
array

testArray

True if the value is a JSON-Schema-'array'-shaped (list) value.

protected bool $testArray
Type
bool

testObject

True if the value is a JSON-Schema-'object'-shaped (map) value.

protected bool $testObject
Type
bool

Methods20

merge($validator)

Validator.php:509

Merge another (sibling, e.g. from an 'allOf' branch) ArrayValidator's $content into this one's, so items/properties it already evaluated aren't re-evaluated (and re-reported) by a later 'unevaluatedItems'/ 'unevaluatedProperties' check on this validator.

function merge(MMO\core\schemas\ArrayValidator $validator): void
$validatorArrayValidator
returnsvoid

validate_additionalProperties()

Validator.php:693

'additionalProperties': validate every key not already evaluated by 'properties'/'patternProperties' against this schema (commonly false, to reject any key outside the explicitly declared ones).

protected function validate_additionalProperties(): Generator
returnsGenerator

validate_contains()

Validator.php:568

'contains'/'minContains'/'maxContains': at least (default 1)/at most this many items must validate against the given schema.

protected function validate_contains(): Generator
returnsGenerator

validate_dependentRequired()

Validator.php:627

'dependentRequired': when a listed key is present, its own required-companion keys must be present too. Each missing one fails at 'dependentRequired/{key}/{missing}', both names escaped: toError reads them back.

protected function validate_dependentRequired(): Generator
returnsGenerator

validate_dependentSchemas()

Validator.php:637

'dependentSchemas': when a listed key is present, the whole value must also validate against that key's schema.

protected function validate_dependentSchemas(): Generator
returnsGenerator

validate_items()

Validator.php:554

'items': validate every item not already evaluated by 'prefixItems' against this one schema.

protected function validate_items(): Generator
returnsGenerator

validate_maxItems()

Validator.php:523

'maxItems': at most this many items (a 'array'-only keyword -- ignored when testing as 'object').

protected function validate_maxItems(): Generator
returnsGenerator

validate_maxProperties()

Validator.php:606

'maxProperties': at most this many keys.

protected function validate_maxProperties(): Generator
returnsGenerator

validate_minItems()

Validator.php:528

'minItems': at least this many items.

protected function validate_minItems(): Generator
returnsGenerator

validate_minProperties()

Validator.php:611

'minProperties': at least this many keys.

protected function validate_minProperties(): Generator
returnsGenerator

validate_patternProperties()

Validator.php:675

'patternProperties': every key matching a given regex pattern must validate against that pattern's schema (a key can match, and be validated by, more than one pattern).

protected function validate_patternProperties(): Generator
returnsGenerator

validate_prefixItems()

Validator.php:540

'prefixItems': validate the first N items positionally against N corresponding schemas (any item beyond that is left for 'items').

protected function validate_prefixItems(): Generator
returnsGenerator

validate_properties()

Validator.php:650

'properties': validate each named key present in the value against its own schema.

protected function validate_properties(): Generator
returnsGenerator

validate_propertyNames()

Validator.php:663

'propertyNames': every key itself (as a string) must validate against the given schema.

protected function validate_propertyNames(): Generator
returnsGenerator

validate_required()

Validator.php:616

'required': every listed key must be present (its value may still be null).

protected function validate_required(): Generator
returnsGenerator

validate_unevaluatedItems()

Validator.php:590

'unevaluatedItems': validate every item not already evaluated by 'prefixItems'/'items'/'contains' (or merged in from an 'allOf'/'anyOf'/'oneOf'/'if' branch -- see merge) against this schema.

protected function validate_unevaluatedItems(): Generator
returnsGenerator

validate_unevaluatedProperties()

Validator.php:708

'unevaluatedProperties': validate every key not already evaluated by anything else (including keys merged in from an 'allOf'/'anyOf'/'oneOf'/'if' branch -- see merge) against this schema.

protected function validate_unevaluatedProperties(): Generator
returnsGenerator

validate_uniqueItems()

Validator.php:533

'uniqueItems': no two items may be equal (skipped when the keyword is false, i.e. duplicates are allowed).

protected function validate_uniqueItems(): Generator
returnsGenerator

__construct($schema, $value)

Validator.php:491
function __construct(MMO\core\interfaces\iSchema $schema, array $value)
$schemaiSchema
$valuearrayreordered in place (Validator::Reorder) so structural (enum/const) comparisons are key-order-independent.
Inherited members (19)
ConstantsDeclared byDescription
ERROR_TEMPLATESValidatorHuman-readable message template per keyword, used by toError.
PropertiesDeclared byDescription
keyValidatorThis validator's key/index within its $parent (e.g.
parentValidatorThe validator for the enclosing value, or null at the root.
schemaValidatorThe schema it's validated against.
valueValidatorThe value being validated.
MethodsDeclared byDescription
createInPlaceValidator($schema)ValidatorA validator of this same value against another schema: an allOf/anyOf/oneOf branch, not, if/then/else, a dependent schema.
describeAssert($assert)ValidatorWhat a failing keyword expected, as plain text: a list of types reads null|string.
getIterator()Validator\IteratorAggregate::getIterator -- yields schemaPath => Validator for every keyword this value fails (the Validator being the (sub-)validator whose value actually failed that keyword, not necessa…
getPath($join)Validator
Reorder($value)ValidatorRecursively sort $value's keys (and, in turn, every nested array's keys), in place -- used before comparing two structures for equality regardless of key order (validate_enum/validate_const).
setParent($validator, $key)ValidatorAttach this validator (for a nested value) under $validator, at $key (a property name or array index) -- used to build getPath.
toError($schemaPath)ValidatorBuild a human-readable error for a failing schema path (a key yielded by getIterator/a validate_* method), this validator being the one that failed.
validate_allOf()Validator'allOf': the value must validate against every listed schema; each schema's own failures are all yielded (not just the first).
validate_anyOf()Validator'anyOf': the value must validate against at least one listed schema; if none match, every schema's failures are yielded together.
validate_const()Validator'const': same as a single-value validate_enum.
validate_enum()Validator'enum': the value must strictly equal (order-independent for arrays/objects, and int/float-interchangeable for whole numbers) one of the declared constants.
validate_if()Validator'if'/'then'/'else': validates against 'then' if the value matches 'if', otherwise against 'else' (each defaulting to TrueSchema, i.e.
validate_not()Validator'not': the value must NOT validate against the given schema.
validate_oneOf()Validator'oneOf': the value must validate against exactly one listed schema -- matching zero (all schemas' failures yielded) or more than one (a single "matched more than one" error) both fail.