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() and error(String), denoting success and failure respectively.

    Since:
    1.0
    Author:
    Vaadin Ltd
    • Method Detail

      • 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 and ErrorLevel.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()
      • isError

        default boolean isError()
        Checks if the result denotes an error.

        Note: By default ErrorLevel.INFO and ErrorLevel.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 given errorMessage.
        Parameters:
        errorMessage - error message, not null
        Returns:
        validation result which represent an error with the given errorMessage
        Throws:
        NullPointerException - if errorMessage is null
      • create

        static ValidationResult create​(String errorMessage,
                                       ErrorLevel errorLevel)
        Creates the validation result with the given errorMessage and errorLevel. Results with ErrorLevel of INFO or WARNING are not errors by default.
        Parameters:
        errorMessage - error message, not null
        errorLevel - error level, not null
        Returns:
        validation result with the given errorMessage and errorLevel
        Throws:
        NullPointerException - if errorMessage or errorLevel is null
        See Also:
        ok(), error(String)