Object
Properties which contain an object will result in an additional PHP class. The PHP classes will be connected via type hinting to provide autocompletion during the development.
{
"$id": "person",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"car": {
"$id": "car",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"ps": {
"type": "integer"
}
}
}
}
}
Generated interface:
// class Person
public function setName(string $name): static;
// As the property is not required it may be initialized with null. Consequently the return value is nullable
public function getName(): ?string;
public function setCar(Car $name): static;
public function getCar(): ?Car;
// class Car
public function setModel(string $name): static;
public function getModel(): ?string;
public function setPs(int $name): static;
public function getPs(): ?int;
Possible exceptions:
* Invalid type for 'car': requires 'object', got '__TYPE__'
* Invalid nested object for property 'car':
- Invalid type for 'model': requires 'string', got '__TYPE__'
The thrown exception will be a PHPModelGenerator\Exception\Generic\InvalidTypeException which provides the following methods to get further error details:
// returns a string if the property expects exactly one type, an array if the property accepts multiple types
public function getExpectedType()
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
The nested object will be validated in the nested class Car which may throw additional exceptions if invalid data is provided. If the internal validation of a nested object fails a PHPModelGenerator\Exception\Generic\NestedObjectException will be thrown which provides the following methods to get further error details:
// Returns the exception which was thrown in the nested object
public function getNestedException()
// get the name of the property which contains the nested object
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
If error collection is enabled the nested exception returned by getNestedException will be an ErrorRegistryException containing all validation errors of the nested object. Otherwise it will contain the first validation error which occurred during the validation of the nested object.
Hint
If the class created for a nested object is instantiated manually you will either get a collection exception or a specific exception based on your error collection configuration if invalid data is provided.
Object applicators without an explicit type
A property subschema that declares object applicators — properties, patternProperties, additionalProperties, unevaluatedProperties, propertyNames, minProperties or maxProperties — is treated as an object even when it omits type: object. JSON Schema applicators are not gated on a type declaration, so the keywords apply whenever the provided value is an object.
Because an untyped schema imposes no type constraint, a value of any other type is still accepted and passes through unchanged. The property is therefore not typed as the nested class alone:
{
"type": "object",
"properties": {
"child": {
"properties": {
"known": {
"type": "string"
}
},
"unevaluatedProperties": false
}
}
}
Generated interface — an object value for child is wrapped in and validated by the generated nested class, while any other value is accepted unchanged:
/** @return Child|mixed */
public function getChild(): mixed;
The native return type is mixed, not Child | mixed: mixed already subsumes every type, and PHP rejects it inside a union. The annotation carries the additional information that the value may be an instance of the generated nested class.
A child object carrying an unevaluated key is rejected, while a scalar child value is accepted without modification. A bare untyped schema ({}) declares no applicators, so no nested class is generated and the property remains a plain mixed value.
A subschema which carries nothing but object applicators, like child above, makes the generator emit a warning: the missing type: object is easy to forget and lets every other value pass. A subschema which also constrains another type (e.g. minLength) declares the mixture itself and is not reported. See Composition-implied objects for the details.
This applies to property subschemas. A root schema without type: object doesn’t generate a class by default, so an unevaluatedProperties keyword on a typeless root has nothing to apply to: the generator warns about the file, naming the class and the fix. Declare type: object on the root, or enable setImplicitObjectComposition to generate the class as if the type was declared.
Note
The same principle applies to scalar and array applicators: a subschema declaring minLength without type: string, or minItems without type: array, enforces the constraint only when the value is of the matching type and accepts values of every other type.
Namespaces
If a nested class is generated the nested class will be located in the same namespace as the parent class. If the nested class occurs somewhere else and has already been generated a class from another namespace may be used (compare namespaces for additional information concerning class re-usage).
Naming
Naming of classes
If the given main object in a JSON-Schema file contains a title, the title will be used as class name. Otherwise, if an $id is present, the basename of the $id and as a last fallback the name of the file will be used.
Naming of nested classes
For the class name of a nested class the following priority order applies:
title — used as-is if present on the nested schema.
$id — the basename of the
$idURI is used if present.$anchor — the
$anchorvalue is used if present (Draft 2019-09 and later).$anchoris a plain-string identifier with the same intent as$idbut without URI semantics.Definition key — when the nested schema is referenced from a named
definitionsor$defsslot (e.g.$ref: "#/definitions/address"), the definition key is used (e.g.address). This produces stable, readable names even for schemas that carry notitle,$id, or$anchor.Inline property name — when the schema is defined inline directly under a
propertieskeyword, the property key is used without a content hash. Property keys are unique within their containing object, so the combination of parent class name and property key is already collision-free. For example, an inlinecarobject insidePersonbecomes Person_Car.Array items — when the schema is the
itemsof a named array property, the array property name is extracted andItemis appended, making it clear that the class represents one element of the array rather than the array itself. For example, the items of atagsarray property become {Parent}_TagsItem.Property name + content hash — final fallback for schemas that do not match any of the above (e.g. inline schemas inside composition branches like
anyOf/oneOf). The property key is prefixed with the parent class name and a short content hash is appended to avoid collisions between branches that share the same property name.The branches of a composition declared on an object (an
allOf/anyOf/oneOf/not/ifkeyword next totype: object) use the key of the property or definition the object lives in instead of the name of the object’s class. For anallOfcomposition on aceoproperty the branches are named {RootClass}_Ceo{hash}, exactly like the branches of ananyOfdeclared on theceoproperty. A composition declared on the object of the schema file itself has no such key; its branches are named {RootClass}_Branch{hash}.The names don’t grow with the nesting depth: a branch which contains another composition again results in the same name pattern, so deeply nested compositions stay below the file name limit of the file system.
Hint
Set title, $id, or $anchor on nested schemas, or use named
definitions/$defs entries, to get the most explicit and predictable class names.
Schemas with large definitions blocks that lack these keywords will automatically
receive names derived from their definition key.
For full control over class naming, implement ClassNameGeneratorInterface and pass it
to the generator configuration via
setClassNameGenerator().
Property Name Normalization
Property names are normalized to provide valid and readable PHP code. All non alpha numeric characters will be removed and the name is converted to camel case. The words of a name are separated by the removed characters, by a change from a lowercase letter or digit to an uppercase letter and by the end of a run of capitals if the last capital starts a new word (an acronym followed by a word). Each word is then written with a leading capital letter followed by lowercase letters.
{
"type": "object",
"properties": {
"underscore_property-minus": {
"type": "string"
},
"CAPS and space 100": {
"type": "string"
},
"SHSArtistId": {
"type": "string"
},
"HTTP2Server": {
"type": "string"
},
"userID": {
"type": "string"
}
}
}
Generated interface:
public function setUnderscorePropertyMinus(string $name): static;
public function getUnderscorePropertyMinus(): ?string;
public function setCapsAndSpace100(string $name): static;
public function getCapsAndSpace100(): ?string;
public function setShsArtistId(string $name): static;
public function getShsArtistId(): ?string;
public function setHttp2Server(string $name): static;
public function getHttp2Server(): ?string;
public function setUserId(string $name): static;
public function getUserId(): ?string;
A digit followed by a lowercase letter does not start a new word (1000string becomes get1000string()).
If the name normalization results in an empty attribute name (eg. ‘__ – __’) an exception will be thrown.
If two properties of an object result in the same attribute name (eg. foo-bar and fooBar, or SHSArtistId and
shsArtistId) or in attribute names which only differ in case (eg. fooBar and foobar, the accessor methods
getFooBar() and getFoobar() are identical for PHP) an exception will be thrown.
Note
The conversion also applies to the names of the cases generated by the EnumPostProcessor.
Required properties
Using the keyword required a list of properties may be defined which must be provided.
{
"$id": "person",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
},
"required": [
"name"
]
}
Possible exceptions:
Missing required value for ‘name’
Hint
Properties defined in the required array but not defined in the properties will be added to the interface of the generated class.
Boolean property schemas
A property schema can be the boolean literal true or false instead of a JSON object schema.
true — the property accepts any value without restriction. A getter is generated with return type mixed.
false — the property is explicitly forbidden. Providing it throws a DeniedPropertyException. Listing a forbidden property in required is a schema error detected at generation time.
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"anything": true,
"forbidden": false
}
}
Generated interface:
public function getName(): ?string;
public function getAnything(): mixed;
// No getter is generated for 'forbidden'; providing it throws DeniedPropertyException
Size
With the keywords minProperties and maxProperties the number of allowed properties can be limited:
{
"$id": "person",
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"minProperties": 2,
"maxProperties": 3
}
Possible exceptions:
Provided object for ‘person’ must not contain less than 2 properties
Provided object for ‘person’ must not contain more than 3 properties
The thrown exception will be a PHPModelGenerator\Exception\Object\MaxPropertiesException or a PHPModelGenerator\Exception\Object\MinPropertiesException which provides the following methods to get further error details:
// for a MaxPropertiesException: get the minimum amount of object properties
public function getMaxProperties(): int
// for a MinPropertiesException: get the maximum amount of object properties
public function getMinProperties(): int
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Additional Properties
Using the keyword additionalProperties the object can be limited to not contain any additional properties by providing false. If a schema is provided all additional properties must be valid against the provided schema. Simple checks like ‘must provide a string’ are possible as well as checks like ‘must contain an object with a specific structure’.
Hint
If you define constraints via additionalProperties you may want to use the AdditionalPropertiesAccessorPostProcessor to access and modify your additional properties.
{
"$id": "example",
"type": "object",
"properties": {
"example": {
"type": "integer"
}
},
"additionalProperties": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
}
Possible exceptions:
Provided JSON for ‘example’ contains not allowed additional properties [‘additional1’, ‘additional2’]
The thrown exception will be a PHPModelGenerator\Exception\Object\AdditionalPropertiesException which provides the following methods to get further error details:
// Get a list of all additional properties which are denied by the schema
public function getAdditionalProperties(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
If invalid additional properties are provided a detailed exception will be thrown containing all violations:
Provided JSON for 'example' contains invalid additional properties
- invalid additional property 'additional1'
* Invalid type for 'name': requires 'string', got 'integer'
- invalid additional property 'additional2'
* Invalid type for 'age': requires 'int', got 'string'
The thrown exception will be a PHPModelGenerator\Exception\Object\InvalidAdditionalPropertiesException which provides the following methods to get further error details:
// returns a two-dimensional array which contains all validation exceptions grouped by property names
public function getNestedExceptions(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Warning
The validation of additional properties is independently from the implicit null setting. If you require your additional properties to accept null define a multi type with explicit null.
Unevaluated Properties
The unevaluatedProperties keyword (Draft 2019-09 and later) constrains every property whose
name was not evaluated by any positive sibling applicator at the same schema level. A key is
counted as evaluated when it is claimed by properties, matched by patternProperties,
claimed by additionalProperties (when that keyword is present), claimed by the schema form of
dependencies while its trigger property is present on the instance (a non-standard extension,
see the note below), or claimed by a
successful branch of an adjacent composition (allOf, anyOf, oneOf,
if/then/else, $ref). not is a negative applicator and contributes nothing.
Unlike additionalProperties, unevaluatedProperties looks across composition branches:
a property covered by a branch that ended up succeeding is credited, and a property covered only
by a branch that failed is not. This holds at every nesting depth — a composition inside another
composition’s branch is resolved the same way, so a name declared only by a branch that lost is
never credited, and one declared by a branch that won always is. This makes the keyword suitable
for enforcing “no leftovers” at the outermost schema level while individual branches are free to
declare their own properties.
A $ref to a schema which declares an additionalProperties other than false claims every
remaining key, exactly as the keyword does on the schema itself: the referenced schema evaluates
what it declares through properties and everything else through additionalProperties, so
nothing is left for unevaluatedProperties to reject. The keys are still validated against the
additionalProperties of the referenced schema.
Note
dependencies is not a keyword of Draft 2019-09 and later, which split it into
dependentSchemas and dependentRequired. The generator keeps applying dependencies in
every draft as a non-standard extension, and as it validates the keys its dependent subschema
declares, it counts them as evaluated, the way dependentSchemas does. A validator which
follows the specification strictly ignores dependencies in these drafts and reports such
keys as unevaluated.
dependencies in its schema form contributes only while its trigger property is present. In
the schema below, extra is evaluated for {"kind": "a", "extra": 5} but not for
{"extra": 5}, where the dependent subschema never applies:
{
"type": "object",
"properties": {
"kind": {
"type": "string"
}
},
"dependencies": {
"kind": {
"properties": {
"extra": {
"type": "integer"
}
}
}
},
"unevaluatedProperties": false
}
A dependencies written inside a composition branch contributes the same way: while the
branch succeeds and its trigger property is present, the names of its dependent subschema are
evaluated.
Only the names the dependent subschema declares directly under its own properties count.
Names it reaches through a composition (allOf, anyOf, oneOf, if) or a $ref
are not credited, and neither are keys matched by its patternProperties. The generator emits
a warning naming the keyword when it sees one. Such a key is then reported as unevaluated even
though the dependent subschema evaluates it — declare the names as properties of the
dependent subschema itself to avoid this; a pattern has no such substitute.
dependentSchemas, the Draft 2019-09 spelling of the same applicator, is not yet supported.
Hint
If you define constraints via unevaluatedProperties you may want to use the
UnevaluatedPropertiesAccessorPostProcessor
to access and modify unevaluated properties on the model.
Using false
Setting unevaluatedProperties: false forbids any property not claimed by a sibling.
{
"$id": "person",
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"allOf": [
{
"properties": {
"age": {
"type": "integer"
}
}
}
],
"unevaluatedProperties": false
}
The generated model accepts name (claimed by properties) and age (claimed by the
allOf branch). Any other key raises an UnevaluatedPropertiesException:
Provided JSON for 'person' contains not allowed unevaluated properties ['extra']
The thrown exception will be a PHPModelGenerator\Exception\Object\UnevaluatedPropertiesException which provides the following methods to get further error details:
// Get the list of property names that were left unevaluated
public function getUnevaluatedProperties(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Using a schema
When unevaluatedProperties is set to a schema, every unevaluated key’s value must validate
against that schema:
{
"$id": "example",
"type": "object",
"properties": {
"example": {
"type": "integer"
}
},
"unevaluatedProperties": {
"type": "string",
"maxLength": 10
}
}
If invalid unevaluated properties are provided a detailed exception is thrown containing all violations:
Provided JSON for 'example' contains invalid unevaluated properties
- invalid unevaluated property 'note'
* Value for 'unevaluated property' must not be longer than 10
The thrown exception will be a PHPModelGenerator\Exception\Object\InvalidUnevaluatedPropertiesException which provides the following methods to get further error details:
// returns a two-dimensional array which contains all validation exceptions grouped by property names
public function getNestedExceptions(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Interaction with additionalProperties
When additionalProperties is present at the same schema level, it claims every key not
covered by properties or patternProperties first — leaving nothing for
unevaluatedProperties to see. The generator recognises these dead-code shapes at generation
time and emits a warning, then skips the unevaluatedProperties validator entirely:
additionalProperties: truealongside anyunevaluatedPropertiesvalue.additionalProperties: falsealongside anyunevaluatedPropertiesvalue.additionalProperties: {schema}alongside anyunevaluatedPropertiesvalue.An implicit
additionalProperties: falseproduced by the deny additional properties setting.
Contradictory inner schemas (e.g. unevaluatedProperties combining a subschema that no value
could satisfy with an outer configuration that still allows keys to reach it) are rejected with
a SchemaException at generation time.
Note
unevaluatedProperties also accepts the boolean literal true. On its own this is a
no-op — every property is considered evaluated — and no validator is emitted. Inside a
composition branch an explicit unevaluatedProperties: true annotates every property, so a
successful branch credits all keys to an enclosing unevaluatedProperties. An omitted
keyword produces no annotation.
Hint
See combined schemas for the per-keyword rules that govern how each composition contributes to the evaluated set.
Recursive Objects
If objects are defined recursive the recursion will be resolved into a single class.
{
"definitions": {
"person": {
"$id": "person",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/person"
}
}
}
}
},
"$id": "family",
"type": "object",
"properties": {
"members": {
"type": "array",
"items": {
"$ref": "#/definitions/person"
}
}
}
}
Generated interface:
// class Family, arrays type hinted in docblocks with Family_Person[]
public function setMembers(array $members): static;
public function getMembers(): ?array;
// class Person, arrays type hinted in docblocks with Family_Person[]
public function setName(string $name): static;
public function getName(): ?string;
public function setChildren(array $name): static;
public function getChildren(): ?array;
Property Names
With the keyword propertyNames rules can be defined which must be fulfilled by each given property.
{
"$id": "example",
"type": "object",
"propertyNames": {
"pattern": "^test[0-9]+$",
"maxLength": 8
}
}
Compare strings for information concerning possible property name validators.
Exceptions contain detailed information about the violations:
Provided JSON for 'example' contains properties with invalid names
- invalid property 'test12345a'
* Value for 'property name' does not match pattern '^test[0-9]+$'
* Value for 'property name' must not be longer than 8
- invalid property 'test123456789'
* Value for 'property name' must not be longer than 8
The thrown exception will be a PHPModelGenerator\Exception\Object\InvalidPropertyNamesException which provides the following methods to get further error details:
// returns a two-dimensional array which contains all validation exceptions grouped by property names
// each entry contains all name violations of the given property
public function getNestedExceptions(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Dependencies
With the keyword dependencies a list of properties can be defined which require a given dependency to be fulfilled if the property is present.
Property Dependencies
Property dependencies refer to a list of other object properties. Each of the referred property is required if the property utilizing the dependency is present.
{
"type": "object",
"properties": {
"credit_card": {
"type": "integer"
},
"billing_address": {
"type": "string"
}
},
"dependencies": {
"credit_card": [
"billing_address"
]
}
}
The generated object accepts input which provide none of the defined properties, both of the defined properties or only the billing_address. If only a credit_card is provided the validation will fail as the presence of the credit_card property depends on the presence of the billing_address.
Exceptions contain a list of all violated properties which are declared as a dependency but aren’t provided:
Missing required attributes which are dependants of 'credit_card':
- 'billing_address'
The thrown exception will be a PHPModelGenerator\Exception\Dependency\InvalidPropertyDependencyException which provides the following methods to get further error details:
// returns an array containing all missing attributes
public function getMissingAttributes(): array
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
As stated above the dependency declaration is not bidirectional. If the presence of a billing_address shall also require the credit_card property to be required the dependency has to be declared separately:
{
"type": "object",
"properties": {
"credit_card": {
"type": "integer"
},
"billing_address": {
"type": "string"
}
},
"dependencies": {
"credit_card": [
"billing_address"
],
"billing_address": [
"credit_card"
]
}
}
Schema Dependencies
Schema dependencies allow you to define a schema which must be fulfilled if a given property is present. The schema is validated against the object which holds the property, so it describes an object: an object schema, a composition schema or a reference to an object schema. A type list which includes object (e.g. ["object", "null"]) is treated as "type": "object", as the other types can never apply. A schema whose type excludes object (e.g. "type": "string") is valid JSON Schema, but no object can satisfy it, so it merely forbids the property. The generator doesn’t support this spelling and rejects it with a SchemaException during the generation; use the dependency false to forbid a property explicitly.
{
"type": "object",
"$id": "CreditCardOwner"
"properties": {
"credit_card": {
"type": "integer"
}
},
"dependencies": {
"credit_card": {
"properties": {
"billing_address": {
"type": "string"
},
"date_of_birth": {
"type": "string"
}
},
"required": [
"date_of_birth"
]
}
}
}
The properties of the dependant schema will be transferred to the base model during the model generation process. If the property which defines the dependency isn’t present they will not be required by the base model.
Generated interface:
// class CreditCardOwner
// base properties
public function setCreditCard(int $creditCard): static;
public function getCreditCard(): ?int;
// inherited properties
// the inherited properties will not be type hinted as they may contain any value if credit_card isn't present.
public function setBillingAddress($billingAddress): static;
public function getBillingAddress();
public function setDateOfBirth($dateOfBirth): static;
public function getDateOfBirth();
Hint
Basically this means your base object gets getters and setters for the additional properties transferred from the schema dependency but this getters and setters won’t perform any validation. If you require type checks and validations performed on the properties define them in your main schema as not required properties and require them as a property dependency.
The same applies to filters: a filter of a property inside the dependency schema runs inside the dependency schema (the validators of the property see the filtered value) but the base object returns the value as provided. If the base object should return the filtered value declare the property including the filter in your main schema. A property which is declared by the main schema keeps the declaration of the main schema, independent of the order of the properties.
Possible exceptions:
Invalid schema which is dependant on 'credit_card':
- Missing required value for 'date_of_birth'
The thrown exception will be a PHPModelGenerator\Exception\Dependency\InvalidSchemaDependencyException which provides the following methods to get further error details:
// Returns the exception which covers all validation errors of the dependant schema
public function getDependencyException(): Throwable
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Multiple violations against the schema dependency may be included.
Boolean dependencies
The value of a dependency can be the boolean literal true or false. A true dependency imposes nothing. A false dependency can’t be fulfilled by any object which contains the property, so the property is forbidden: an object which contains the key (also with a null value) is rejected with a PHPModelGenerator\Exception\Generic\DeniedPropertyException. A property which is also listed as required can never be provided validly and is rejected with a SchemaException during the generation.
{
"type": "object",
"properties": {
"legacy_id": {
"type": "string"
}
},
"dependencies": {
"legacy_id": false
}
}
Pattern Properties
Using the keyword patternProperties further restrictions for properties matching a pattern can be defined.
Hint
If you define constraints via patternProperties you may want to use the PatternPropertiesAccessorPostProcessor to access your pattern properties.
{
"$id": "example",
"type": "object",
"properties": {
"example": {
"type": "integer"
}
},
"patternProperties": {
"^a": {
"type": "string"
}
}
}
Possible exceptions:
If invalid pattern properties are provided a detailed exception will be thrown containing all violations:
Provided JSON for 'Example' contains invalid pattern properties
- invalid property 'a0' matching pattern '\^a'
* Invalid type for 'pattern property': requires 'string', got 'integer'
The thrown exception will be a PHPModelGenerator\Exception\Object\InvalidPatternPropertiesException which provides the following methods to get further error details:
// returns a two-dimensional array which contains all validation exceptions grouped by property names
public function getNestedExceptions(): array
// get the pattern which lead to the error
public function getPattern(): string
// get the name of the property which failed
public function getPropertyName(): string
// get the value provided to the property
public function getProvidedValue()
// get the JSON pointer to the schema keyword that rejected the value
public function getJsonPointer(): JsonPointer
Note
When a declared property’s name matches a patternProperties pattern, both the
properties schema and the patternProperties schema apply simultaneously (allOf
semantics). The generator enforces this at generation time by intersecting the two type
constraints:
If the types are compatible (e.g. the declared type is
numberand the pattern requiresinteger), the property type is narrowed to the intersection (int).If the types are contradictory (e.g. declared
string, pattern requiresinteger), aSchemaExceptionis thrown at generation time because no value can satisfy both constraints.
This also applies to properties transferred from composition branches (anyOf,
oneOf, allOf, if/then/else).
A pattern schema can also be the boolean literal true or false.
true — properties matching the pattern are accepted without restriction (useful when combining
with additionalProperties: false to be explicit about intent).
false — properties matching the pattern are forbidden. Providing any such property throws a
DeniedPropertyException.
{
"type": "object",
"patternProperties": {
"^internal_.*": false
}
}