Interface Validatable

All Superinterfaces:
Serializable
All Known Subinterfaces:
BufferedValidatable, FAbstractTextField, Field<T>, HasFInternalValue<T>, Select
All Known Implementing Classes:
AbstractField, CustomField, FAbstractField, FAbstractSelect, FCheckBox, FComboBox, FDateField, FListSelect, FPasswordField, FTextArea, FTextField, FTokenField, FTwinColSelect, Table

public interface Validatable extends Serializable

Interface for validatable objects. Defines methods to verify if the object's value is valid or not, and to add, remove and list registered validators of the object.

Since:
3.0
Author:
Vaadin Ltd.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a new validator for this object.
    Returns a collection of all validators currently registered for the object.
    boolean
    Checks the validabtable object accept invalid values.The default value is true.
    boolean
    Tests the current value of the object against all registered validators.
    void
    Removes all validators from this object, as if removeValidator was called for each registered validator.
    void
    Removes a previously registered validator from the object.
    void
    setInvalidAllowed(boolean invalidValueAllowed)
    Should the validabtable object accept invalid values.
    void
    Checks the validity of the validatable.
  • Method Details

    • addValidator

      void addValidator(Validator validator)

      Adds a new validator for this object. The validator's Validator.validate(Object) method is activated every time the object's value needs to be verified, that is, when the isValid() method is called. This usually happens when the object's value changes.

      Parameters:
      validator - the new validator
    • removeValidator

      void removeValidator(Validator validator)

      Removes a previously registered validator from the object. The specified validator is removed from the object and its validate method is no longer called in isValid().

      Parameters:
      validator - the validator to remove
    • removeAllValidators

      void removeAllValidators()
      Removes all validators from this object, as if removeValidator was called for each registered validator.
    • getValidators

      Collection<Validator> getValidators()

      Returns a collection of all validators currently registered for the object. The collection may be immutable. Calling removeValidator for this Validatable while iterating over the collection may be unsafe (e.g. may throw ConcurrentModificationException.)

      Returns:
      A collection of validators
    • isValid

      boolean isValid()

      Tests the current value of the object against all registered validators. The registered validators are iterated and for each the Validator.validate(Object) method is called. If any validator throws the Validator.InvalidValueException this method returns false.

      Returns:
      true if the registered validators concur that the value is valid, false otherwise
    • validate

      void validate() throws Validator.InvalidValueException

      Checks the validity of the validatable. If the validatable is valid this method should do nothing, and if it's not valid, it should throw Validator.InvalidValueException

      Throws:
      Validator.InvalidValueException - if the value is not valid
    • isInvalidAllowed

      boolean isInvalidAllowed()

      Checks the validabtable object accept invalid values.The default value is true.

    • setInvalidAllowed

      void setInvalidAllowed(boolean invalidValueAllowed) throws UnsupportedOperationException

      Should the validabtable object accept invalid values. Supporting this configuration possibility is optional. By default invalid values are allowed.

      Parameters:
      invalidValueAllowed -
      Throws:
      UnsupportedOperationException - if the setInvalidAllowed is not supported.