Class ValidationUtil

java.lang.Object
com.vaadin.flow.component.shared.ValidationUtil

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

    • checkRequired

      public static <V> 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>> 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>> 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