Package com.vaadin.data
Interface ValidationResult
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ValidationResult.SimpleValidationResult
public interface ValidationResult extends Serializable
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()
anderror(String)
, denoting success and failure respectively.- Since:
- 8.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ValidationResult.SimpleValidationResult
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ValidationResult
create(String errorMessage, ErrorLevel errorLevel)
Creates the validation result with the givenerrorMessage
anderrorLevel
.static ValidationResult
error(String errorMessage)
Creates the validation result which represent an error with the givenerrorMessage
.Optional<ErrorLevel>
getErrorLevel()
Returns optional error level for this validation result.String
getErrorMessage()
Returns the result message.default boolean
isError()
Checks if the result denotes an error.static ValidationResult
ok()
Returns a successful result.
-
-
-
Method Detail
-
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
- Since:
- 8.2
- See Also:
isError()
-
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
static ValidationResult ok()
Returns a successful result.- Returns:
- the successful result
-
error
static ValidationResult error(String errorMessage)
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
static ValidationResult create(String errorMessage, ErrorLevel errorLevel)
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
- Since:
- 8.2
- See Also:
ok()
,error(String)
-
-