com.vaadin.flow.component.

Interface HasValidation

    • Method Summary

      All Methods
      Modifier and Type Method and Description
      String getErrorMessage()

      Gets current error message from the component.

      boolean isInvalid()

      Returns true if component input is invalid, false otherwise.

      void setErrorMessage(String errorMessage)

      Sets an error message to the component.

      void setInvalid(boolean invalid)

      Sets the validity of the component input.

    • Method Detail

      • setErrorMessage

        void setErrorMessage(String errorMessage)

        Sets an error message to the component.

        The Web Component is responsible for deciding when to show the error message to the user, and this is usually triggered by triggering the invalid state for the Web Component. Which means that there is no need to clean up the message when component becomes valid (otherwise it may lead to undesired visual effects).

        Parameters:

        errorMessage - a new error message

      • getErrorMessage

        String getErrorMessage()

        Gets current error message from the component.

        Returns:

        current error message

      • setInvalid

        void setInvalid(boolean invalid)

        Sets the validity of the component input.

        When component becomes valid it hides the error message by itself, so there is no need to clean up the error message via the setErrorMessage(String) call.

        Parameters:

        invalid - new value for component input validity

      • isInvalid

        boolean isInvalid()

        Returns true if component input is invalid, false otherwise.

        Returns:

        whether the component input is valid