Package com.github.skopylov58.functional
Interface Validator<T,E>
- Type Parameters:
T- type to validateE- validation error type
- All Known Implementing Classes:
Validator.ValidatorImpl
public interface Validator<T,E>
Simple validator that can collect validation errors.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns validation errors.booleanChecks if object is validstatic <T,E> Validator<T, E> of(T t) Factory method to create validator of type T and errors type EValidates some internal state (class members, etc.) of validator's object.Validates validator's object of type T.
-
Method Details
-
validate
Validates validator's object of type T.- Parameters:
predicate- predicate to validate validator's objecterrorSupplier- error supplier if predicate returns false.- Returns:
- this validator
-
validate
<R> Validator<T,E> validate(Function<T, R> mapper, Predicate<R> predicate, Supplier<E> errorSupplier) Validates some internal state (class members, etc.) of validator's object.- Type Parameters:
R-- Parameters:
mapper-predicate-errorSupplier-- Returns:
-
validate
-
validate
-
notNull
-
hasErrors
boolean hasErrors()Checks if object is valid- Returns:
- true if no validation errors were found
-
getErrors
Returns validation errors.- Returns:
- empty list if no errors were found.
-
validate
-
validate
-
notNull
-
of
Factory method to create validator of type T and errors type E- Type Parameters:
T- type to validateE- validation error type- Parameters:
t- object to validate- Returns:
- validator
-