ArrayValidator
MMO\core\schemas · 1 symbol · generated 5 Oct 2026
ArrayValidator
Validator.php:472Validator 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.
- Namespace
MMO\core\schemas- Extends
- Validator
Index
| KEYS | ||
| content | ||
| testArray | True if the value is a JSON-Schema-'array'-shaped (list) value. | |
| testObject | True 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
Properties3
content
- Type
- array
testArray
True if the value is a JSON-Schema-'array'-shaped (list) value.
- Type
- bool
testObject
True if the value is a JSON-Schema-'object'-shaped (map) value.
- Type
- bool
Methods20
isValidType($types)
Validator.php:498merge($validator)
Validator.php:509Merge 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.
| $validator | ArrayValidator | |
| returns | void |
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).
| returns | Generator |
validate_contains()
Validator.php:568'contains'/'minContains'/'maxContains': at least (default 1)/at most this many items must validate against the given schema.
| returns | Generator |
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.
| returns | Generator |
validate_dependentSchemas()
Validator.php:637'dependentSchemas': when a listed key is present, the whole value must also validate against that key's schema.
| returns | Generator |
validate_items()
Validator.php:554'items': validate every item not already evaluated by 'prefixItems' against this one schema.
| returns | Generator |
validate_maxItems()
Validator.php:523'maxItems': at most this many items (a 'array'-only keyword -- ignored when testing as 'object').
| returns | Generator |
validate_maxProperties()
Validator.php:606'maxProperties': at most this many keys.
| returns | Generator |
validate_minItems()
Validator.php:528'minItems': at least this many items.
| returns | Generator |
validate_minProperties()
Validator.php:611'minProperties': at least this many keys.
| returns | Generator |
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).
| returns | Generator |
validate_prefixItems()
Validator.php:540'prefixItems': validate the first N items positionally against N corresponding schemas (any item beyond that is left for 'items').
| returns | Generator |
validate_properties()
Validator.php:650'properties': validate each named key present in the value against its own schema.
| returns | Generator |
validate_propertyNames()
Validator.php:663'propertyNames': every key itself (as a string) must validate against the given schema.
| returns | Generator |
validate_required()
Validator.php:616'required': every listed key must be present (its value may still be null).
| returns | Generator |
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.
| returns | Generator |
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.
| returns | Generator |
validate_uniqueItems()
Validator.php:533'uniqueItems': no two items may be equal (skipped when the keyword is false, i.e. duplicates are allowed).
| returns | Generator |
__construct($schema, $value)
Validator.php:491| $schema | iSchema | |
| $value | array | reordered in place (Validator::Reorder) so structural (enum/const) comparisons are key-order-independent. |
Inherited members (19)
| Constants | Declared by | Description | |
|---|---|---|---|
ERROR_TEMPLATES | Validator | Human-readable message template per keyword, used by toError. |
| Properties | Declared by | Description | |
|---|---|---|---|
key | Validator | This validator's key/index within its $parent (e.g. | |
parent | Validator | The validator for the enclosing value, or null at the root. | |
schema | Validator | The schema it's validated against. | |
value | Validator | The value being validated. |
| Methods | Declared by | Description | |
|---|---|---|---|
createInPlaceValidator($schema) | Validator | A validator of this same value against another schema: an allOf/anyOf/oneOf branch, not, if/then/else, a dependent schema. | |
describeAssert($assert) | Validator | What 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) | Validator | Recursively 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) | Validator | Attach this validator (for a nested value) under $validator, at $key (a property name or array index) -- used to build getPath. | |
toError($schemaPath) | Validator | Build 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. |