Interface Validator<T>

  • Type Parameters:
    T - type of the controls value
    All Superinterfaces:
    BiFunction<Control,​T,​ValidationResult>

    public interface Validator<T>
    extends BiFunction<Control,​T,​ValidationResult>
    Interface defining the contract for validation of specific component This interface is a BiFunction which when given the control and its current value computes the validation result
    • Method Detail

      • combine

        @SafeVarargs
        static <T> Validator<T> combine​(Validator<T>... validators)
        Combines the given validators into a single Validator instance.
        Parameters:
        validators - the validators to combine
        Returns:
        a Validator instance
      • createEmptyValidator

        static <T> Validator<T> createEmptyValidator​(String message,
                                                     Severity severity)
        Factory method to create a validator, which checks if value exists.
        Parameters:
        message - text of a message to be created if value is invalid
        severity - severity of a message to be created if value is invalid
        Returns:
        new validator
      • createEmptyValidator

        static <T> Validator<T> createEmptyValidator​(String message)
        Factory method to create a validator, which checks if value exists. Error is created if not if value does not exist
        Parameters:
        message - of a error to be created if value is invalid
        Returns:
        new validator
      • createEqualsValidator

        static <T> Validator<T> createEqualsValidator​(String message,
                                                      Severity severity,
                                                      Collection<T> values)
        Factory method to create a validator, which if value exists in the provided collection.
        Parameters:
        values - text of a message to be created if value is not found
        severity - severity of a message to be created if value is found
        Returns:
        new validator
      • createEqualsValidator

        static <T> Validator<T> createEqualsValidator​(String message,
                                                      Collection<T> values)
        Factory method to create a validator, which checks if value exists in the provided collection. Error is created if not found
        Parameters:
        message - text of a error to be created if value is not found
        values -
        Returns:
        new validator
      • createPredicateValidator

        static <T> Validator<T> createPredicateValidator​(Predicate<T> predicate,
                                                         String message)
        Factory method to create a validator, which evaluates the value validity with a given predicate. Error is created if the evaluation is false.
        Parameters:
        message - text of a message to be created if value is invalid
        predicate - the predicate to be used for the value validity evaluation.
        Returns:
        new validator
      • createPredicateValidator

        static <T> Validator<T> createPredicateValidator​(Predicate<T> predicate,
                                                         String message,
                                                         Severity severity)
        Factory method to create a validator, which evaluates the value validity with a given predicate. Error is created if the evaluation is false.
        Parameters:
        message - text of a message to be created if value is invalid
        predicate - the predicate to be used for the value validity evaluation.
        severity - severity of a message to be created if value is invalid
        Returns:
        new validator
      • createRegexValidator

        static Validator<String> createRegexValidator​(String message,
                                                      String regex,
                                                      Severity severity)
        Factory method to create a validator, which checks the value against a given regular expression. Error is created if the value is null or the value does not match the pattern.
        Parameters:
        message - text of a message to be created if value is invalid
        regex - the regular expression the value has to match
        severity - severity of a message to be created if value is invalid
        Returns:
        new validator
      • createRegexValidator

        static Validator<String> createRegexValidator​(String message,
                                                      Pattern regex,
                                                      Severity severity)
        Factory method to create a validator, which checks the value against a given regular expression. Error is created if the value is null or the value does not match the pattern.
        Parameters:
        message - text of a message to be created if value is invalid
        regex - the regular expression the value has to match
        severity - severity of a message to be created if value is invalid
        Returns:
        new validator