Closed as not planned
Description
Hi,
It seems that the default values don't get applied to objects inside of an array.
It looks like that only the top level object gets their default values applied.
The validation in the sub-object does work (like type checking and required fields).
I'm running version 5.2.0
Example:
I expect the 'test' property to be filled with the default value if not present.
$data = [
(object)[
"key" => 1,
"test" => 1
],(object)[
"key" => 1,
]
];
$validator = new \JsonSchema\Validator();
var_dump($validator->validate(
$data,
json_decode('
{
"type": "array",
"items": [
{
"type": "object",
"properties": {
"key": {
"type": "integer"
},
"test": {
"type": "integer",
"default": 0
}
},
"required": [
"key"
]
}
]
}
'), \JsonSchema\Constraints\Constraint::CHECK_MODE_APPLY_DEFAULTS
));
var_dump($data);
Gives:
int(0)
array(2) {
[0]=>
object(stdClass)#3 (2) {
["key"]=>
int(1)
["test"]=>
int(1)
}
[1]=>
object(stdClass)#2 (1) {
["key"]=>
int(1)
}
}
Metadata
Metadata
Assignees
Labels
No labels