|
|
@@ -2,8 +2,11 @@ package org.leumasjaffe.json.schema.tester;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import org.leumasjaffe.container.EitherStream;
|
|
|
import org.leumasjaffe.json.schema.Tester;
|
|
|
+import org.leumasjaffe.json.schema.ValidationException;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
|
@@ -19,6 +22,17 @@ public class AnyOfTester implements Tester {
|
|
|
public AnyOfTester(Tester...testers) {
|
|
|
this(Arrays.asList(testers));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void validate(JsonNode node) throws ValidationException {
|
|
|
+ final List<ValidationException> exceptions = EitherStream.from(children)
|
|
|
+ .flatMap(t -> t.validate(node), ValidationException.class)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (exceptions.size() == children.size()) {
|
|
|
+ throw new ValidationException("anyOf", "JSON node failed every sub-schema",
|
|
|
+ exceptions);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public boolean accepts(JsonNode node) {
|