Skip to content

Commit 0251e2a

Browse files
authored
Merge pull request #93 from networknt/fix/support-nullable-fields
Adding support for nullable fields
2 parents b7d78f5 + 228d117 commit 0251e2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/networknt/schema/TypeValidator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
5555
if (schemaType == JsonType.NUMBER && nodeType == JsonType.INTEGER) {
5656
return Collections.emptySet();
5757
}
58+
if (nodeType == JsonType.NULL) {
59+
JsonNode nullable = this.getParentSchema().getSchemaNode().get("nullable");
60+
if (nullable != null && nullable.asBoolean()) {
61+
return Collections.emptySet();
62+
}
63+
}
5864

5965
return Collections.singleton(buildValidationMessage(at, nodeType.toString(), schemaType.toString()));
6066
}

0 commit comments

Comments
 (0)