/** Method from the external library which prints the report. */ protected static void printReport(final ValidationReport report) throws IOException { final boolean success = report.isSuccess(); System.out.println("Validation " + (success ? "succeeded" : "failed")); if (!success) { System.out.println("---- BEGIN REPORT ----"); System.out.println(WRITER.writeValueAsString(report.asJsonObject())); System.out.println("---- END REPORT ----"); } }
@Override protected void validate( final ValidationContext context, final ValidationReport report, final JsonNode instance) { if (!uniqueItems) return; final Set<JsonNode> set = Sets.newHashSet(); for (final JsonNode element : instance) if (!set.add(element)) { final Message.Builder msg = newMsg().setMessage("duplicate elements in array"); report.addMessage(msg.build()); return; } }