public class ValidationRule extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> ViolationProvider |
after(String field,
Comparable<T> value,
T other)
Checks if the compared value is strictly after the other.
|
static <T> ViolationProvider |
afterOrEqualsTo(String field,
Comparable<T> value,
T other)
Checks if the compared value is after or equals to the other.
|
static <T> Optional<Violation> |
afterOrEqualsToRule(String field,
Comparable<T> value,
T other)
|
static <T> Optional<Violation> |
afterRule(String field,
Comparable<T> value,
T other)
|
static <T> ViolationProvider |
before(String field,
Comparable<T> value,
T other)
Checks if the compared value is strictly before the other.
|
static <T> ViolationProvider |
beforeOrEqualsTo(String field,
Comparable<T> value,
T other)
Checks if the compared value is before or equals to the other.
|
static <T> Optional<Violation> |
beforeOrEqualsToRule(String field,
Comparable<T> value,
T other)
|
static <T> Optional<Violation> |
beforeRule(String field,
Comparable<T> value,
T other)
|
static ViolationProvider |
blank(String field,
CharSequence value)
Checks if the value is blank.
|
static Optional<Violation> |
blankRule(String field,
CharSequence value)
|
static <T> ViolationProvider |
compareComparable(String field,
Comparable<T> value,
T other,
BiPredicate<Comparable<T>,T> compareFunc,
Supplier<Violation> violationFunc) |
static <T> Optional<Violation> |
compareComparableRule(String field,
Comparable<T> value,
T other,
BiPredicate<Comparable<T>,T> compareFunc,
Supplier<Violation> violationFunc)
Returns violation in case compare function is true.
|
static ViolationProvider |
compareStrings(String field,
String value,
String other,
BiPredicate<String,String> compareFunc,
Supplier<Violation> violationFunc)
Compares the two string against a provided rule.
|
static Optional<Violation> |
compareStringsRule(String field,
String value,
String other,
BiPredicate<String,String> compareFunc,
Supplier<Violation> violationFunc)
Returns violation in case compare function is true.
|
static ViolationProvider |
empty(String field,
CharSequence value)
Checks if the value is empty.
|
static Optional<Violation> |
emptyRule(String field,
CharSequence value)
|
static <T> ViolationProvider |
equalsTo(String field,
Comparable<T> value,
T other)
Checks if the compared value equals the other.
|
static ViolationProvider |
equalsTo(String field,
String value,
String other)
Checks if the compared value equals the other.
|
static <T> Optional<Violation> |
equalsToRule(String field,
Comparable<T> value,
T other)
|
static Optional<Violation> |
equalsToRule(String field,
String value,
String other)
|
static ViolationProvider |
inRange(String field,
Integer value,
int min,
int max)
Checks if the value is between or equals to one of the two limits.
|
static Optional<Violation> |
inRangeRule(String field,
Integer value,
int min,
int max)
|
static ViolationProvider |
isFalse(BooleanSupplier condition,
Violation violation)
Checks if the condition is evaluated to false.
|
static Optional<Violation> |
isFalseRule(BooleanSupplier condition,
Violation violation)
|
static ViolationProvider |
isNull(String field,
Object value)
Checks if the value is null.
|
static Optional<Violation> |
isNullRule(String field,
Object value)
|
static ViolationProvider |
isTrue(BooleanSupplier condition,
Violation violation)
Checks if the condition is evaluated to true.
|
static Optional<Violation> |
isTrueRule(BooleanSupplier condition,
Violation violation)
|
static ViolationProvider |
lengthBetween(String field,
CharSequence value,
int min,
int max)
Checks if the value has the length between or equals to one of two limits.
|
static Optional<Violation> |
lengthBetweenRule(String field,
CharSequence value,
int min,
int max)
|
static ViolationProvider |
matchRegex(String field,
String value,
String regex)
Checks if the value matches the provided regex.
|
static Optional<Violation> |
matchRegexRule(String field,
String value,
String regex)
|
static ViolationProvider |
max(String field,
Integer value,
int max)
Checks if the value is smaller than or equals to the provided superior limit.
|
static Optional<Violation> |
maxRule(String field,
Integer value,
int max)
|
static ViolationProvider |
min(String field,
Integer value,
int min)
Checks if the value is grater than or equals to the provided inferior limit.
|
static Optional<Violation> |
minRule(String field,
Integer value,
int min)
|
static ViolationProvider |
notBlank(String field,
CharSequence value)
Checks if the value is not blank.
|
static Optional<Violation> |
notBlankRule(String field,
CharSequence value)
|
static ViolationProvider |
notEmpty(String field,
CharSequence value)
Checks if the value is not empty.
|
static Optional<Violation> |
notEmptyRule(String field,
CharSequence value)
|
static ViolationProvider |
notEqualsTo(String field,
String value,
String other)
Checks if the compared value is not equal to the other.
|
static Optional<Violation> |
notEqualsToRule(String field,
String value,
String other)
|
static ViolationProvider |
notNull(String field,
Object value)
Checks if the value is not null.
|
static Optional<Violation> |
notNullRule(String field,
Object value)
|
public static ViolationProvider isNull(String field, Object value)
field - path to fieldvalue - value to be checkedpublic static ViolationProvider notNull(String field, Object value)
field - path to fieldvalue - value to be checkedpublic static ViolationProvider isTrue(BooleanSupplier condition, Violation violation)
condition - conditionviolation - violationIllegalArgumentException - in case condition or violation is nullpublic static Optional<Violation> isTrueRule(BooleanSupplier condition, Violation violation)
public static ViolationProvider isFalse(BooleanSupplier condition, Violation violation)
condition - conditionviolation - violationIllegalArgumentException - in case condition or violation is nullpublic static Optional<Violation> isFalseRule(BooleanSupplier condition, Violation violation)
public static ViolationProvider empty(String field, CharSequence value)
field - path to fieldvalue - value to be checkedpublic static Optional<Violation> emptyRule(String field, CharSequence value)
public static ViolationProvider notEmpty(String field, CharSequence value)
field - path to fieldvalue - value to be checkedpublic static Optional<Violation> notEmptyRule(String field, CharSequence value)
public static ViolationProvider blank(String field, CharSequence value)
field - path to fieldvalue - value to be checkedpublic static Optional<Violation> blankRule(String field, CharSequence value)
public static ViolationProvider notBlank(String field, CharSequence value)
field - path to fieldvalue - value to be checkedpublic static Optional<Violation> notBlankRule(String field, CharSequence value)
public static ViolationProvider lengthBetween(String field, CharSequence value, int min, int max)
notNullRule(java.lang.String, java.lang.Object)field - path to fieldvalue - value to be checkedmin - inferior limitmax - superior limitIllegalArgumentException - if min is greater than max.public static Optional<Violation> lengthBetweenRule(String field, CharSequence value, int min, int max)
public static ViolationProvider matchRegex(String field, String value, String regex)
notNullRule(java.lang.String, java.lang.Object)field - path to fieldvalue - value to be checkedregex - a valid regex patternpublic static Optional<Violation> matchRegexRule(String field, String value, String regex)
public static ViolationProvider inRange(String field, Integer value, int min, int max)
notNullRule(java.lang.String, java.lang.Object)field - path to fieldvalue - value to be checkedmin - inferior limitmax - superior limitIllegalArgumentException - if min is greater than max.public static Optional<Violation> inRangeRule(String field, Integer value, int min, int max)
public static ViolationProvider min(String field, Integer value, int min)
notNullRule(java.lang.String, java.lang.Object)field - path to fieldvalue - value to be checkedmin - inferior limitpublic static ViolationProvider max(String field, Integer value, int max)
notNullRule(java.lang.String, java.lang.Object)field - path to fieldvalue - value to be checkedmax - superior limitpublic static <T> ViolationProvider after(String field, Comparable<T> value, T other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.T - compared object typefield - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> afterRule(String field, Comparable<T> value, T other)
public static <T> Optional<Violation> compareComparableRule(String field, Comparable<T> value, T other, BiPredicate<Comparable<T>,T> compareFunc, Supplier<Violation> violationFunc)
field - path to fieldvalue - first valueother - second valuecompareFunc - function that compares the two valuesviolationFunc - the Violation that will be returnedpublic static <T> ViolationProvider afterOrEqualsTo(String field, Comparable<T> value, T other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.T - compared object typefield - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> afterOrEqualsToRule(String field, Comparable<T> value, T other)
public static <T> ViolationProvider before(String field, Comparable<T> value, T other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.T - compared object typefield - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> beforeRule(String field, Comparable<T> value, T other)
public static <T> ViolationProvider beforeOrEqualsTo(String field, Comparable<T> value, T other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.T - compared object typefield - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> beforeOrEqualsToRule(String field, Comparable<T> value, T other)
public static <T> ViolationProvider equalsTo(String field, Comparable<T> value, T other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.T - compared object typefield - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> equalsToRule(String field, Comparable<T> value, T other)
public static ViolationProvider equalsTo(String field, String value, String other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.field - path to fieldvalue - value to be checkedother - other valuepublic static Optional<Violation> equalsToRule(String field, String value, String other)
public static Optional<Violation> compareStringsRule(String field, String value, String other, BiPredicate<String,String> compareFunc, Supplier<Violation> violationFunc)
field - path to fieldvalue - first valueother - second valuecompareFunc - function that compares the two valuesviolationFunc - the Violation that will be returnedpublic static ViolationProvider notEqualsTo(String field, String value, String other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.field - path to fieldvalue - value to be checkedother - other valuepublic static Optional<Violation> notEqualsToRule(String field, String value, String other)
public static ViolationProvider compareStrings(String field, String value, String other, BiPredicate<String,String> compareFunc, Supplier<Violation> violationFunc)
field - path to fieldvalue - value to be checkedother - other valuecompareFunc - comparison functionviolationFunc - violation to be retrieved when compareFunc evaluates
to truepublic static <T> ViolationProvider compareComparable(String field, Comparable<T> value, T other, BiPredicate<Comparable<T>,T> compareFunc, Supplier<Violation> violationFunc)
Copyright © 2020. All rights reserved.