public interface ValidationSet
| Modifier and Type | Method and Description |
|---|---|
void |
addError(String validationKey,
String code,
String text)
Creates and adds a new Error validation Message.
|
void |
addMessage(String validationKey,
ValidationLevel messageLevel,
String code,
String text)
Creates and adds a new validation Message.
|
void |
addMessage(String validationKey,
ValidationMessage validationMessage)
Adds a new validation Message to this set, using the
specified validation key.
|
void |
addSuccess(String validationKey,
String code,
String text)
Creates and adds a new Success validation Message.
|
void |
addWarning(String validationKey,
String code,
String text)
Creates and adds a new Warning validation Message.)
|
ValidationSet |
createNewValidationSet()
Creates a new
ValidationSet. |
Map<String,List<ValidationMessage>> |
getMessages()
Gets the validation keys and their
associated messages.
|
List<ValidationMessage> |
getMessages(String validationKey)
Gets the validation messages for the specified key.
|
String |
getMessagesFormatted(String validationKey,
ValidationMessageFormatType formatType)
Quick way to get a formatted version of the validation
messages for the specified key.
|
String |
getMessagesFormatted(ValidationMessageFormatType formatType)
Quick way to get a formatted version of all validation
messages.
|
JsonObject |
getValidationResultAsJsonObject()
The
JsonObject in which the validation messages
are actually stored. |
boolean |
hasMessages()
Does this validation set contain any validation
Messages?
|
boolean |
hasMessages(String validationKey)
Does the the element at the specified key
contains validation Messages?
|
boolean |
isError()
Returns
true if the validation set
contains at least one ERROR message. |
boolean |
isError(String validationKey)
Returns
true if the validation set
for the element at the specified key contains
at least one ERROR message. |
boolean |
isSuccess()
Returns
true if the validation set
only contains SUCCESS messages
(or contains no messages at all). |
boolean |
isSuccess(String validationKey)
Returns
true if the validation set
for the element at the specified key only contains
SUCCESS messages
(or contains no messages at all). |
boolean |
isValid()
Returns
true if the validation set
does not contain ERROR messages. |
boolean |
isValid(String... validationKey)
Returns
true if the validation set
for the elements at the specified keys
dont not contain ERROR messages. |
boolean |
isWarning()
Returns
true if the validation set
contains at least one WARNING message, but no
ERROR messages. |
boolean |
isWarning(String validationKey)
Returns
true if the validation set
for the element at the specified key contains at
least one WARNING message, but no
ERROR messages. |
ValidationSet |
mergeValidationSet(String validationKeyPrefix,
ValidationSet validationSet)
Merges another
ValidationSet and prefixes all the
validation keys of this set using the
validationKeyPrefix. |
ValidationSet |
mergeValidationSet(ValidationSet validationSet)
Merges another
ValidationSet. |
int |
size()
The number of validation messages in this set.
|
void addMessage(String validationKey, ValidationMessage validationMessage)
void addMessage(String validationKey, ValidationLevel messageLevel, String code, String text)
void addError(String validationKey, String code, String text)
void addWarning(String validationKey, String code, String text)
void addSuccess(String validationKey, String code, String text)
boolean hasMessages()
boolean hasMessages(String validationKey)
boolean isWarning()
true if the validation set
contains at least one WARNING message, but no
ERROR messages.boolean isWarning(String validationKey)
true if the validation set
for the element at the specified key contains at
least one WARNING message, but no
ERROR messages.boolean isSuccess()
true if the validation set
only contains SUCCESS messages
(or contains no messages at all).boolean isSuccess(String validationKey)
true if the validation set
for the element at the specified key only contains
SUCCESS messages
(or contains no messages at all).boolean isError()
true if the validation set
contains at least one ERROR message.boolean isError(String validationKey)
true if the validation set
for the element at the specified key contains
at least one ERROR message.boolean isValid()
true if the validation set
does not contain ERROR messages.
The set may contain
WARNING messages.
This is a synonym of !isError().
boolean isValid(String... validationKey)
true if the validation set
for the elements at the specified keys
dont not contain ERROR messages.
The elements may contains WARNING messages.
If no keys are passed, then all keys
must be valid (synonym of isValid().
Map<String,List<ValidationMessage>> getMessages()
The Map and the lists are immutable.
List<ValidationMessage> getMessages(String validationKey)
The list is immutable.
String getMessagesFormatted(String validationKey, ValidationMessageFormatType formatType)
key - The key to get messages for.formatType - The type of output for the messages (Text, HTML, Json or XML).null if
there are no validation messages.String getMessagesFormatted(ValidationMessageFormatType formatType)
formatType - The type of output for the messages (Text, HTML, Json or XML).null if
there are no validation messages.ValidationSet createNewValidationSet()
ValidationSet.ValidationSet mergeValidationSet(ValidationSet validationSet)
ValidationSet.ValidationSet mergeValidationSet(String validationKeyPrefix, ValidationSet validationSet)
ValidationSet and prefixes all the
validation keys of this set using the
validationKeyPrefix.int size()
JsonObject getValidationResultAsJsonObject()
JsonObject in which the validation messages
are actually stored.
You can use this object to return the validation result as json, in a response.
Copyright © 2018. All rights reserved.