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 classValidationResult.SimpleValidationResult
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ValidationResultcreate(String errorMessage, ErrorLevel errorLevel)Creates the validation result with the givenerrorMessageanderrorLevel.static ValidationResulterror(String errorMessage)Creates the validation result which represent an error with the givenerrorMessage.Optional<ErrorLevel>getErrorLevel()Returns optional error level for this validation result.StringgetErrorMessage()Returns the result message.default booleanisError()Checks if the result denotes an error.static ValidationResultok()Returns a successful result.
-
-
-
Method Detail
-
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
- Since:
- 8.2
- See Also:
isError()
-
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
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- iferrorMessageis null
-
create
static ValidationResult create(String errorMessage, ErrorLevel errorLevel)
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- Since:
- 8.2
- See Also:
ok(),error(String)
-
-