Skip to content

Commit a2f520f

Browse files
author
Anderson Ferreira
committed
#214 - Fix conditional of validation (if-then-else)
1 parent c0f288a commit a2f520f

File tree

5 files changed

+1
-447
lines changed

5 files changed

+1
-447
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
5454
Set<ValidationMessage> ifErrors = ifSchema.validate(node, rootNode, at);
5555
if (ifErrors.isEmpty() && thenSchema != null) {
5656
errors.addAll(thenSchema.validate(node, rootNode, at));
57-
} else if (thenSchema != null && elseSchema != null) {
57+
} else if (!ifErrors.isEmpty() && elseSchema != null) {
5858
errors.addAll(elseSchema.validate(node, rootNode, at));
5959
}
6060

src/test/java/com/networknt/schema/V201909JsonSchemaTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,6 @@ public void testFormatValidator() throws Exception {
309309
}
310310

311311
@Test
312-
public void testIfValidator() throws Exception {
313-
runTestFile("draft2019-09/if.json");
314-
}
315-
316-
@Test
317-
@Ignore
318312
public void testIfThenElseValidator() throws Exception {
319313
runTestFile("draft2019-09/if-then-else.json");
320314
}

src/test/java/com/networknt/schema/V7JsonSchemaTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,6 @@ public void testFormatValidator() throws Exception {
305305
}
306306

307307
@Test
308-
public void testIfValidator() throws Exception {
309-
runTestFile("draft7/if.json");
310-
}
311-
312-
@Test
313-
@Ignore
314308
public void testIfThenElseValidator() throws Exception {
315309
runTestFile("draft7/if-then-else.json");
316310
}

src/test/resources/draft2019-09/if.json

Lines changed: 0 additions & 217 deletions
This file was deleted.

0 commit comments

Comments
 (0)