- All Superinterfaces:
Composable<ValidationResult>,Iterable<ValidationResult>,Localizable,LocalizableObject
- All Known Implementing Classes:
AbstractValidationResult,ComposedValidationFailure,ValidationFailure,ValidationResultValid
Result of a
validation. If valid is true, the
message is null. Otherwise the message shall be filled and explain the reason of the
failure in a understandable but short form to end-users. Examples are "Value may not be blank." or "Value has to be
in the range from 5 to 9.". Depending on the usage the message may also
contain additional context information in order to determine the source of the problem.- Since:
- 1.0.0
-
Field Summary
Fields inherited from interface io.github.mmm.base.i18n.Localizable
BUNDLE_PREFIX -
Method Summary
Modifier and TypeMethodDescriptionadd(ValidationResult result) default booleancontainsCode(String code) getCode()default StringgetLocalizedMessage(boolean verbose) This method gets the resolved and localized message.default StringgetLocalizedMessage(Locale locale, boolean verbose) This method gets the resolved and localized message.default voidgetLocalizedMessage(Locale locale, Appendable buffer) voidgetLocalizedMessage(Locale locale, Appendable buffer, boolean verbose) default Stringdefault StringgetMessage(boolean verbose) default booleanisValid()Methods inherited from interface io.github.mmm.base.lang.Composable
getChild, getChildCount, iteratorMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface io.github.mmm.base.i18n.Localizable
getArgument, getLocalizedMessage, getLocalizedMessage, toLocalizable
-
Method Details
-
isValid
default boolean isValid()- Returns:
trueif the validation was successful,falseotherwise. A successfulValidationResultis always empty. All other methods will not return any resonable result.
-
getSource
String getSource()- Returns:
- the optional
validation sourcedescribing the origin of thevaluethat has been validated. May benull. If present this may be the filename where the value was read from, an XPath where the value was located in an XML document, the label of a widget of the UI containing the value, etc. This will help to find the problem easier.
-
getCode
String getCode()- Returns:
- the failure code or
nullifvalid. For a singleValidationFailurethis will be theIDof the failingValidator. The code is a stable identifier that indicates the type of the failure. It can be used for automated testing in order to make the test-cases independent from the actual message texts so they are maintainable and will not break e.g. if typos are fixed in the messages. - See Also:
-
getMessage
- Specified by:
getMessagein interfaceLocalizable- See Also:
-
getMessage
- Parameters:
verbose-- Returns:
- the localized message.
- See Also:
-
getLocalizedMessage
This method gets the resolved and localized message.- Parameters:
verbose- the verbose flag (to includecode(s), etc.- Returns:
- the localized message.
-
getLocalizedMessage
This method gets the resolved and localized message. -
getLocalizedMessage
- Specified by:
getLocalizedMessagein interfaceLocalizable- See Also:
-
getLocalizedMessage
- Parameters:
locale- is theLocaleto translate to.buffer- theAppendablewhere towritethe message to.verbose- the verbose flag (to includecode(s), etc.- See Also:
-
add
- Parameters:
result- anotherValidationResultto combine with this one.- Returns:
- the
ValidationResultcomposed out of this with the givenresult. - See Also:
-
containsCode
- Parameters:
code- thecodeto check for.- Returns:
trueif thisValidationResultitselfhasthe givencodeor recursivelycontainssuchValidationResults,falseotherwise.
-