Package org.spincast.core.validation
Interface ValidationSet
- All Known Subinterfaces:
Form
- All Known Implementing Classes:
FormDefault
,ValidationSetSimple
public interface ValidationSet
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates and adds a new Error validation Message.void
addError
(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) 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, ValidationLevel messageLevel, String code, String text, ValidationHtmlEscapeType htmlEscapeType) 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
addSuccess
(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new Success validation Message.void
addWarning
(String validationKey, String code, String text) Creates and adds a new Warning validation Message.)void
addWarning
(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new Warning validation Message.)void
Removes all previously added messages and reset the validation status.Creates a newValidationSet
.Gets the validation keys and their associated messages.getMessages
(String validationKey) Gets the validation messages for the specified key.getMessagesFormatted
(String validationKey, ValidationMessageFormatType formatType) Quick way to get a formatted version of the validation messages for the specified key.getMessagesFormatted
(ValidationMessageFormatType formatType) Quick way to get a formatted version of all validation messages.TheJsonObject
in which the validation messages are actually stored.boolean
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()
Returnstrue
if the validation set contains at least one ERROR message.boolean
Returnstrue
if the validation set for the element at the specified key contains at least one ERROR message.boolean
Returnstrue
if the validation set only contains SUCCESS messages (or contains no messages at all).boolean
Returnstrue
if the validation set for the element at the specified key only contains SUCCESS messages (or contains no messages at all).boolean
isValid()
Returnstrue
if the validation set does not contain ERROR messages.boolean
Returnstrue
if the validation set for the elements at the specified keys dont not contain ERROR messages.boolean
Returnstrue
if the validation set contains at least one WARNING message, but no ERROR messages.boolean
Returnstrue
if the validation set for the element at the specified key contains at least one WARNING message, but no ERROR messages.mergeValidationSet
(String validationKeyPrefix, ValidationSet validationSet) Merges anotherValidationSet
and prefixes all the validation keys of this set using thevalidationKeyPrefix
.mergeValidationSet
(ValidationSet validationSet) Merges anotherValidationSet
.int
size()
The number of validation messages in this set.
-
Method Details
-
addMessage
Adds a new validation Message to this set, using the specified validation key. -
addMessage
Creates and adds a new validation Message.Escapes the message in
<pre>
tags if displayed in HTML. -
addMessage
void addMessage(String validationKey, ValidationLevel messageLevel, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new validation Message.- Parameters:
htmlEscape
- if this message if displayed usingHTML
, how should it be escaped?
-
addError
Creates and adds a new Error validation Message.Escapes the message in
<pre>
tags if displayed in HTML. -
addError
void addError(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new Error validation Message.- Parameters:
htmlEscape
- if this message if displayed usingHTML
, should should it be escaped?
-
addWarning
Creates and adds a new Warning validation Message.)Escapes the message in
<pre>
tags if displayed in HTML. -
addWarning
void addWarning(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new Warning validation Message.)- Parameters:
htmlEscape
- if this message if displayed usingHTML
, should should it be escaped?
-
addSuccess
Creates and adds a new Success validation Message.Escapes the message in
<pre>
tags if displayed in HTML. -
addSuccess
void addSuccess(String validationKey, String code, String text, ValidationHtmlEscapeType htmlEscapeType) Creates and adds a new Success validation Message.- Parameters:
htmlEscapeType
- if this message if displayed usingHTML
, should should it be escaped?
-
hasMessages
boolean hasMessages()Does this validation set contain any validation Messages? -
hasMessages
Does the the element at the specified key contains validation Messages? -
isWarning
boolean isWarning()Returnstrue
if the validation set contains at least one WARNING message, but no ERROR messages. -
isWarning
Returnstrue
if the validation set for the element at the specified key contains at least one WARNING message, but no ERROR messages. -
isSuccess
boolean isSuccess()Returnstrue
if the validation set only contains SUCCESS messages (or contains no messages at all). -
isSuccess
Returnstrue
if the validation set for the element at the specified key only contains SUCCESS messages (or contains no messages at all). -
isError
boolean isError()Returnstrue
if the validation set contains at least one ERROR message. -
isError
Returnstrue
if the validation set for the element at the specified key contains at least one ERROR message. -
isValid
boolean isValid()Returnstrue
if the validation set does not contain ERROR messages. The set may contain WARNING messages.This is a synonym of
!isError()
. -
isValid
Returnstrue
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()
. -
getMessages
Map<String,List<ValidationMessage>> getMessages()Gets the validation keys and their associated messages.The Map and the lists are immutable.
-
getMessages
Gets the validation messages for the specified key.The list is immutable.
-
getMessagesFormatted
Quick way to get a formatted version of the validation messages for the specified key.- Parameters:
key
- The key to get messages for.formatType
- The type of output for the messages (Text, HTML, Json or XML).- Returns:
- the formatted messages or
null
if there are no validation messages.
-
getMessagesFormatted
Quick way to get a formatted version of all validation messages.- Parameters:
formatType
- The type of output for the messages (Text, HTML, Json or XML).- Returns:
- the formatted messages or
null
if there are no validation messages.
-
createNewValidationSet
ValidationSet createNewValidationSet()Creates a newValidationSet
. -
mergeValidationSet
Merges anotherValidationSet
.- Returns:
- this, fluent-style.
-
mergeValidationSet
Merges anotherValidationSet
and prefixes all the validation keys of this set using thevalidationKeyPrefix
.- Returns:
- this, fluent-style.
-
size
int size()The number of validation messages in this set. -
getValidationResultAsJsonObject
JsonObject getValidationResultAsJsonObject()TheJsonObject
in which the validation messages are actually stored.You can use this object to return the validation result as json, in a response.
-
clearAllValidation
void clearAllValidation()Removes all previously added messages and reset the validation status.
-