Skip to content

Commit cafb390

Browse files
committed
fix: allow items: true to pass validation
1 parent bb68276 commit cafb390

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/JsonSchema/Constraints/CollectionConstraint.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
6565
*/
6666
protected function validateItems(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
6767
{
68+
if (is_bool($schema->items) && $schema->items === true) {
69+
return;
70+
}
71+
6872
if (is_object($schema->items)) {
6973
// just one type definition for the whole array
7074
foreach ($value as $k => &$v) {

tests/Constraints/ArraysTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,17 @@ public function getValidTests(): array
271271
}
272272
}
273273
}'
274-
]
274+
],
275+
'items: true passes validation' => [
276+
'input' => <<<JSON
277+
[1, 1.2, "12"]
278+
JSON
279+
,
280+
'schema' => <<<JSON
281+
{ "type": "array", "items": true }
282+
JSON
283+
,
284+
],
275285
];
276286
}
277287
}

0 commit comments

Comments
 (0)