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
Modifier and TypeInterfaceDescriptionstatic class
Simple validation result implementation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValidationResult
create
(String errorMessage, ErrorLevel errorLevel) Creates the validation result with the givenerrorMessage
anderrorLevel
.static ValidationResult
Creates the validation result which represent an error with the givenerrorMessage
.Returns optional error level for this validation result.Returns the result message.default boolean
isError()
Checks if the result denotes an error.static ValidationResult
ok()
Returns a successful result.
-
Method Details
-
getErrorMessage
String getErrorMessage()Returns the result message.Throws an
IllegalStateException
if 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.INFO
andErrorLevel.WARNING
are 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.INFO
andErrorLevel.WARNING
are not considered to be errors.- Returns:
true
if the result denotes an error,false
otherwise
-
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
- iferrorMessage
is null
-
create
Creates the validation result with the givenerrorMessage
anderrorLevel
. Results withErrorLevel
ofINFO
orWARNING
are not errors by default.- Parameters:
errorMessage
- error message, notnull
errorLevel
- error level, notnull
- Returns:
- validation result with the given
errorMessage
anderrorLevel
- Throws:
NullPointerException
- iferrorMessage
orerrorLevel
isnull
- See Also:
-