Interface Validated<T>
- All Known Implementing Classes:
Validated.Either
,Validated.Invalid
,Validated.None
,Validated.Secret
,Validated.Valid
Validation support for
MeterRegistryConfig
.- Since:
- 1.5.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
static class
Indicates that no validation has occurred.static class
A specializationValidated.Valid
that won't print the secret in plain text if the validation is serialized.static class
A valid property value. -
Method Summary
Modifier and TypeMethodDescriptiondefault Validated
<?> default List
<Validated.Invalid<?>> failures()
<U> Validated
<U> flatMap
(BiFunction<T, Validated.Valid<T>, Validated<U>> mapping) default <U> Validated
<U> get()
static <T> Validated.Invalid
<T> invalid
(String property, Object value, String message, InvalidReason reason) static <T> Validated.Invalid
<T> invalidateWhen
(Predicate<T> condition, String message, InvalidReason reason) When the condition is met, turn aValidated.Valid
result into anValidated.Invalid
result with the provided message.default boolean
boolean
isValid()
<U> Validated
<U> nonBlank()
static <T> Validated.None
<T> none()
default T
void
orThrow()
required()
static <T> Validated.Valid
<T> static Validated.Secret
validSecret
(String property, String value) Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
isValid
boolean isValid() -
isInvalid
default boolean isInvalid() -
failures
-
validSecret
-
none
-
valid
-
invalid
static <T> Validated.Invalid<T> invalid(String property, @Nullable Object value, String message, InvalidReason reason) -
invalid
static <T> Validated.Invalid<T> invalid(String property, @Nullable Object value, String message, InvalidReason reason, @Nullable Throwable exception) -
and
-
map
-
flatMap
-
flatMap
-
invalidateWhen
When the condition is met, turn aValidated.Valid
result into anValidated.Invalid
result with the provided message.- Parameters:
condition
-true
when the property should be considered invalid.message
- A message explaining the reason why the property is considered invalid.reason
- An invalid reason.- Returns:
- When originally
Validated.Valid
, apply the test and either retain the valid decision or make itValidated.Invalid
. When originallyValidated.Invalid
orValidated.None
, don't apply the test at all, and pass through the original decision.
-
required
-
nonBlank
-
get
- Throws:
ValidationException
-
orElse
- Throws:
ValidationException
-
orElseGet
- Throws:
ValidationException
-
orThrow
- Throws:
ValidationException
-