public final class ValidationReport extends Object
A report is a map of Message
s, with the path into the validated
instance where the error occurred as a supplementary information.
You can retrieve messages either as a list of plain strings or JSON (either an object or an array).
JsonSchema.validate(JsonNode)
Constructor and Description |
---|
ValidationReport()
Create a new validation report with
ROOT as an instance path |
Modifier and Type | Method and Description |
---|---|
boolean |
addMessage(Message message)
Add one validation message to the report
|
void |
addMessages(Collection<Message> messages)
Add several validation messages to the report
|
JsonNode |
asJsonArray()
Return the list of validation messages as a JSON array
|
JsonNode |
asJsonObject()
Retrieve all messages as a JSON object
|
ValidationReport |
copy()
Make a copy of this validation report, with an empty message map and
the current path.
|
List<String> |
getMessages()
Get a flat list of validation messages as strings
|
JsonPointer |
getPath()
Get the current path of this report
|
boolean |
hasFatalError()
Was there a fatal error during validation?
|
boolean |
isSuccess()
Is this report a success?
|
void |
mergeWith(ValidationReport other)
Merge with another validation report
|
void |
setPath(JsonPointer path)
Set the current path of this report
|
String |
toString() |
public ValidationReport()
ROOT
as an instance pathpublic JsonPointer getPath()
public void setPath(JsonPointer path)
path
- the pathpublic boolean addMessage(Message message)
The message will be added to the already existing list of messages for
the current path (see getPath()
, setPath(JsonPointer)
).
message
- the messagefatal
is
already true
public void addMessages(Collection<Message> messages)
messages
- the collection of messagespublic boolean isSuccess()
public boolean hasFatalError()
This implementation currently considers that all URI resolution failures are fatal errors.
public void mergeWith(ValidationReport other)
Note that if a fatal error has been encountered, only the message describing this fatal error will make it into the report. Other messages are discarded.
other
- the report to merge withpublic ValidationReport copy()
public List<String> getMessages()
One message has the form:
"/pointer/here": message here
The list is sorted by pointer.
public JsonNode asJsonObject()
The retrieved JSON document is an object where:
JsonPointer
s,Note: the returned JsonNode
is mutable.
Message.toJsonNode()
public JsonNode asJsonArray()
This method makes its best to order validation messages correctly.
Each message in the resulting array is a JSON object, with the
contents of the Message
and with an added member named path
, which contains the path into the instance where the error has
occurred (as a JsonPointer
).
Message.toJsonNode()
Copyright © 2013. All Rights Reserved.