Package com.vaadin.flow.data.binder
Interface ValidationResult
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ValidationResult.SimpleValidationResult
Represents the result of a validation. A result may be either successful or
contain an error message in case of a failure.
ValidationResult instances are created using the factory methods
ok() and error(String), denoting success and failure
respectively.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSimple validation result implementation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValidationResultcreate(String errorMessage, ErrorLevel errorLevel) Creates the validation result with the givenerrorMessageanderrorLevel.static ValidationResultCreates the validation result which represent an error with the givenerrorMessage.Returns optional error level for this validation result.Returns the result message.default booleanisError()Checks if the result denotes an error.static ValidationResultok()Returns a successful result.
-
Method Details
-
getErrorMessage
String getErrorMessage()Returns the result message.Throws an
IllegalStateExceptionif the result represents success.- Returns:
- the error message
- Throws:
IllegalStateException- if the result represents success
-
getErrorLevel
Optional<ErrorLevel> getErrorLevel()Returns optional error level for this validation result. Error level is not present for successful validation results.Note: By default
ErrorLevel.INFOandErrorLevel.WARNINGare not considered to be blocking the validation and conversion chain.- Returns:
- optional error level; error level is present for validation results that have not passed validation
- See Also:
-
isError
default boolean isError()Checks if the result denotes an error.Note: By default
ErrorLevel.INFOandErrorLevel.WARNINGare not considered to be errors.- Returns:
trueif the result denotes an error,falseotherwise
-
ok
Returns a successful result.- Returns:
- the successful result
-
error
Creates the validation result which represent an error with the givenerrorMessage.- Parameters:
errorMessage- error message, notnull- Returns:
- validation result which represent an error with the given
errorMessage - Throws:
NullPointerException- iferrorMessageis null
-
create
Creates the validation result with the givenerrorMessageanderrorLevel. Results withErrorLevelofINFOorWARNINGare not errors by default.- Parameters:
errorMessage- error message, notnullerrorLevel- error level, notnull- Returns:
- validation result with the given
errorMessageanderrorLevel - Throws:
NullPointerException- iferrorMessageorerrorLevelisnull- See Also:
-