Class ValidationUtil


  • public class ValidationUtil
    extends Object
    Util methods for component validation
    • Method Detail

      • checkRequired

        public static <V> com.vaadin.flow.data.binder.ValidationResult checkRequired​(boolean required,
                                                                                     V value,
                                                                                     V emptyValue)
        Checks the required validation constraint
        Type Parameters:
        V - the type of the component value
        Parameters:
        required - the required state of the component
        value - the current value set on the component
        emptyValue - the empty value for the component
        Returns:
        Validation.ok() if the validation passes, Validation.error() otherwise
      • checkGreaterThanMax

        public static <V extends Comparable<V>> com.vaadin.flow.data.binder.ValidationResult checkGreaterThanMax​(V value,
                                                                                                                 V maxValue)
        Checks if the value being set to the component is greater than the max value defined
        Type Parameters:
        V - the type of the component value
        Parameters:
        value - the current value set on the component
        maxValue - the max value set on the component
        Returns:
        Validation.ok() if the validation passes, Validation.error() otherwise
      • checkSmallerThanMin

        public static <V extends Comparable<V>> com.vaadin.flow.data.binder.ValidationResult checkSmallerThanMin​(V value,
                                                                                                                 V minValue)
        Checks if the value being set to the component is smaller than the max value defined
        Type Parameters:
        V - the type of the component value
        Parameters:
        value - the current value set on the component
        minValue - the min value set on the component
        Returns:
        Validation.ok() if the validation passes, Validation.error() otherwise