Interface SupportsValidation<V>

Type Parameters:
V - the type of the value that the component handles
All Superinterfaces:
com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.shared.HasValidationProperties, Serializable
All Known Implementing Classes:
AbstractConfigurationDetail, AbstractIntervalField, CodeEditor, DateRangePicker, EntityComboBox, EntityPicker, FileStorageUploadField, FileUploadField, FilterConfigurationDetail, FullTextFilter, JmixBigDecimalField, JmixCheckbox, JmixCheckboxGroup, JmixComboBox, JmixEmailField, JmixIntegerField, JmixMultiSelectComboBox, JmixMultiSelectComboBoxPicker, JmixMultiValuePicker, JmixNumberField, JmixPasswordField, JmixRadioButtonGroup, JmixSelect, JmixTextArea, JmixValuePicker, JpqlFilter, LastIntervalField, MessageTemplatesFragment, NextIntervalField, PropertyFilter, RelativeDateIntervalField, SingleFilterComponentBase, Switch, TwinColumn, TypedDatePicker, TypedDateTimePicker, TypedTextField, TypedTimePicker, UiDataFilterConfigurationDetail, WebdavDocumentUploadField

public interface SupportsValidation<V> extends com.vaadin.flow.component.shared.HasValidationProperties
An interface that provides validation capabilities for components. It defines methods for adding validators, executing validation, and managing error messages and invalid states.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addValidator(Validator<? super V> validator)
    Adds a validator to the list of validators for the component.
    void
    Executes all registered validators against the current value of the component.
    default String
     
    default void
    setErrorMessage(String errorMessage)
     
    void
    setInvalid(boolean invalid)
    Sets invalid state to the field considering result of field validation.

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties

    isInvalid
  • Field Details

  • Method Details

    • addValidator

      com.vaadin.flow.shared.Registration addValidator(Validator<? super V> validator)
      Adds a validator to the list of validators for the component. The provided validator will be used to validate the value of the component during validation execution.
      Parameters:
      validator - the validator to be added; should not be null
      Returns:
      a Registration object that allows removing the added validator
    • executeValidators

      void executeValidators() throws ValidationException
      Executes all registered validators against the current value of the component. If any of the validators fail, a ValidationException is thrown to indicate the failure. The exact behavior and order of validation depend on the validators added.
      Throws:
      ValidationException - if validation fails for one or more validators
    • getErrorMessage

      @Nullable default String getErrorMessage()
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.HasValidation
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.shared.HasValidationProperties
    • setErrorMessage

      default void setErrorMessage(@Nullable String errorMessage)
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.HasValidation
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.shared.HasValidationProperties
    • setInvalid

      void setInvalid(boolean invalid)
      Sets invalid state to the field considering result of field validation.
      • Invalid - false and validation passed - false = field is invalid
      • Invalid - false and validation passed - true = field is valid
      • Invalid - true and validation passed - false = field is invalid
      • Invalid - true and validation passed - true = field is invalid
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
      Specified by:
      setInvalid in interface com.vaadin.flow.component.shared.HasValidationProperties
      Parameters:
      invalid - whether field should be invalid