public final class ValidationReport extends Object
Internally, it uses a ListMultimap where:
JsonPointers),
ValidationMessages.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(ValidationMessage message)
Add one validation message to the report
|
void |
addMessages(Collection<ValidationMessage> messages)
Add several validation messages to the report
|
JsonNode |
asJsonArray()
Return the list of validation messages as a JSON array
|
JsonNode |
asJsonNode()
Deprecated.
use
asJsonObject() instead |
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
|
JsonPointer |
getPath()
Get the current path of this report
|
boolean |
hasFatalError() |
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
|
int |
size() |
String |
toString() |
public ValidationReport()
ROOT as an instance pathpublic JsonPointer getPath()
public void setPath(JsonPointer path)
path - the pathpublic boolean addMessage(ValidationMessage message)
message - the messagefatal is
already truepublic void addMessages(Collection<ValidationMessage> messages)
messages - the collection of messagespublic int size()
public boolean isSuccess()
public boolean hasFatalError()
public void mergeWith(ValidationReport other)
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:
JsonPointers,Note: the returned JsonNode is mutable.
ValidationMessage.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 ValidationMessage and with an added member named
path, which contains the path into the instance where the error
has occurred (as a JsonPointer).
ValidationMessage.toJsonNode()@Deprecated public JsonNode asJsonNode()
asJsonObject() insteadJsonNode
The retrieved JSON document is an object where:
JsonPointers,ValidationMessage.toJsonNode()Copyright © 2012. All Rights Reserved.