Skip to content

Commit

Permalink
Merge pull request #374 from zgyorffi/fix_nullpointer_if_no_items_schema
Browse files Browse the repository at this point in the history
Skip validation of elements in array against additionalItems schema i…
  • Loading branch information
erosb authored Jul 7, 2020
2 parents a8dc686 + 56bd409 commit fd33c26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ArraySchemaValidatingVisitor(Object subject, ValidatingVisitor owner) {
}

@Override void visitSchemaOfAdditionalItems(Schema schemaOfAdditionalItems) {
if (schemaOfAdditionalItems == null) {
if (schemaOfAdditionalItems == null || arraySchema.getItemSchemas() == null) {
return;
}
int validationFrom = Math.min(subjectLength, arraySchema.getItemSchemas().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public void additionalItemsSchema() {
.build().validate(ARRAYS.get("additionalItemsSchema"));
}

@Test
public void ignoreAdditionalItemsIfNoItemsSchema() {
ArraySchema.builder()
.schemaOfAdditionalItems(FalseSchema.INSTANCE)
.build().validate(ARRAYS.get("noItemSchema"));
}

@Test
public void additionalItemsSchemaFailure() {
NullSchema nullSchema = buildWithLocation(NullSchema.builder());
Expand Down

0 comments on commit fd33c26

Please sign in to comment.