V - Entity type to be validatedpublic class RuleBuilder<V> extends Object
ValidationRule| Constructor and Description |
|---|
RuleBuilder(String fieldName) |
| Modifier and Type | Method and Description |
|---|---|
ValidationRule<V> |
build()
Build the
ValidationRule with the supplied value functions and their corresponding predicates, all of
which must be positively tested to generate aa error |
<M> RuleBuilder<V> |
check(Function<V,M> valueRetriever,
Predicate<M> predicate)
Adds the value function, with the corresponding predicate to the checks list
|
RuleBuilder<V> |
check(Predicate<V> valueRetriever,
boolean expectedValue)
Adds the value function, with the corresponding predicate to the checks list
|
static Predicate<String> |
eq(String testValue) |
static Predicate<String> |
greaterThanOrEquals(Long number) |
RuleBuilder<V> |
ifMatchesThenSet(Function<V,String> messageFunction)
Sets the message function, which will be used to get the actual error message for the field error
|
RuleBuilder<V> |
ifMatchesThenSet(Supplier<String> messageSupplier)
Sets the message supplier, which will be used to get the actual error message for the field error
|
static Predicate<String> |
inLongRange(Long min,
Long max) |
static Predicate<String> |
isNull() |
static Predicate<String> |
isValidRegex() |
static Predicate<String> |
isValidURI() |
static <K> Predicate<K> |
matchesAll(Predicate<K>... predicates) |
static <K> Predicate<K> |
matchesAny(Predicate<K>... predicates) |
static Supplier<String> |
message(I18nHelper i18nHelper,
String messageKey) |
static <K> Predicate<K> |
not(Predicate<K> predicate) |
static Predicate<String> |
notNull() |
static Predicate<String> |
regex(String pattern)
Utility method which returns the predicate for matching any string value to the given regex pattern.
|
public RuleBuilder(String fieldName)
public static Predicate<String> regex(String pattern)
pattern - The pattern to which the string is to be tested againstpublic static Supplier<String> message(I18nHelper i18nHelper, String messageKey)
public <M> RuleBuilder<V> check(Function<V,M> valueRetriever, Predicate<M> predicate)
valueRetriever - The value function to be used to retrieve valuepredicate - The predicate to be tested against the retrieved value from Functionpublic RuleBuilder<V> check(Predicate<V> valueRetriever, boolean expectedValue)
valueRetriever - Predicate which will be used to check conditionexpectedValue - The value which will be compare in predicatepublic RuleBuilder<V> ifMatchesThenSet(Supplier<String> messageSupplier)
messageSupplier - The supplier for the error messagepublic RuleBuilder<V> ifMatchesThenSet(Function<V,String> messageFunction)
messageFunction - the function, which will be used to get proper error messagepublic ValidationRule<V> build()
ValidationRule with the supplied value functions and their corresponding predicates, all of
which must be positively tested to generate aa errorValidationRule A rule that can be applied on the V entity to be validatedCopyright © 2023 Atlassian. All rights reserved.