Module ultimategdbot.api
Interface Validator<T>
-
- Type Parameters:
T
- the type of value to validate
- All Superinterfaces:
Function<T,reactor.core.publisher.Mono<T>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Validator<T> extends Function<T,reactor.core.publisher.Mono<T>>
Validates a value in a reactive way.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <T> Validator<T>
allowingAll()
Creates a validator that allows all values.static <T> Validator<T>
allowingIf(Predicate<? super T> predicate, String failureMessage)
Creates a validator that allows the value if the predicate is matched, with the given failure message if the validation doesn't pass.static <T> Validator<T>
allowingWhen(Function<? super T,? extends org.reactivestreams.Publisher<Boolean>> asyncPredicate, String failureMessage)
Creates a validator that allows the value if the Publisher emits true, with the given failure message if the validation doesn't pass.default Validator<T>
and(Validator<T> other)
Creates a validator that allows the value if BOTH this validator AND the given one allow the value.static <T> Validator<T>
denyingAll(String failureMessage)
Creates a validator that denies all values.static <T> Validator<T>
denyingIf(Predicate<? super T> predicate, String failureMessage)
Creates a validator that denies the value if the predicate is matched, with the given failure message if the validation doesn't pass.static <T> Validator<T>
denyingIfNotNull(String failureMessage)
Creates a validator that only allows null values.static <T> Validator<T>
denyingIfNull(String failureMessage)
Creates a validator that denies null values.static <T> Validator<T>
denyingWhen(Function<? super T,? extends org.reactivestreams.Publisher<Boolean>> asyncPredicate, String failureMessage)
Creates a validator that denies the value if the Publisher emits true, with the given failure message if the validation doesn't pass.default Validator<T>
or(Validator<T> other)
Creates a validator that allows the value if EITHER this validator OR the given one allows the value.
-
-
-
Method Detail
-
and
default Validator<T> and(Validator<T> other)
Creates a validator that allows the value if BOTH this validator AND the given one allow the value. If this validator fails, the given one is not evaluated.- Parameters:
other
- the other validator- Returns:
- a validator allowing the value if this validator AND the given one allow it
-
or
default Validator<T> or(Validator<T> other)
Creates a validator that allows the value if EITHER this validator OR the given one allows the value. If this validator allows the value, the given one is not evaluated.- Parameters:
other
- the other validator- Returns:
- a validator allowing the value if this validator OR the given one allows it
-
allowingAll
static <T> Validator<T> allowingAll()
Creates a validator that allows all values.- Type Parameters:
T
- the type of value to validate- Returns:
- a validator
-
denyingAll
static <T> Validator<T> denyingAll(String failureMessage)
Creates a validator that denies all values.- Type Parameters:
T
- the type of value to validate- Parameters:
failureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
allowingIf
static <T> Validator<T> allowingIf(Predicate<? super T> predicate, String failureMessage)
Creates a validator that allows the value if the predicate is matched, with the given failure message if the validation doesn't pass.- Type Parameters:
T
- the type of value to validate- Parameters:
predicate
- the predicate deciding whether to allow the valuefailureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
denyingIf
static <T> Validator<T> denyingIf(Predicate<? super T> predicate, String failureMessage)
Creates a validator that denies the value if the predicate is matched, with the given failure message if the validation doesn't pass.- Type Parameters:
T
- the type of value to validate- Parameters:
predicate
- the predicate deciding whether to deny the valuefailureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
allowingWhen
static <T> Validator<T> allowingWhen(Function<? super T,? extends org.reactivestreams.Publisher<Boolean>> asyncPredicate, String failureMessage)
Creates a validator that allows the value if the Publisher emits true, with the given failure message if the validation doesn't pass. The async predicate obeys the same rules as described inMono.filterWhen(Function)
- Type Parameters:
T
- the type of value to validate- Parameters:
asyncPredicate
- the async predicate deciding whether to allow the valuefailureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
denyingWhen
static <T> Validator<T> denyingWhen(Function<? super T,? extends org.reactivestreams.Publisher<Boolean>> asyncPredicate, String failureMessage)
Creates a validator that denies the value if the Publisher emits true, with the given failure message if the validation doesn't pass. The async predicate obeys the same rules as described inMono.filterWhen(Function)
- Type Parameters:
T
- the type of value to validate- Parameters:
asyncPredicate
- the async predicate deciding whether to deny the valuefailureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
denyingIfNull
static <T> Validator<T> denyingIfNull(String failureMessage)
Creates a validator that denies null values.- Type Parameters:
T
- the type of value to validate- Parameters:
failureMessage
- the message to forward to the user if the validation fails- Returns:
- a validator
-
-