Class SelectionLengthValidator<E>

java.lang.Object
com.dlsc.formsfx.model.validators.CustomValidator<javafx.collections.ObservableList<E>>
com.dlsc.formsfx.model.validators.SelectionLengthValidator<E>
All Implemented Interfaces:
Validator<javafx.collections.ObservableList<E>>

public class SelectionLengthValidator<E>
extends CustomValidator<javafx.collections.ObservableList<E>>
A SelectionLengthValidator checks if a selection list's length is between a minimum and a maximum value.
Author:
Sacha Schmid, Rinesch Murugathas
  • Method Details

    • between

      public static <T> SelectionLengthValidator<T> between​(int min, int max, String errorMessage)
      Creates an SelectionLengthValidator with given lower and upper bounds.
      Parameters:
      min - The lower bound for the validation.
      max - The upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new SelectionLengthValidator.
      Throws:
      IllegalArgumentException - Thrown if the minimum is a negative number.
    • atLeast

      public static <T> SelectionLengthValidator<T> atLeast​(int min, String errorMessage)
      Creates an SelectionLengthValidator with a given lower bound.
      Parameters:
      min - The lower bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new SelectionLengthValidator.
      Throws:
      IllegalArgumentException - Thrown if the minimum is a negative number.
    • upTo

      public static <T> SelectionLengthValidator<T> upTo​(int max, String errorMessage)
      Creates an SelectionLengthValidator with a given upper bound.
      Parameters:
      max - The upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new SelectionLengthValidator.
    • exactly

      public static <T> SelectionLengthValidator<T> exactly​(int value, String errorMessage)
      Creates a SelectionLengthValidator with a given lower and upper bound, which are equal.
      Parameters:
      value - The lower and upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new SelectionLengthValidator.
    • createResult

      protected ValidationResult createResult​(boolean result)
      Creates a ValidationResult based on the validation result.
      Parameters:
      result - The result of the validation.
      Returns:
      Returns a new ValidationResult containing result and message.