Interface Validator<T>

    • Method Detail

      • validate

        java.lang.String validate​(T value)
        Validate a value.
        Parameters:
        value - the value to validate
        Returns:
        a description of the validation errors or null
      • when

        default Validator<T> when​(java.util.function.Supplier<java.lang.Boolean> condition)
        Returns:
        a new Validator that only reports errors when the condition is true
      • whenNot

        default Validator<T> whenNot​(java.util.function.Supplier<java.lang.Boolean> condition)
        Returns:
        a new Validator that only reports errors when the condition is false
      • then

        default Validator<T> then​(Validator<T> other)
        Apply another validation if this validation passes.
        Parameters:
        other - the other validator
        Returns:
        a new Validator that returns the error from this or other
      • add

        default Validator<T> add​(Validator<T> other)
        Apply another validation after this validation. Uses System.lineSeparator() as the message separator.
        Parameters:
        other - the other validator
        Returns:
        a new Validator that returns the combined messages of this and other
      • add

        default Validator<T> add​(Validator<T> other,
                                 java.lang.String separator)
        Apply another validation after this validation.
        Parameters:
        other - the other validator
        separator - the separator to use when joining the error messages
        Returns:
        a new Validator that returns the combined messages of this and other