Skip to content

Commit 91ed23e

Browse files
committed
Merge pull request #79 from schmeiserd/master
fixed "empty array"-bug
2 parents dea4e26 + 6bf0956 commit 91ed23e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/JsonSchema/Constraints/Collection.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ protected function validateItems($value, $schema = null, $path = null, $i = null
101101
}
102102
}
103103

104-
// Treat when we have more schema definitions than values
105-
for ($k = count($value); $k < count($schema->items); $k++) {
106-
$this->checkUndefined(new Undefined(), $schema->items[$k], $path, $k);
104+
// Treat when we have more schema definitions than values, not for empty arrays
105+
if(count($value) > 0) {
106+
for ($k = count($value); $k < count($schema->items); $k++) {
107+
$this->checkUndefined(new Undefined(), $schema->items[$k], $path, $k);
108+
}
107109
}
108110
}
109111
}

0 commit comments

Comments
 (0)