From 6bf095614a373c009a9e5012242027fbbde353e8 Mon Sep 17 00:00:00 2001 From: "dominik.schmeiser" Date: Tue, 5 Nov 2013 09:55:35 +0100 Subject: [PATCH] fixed "empty array"-bug --- src/JsonSchema/Constraints/Collection.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/JsonSchema/Constraints/Collection.php b/src/JsonSchema/Constraints/Collection.php index 4ca8e1b3..079617c4 100644 --- a/src/JsonSchema/Constraints/Collection.php +++ b/src/JsonSchema/Constraints/Collection.php @@ -101,9 +101,11 @@ protected function validateItems($value, $schema = null, $path = null, $i = null } } - // Treat when we have more schema definitions than values - for ($k = count($value); $k < count($schema->items); $k++) { - $this->checkUndefined(new Undefined(), $schema->items[$k], $path, $k); + // Treat when we have more schema definitions than values, not for empty arrays + if(count($value) > 0) { + for ($k = count($value); $k < count($schema->items); $k++) { + $this->checkUndefined(new Undefined(), $schema->items[$k], $path, $k); + } } } }