public class ValidationRule extends Object
| Constructor and Description |
|---|
ValidationRule() |
| Modifier and Type | Method and Description |
|---|---|
static <T> ViolationProvider |
after(String fieldPath,
Comparable<T> value,
T other)
Checks if the compared value is strictly after the other.
|
static <T> ViolationProvider |
afterOrEqualsTo(String fieldPath,
Comparable<T> value,
T other)
Checks if the compared value is after or equals to the other.
|
static <T> Optional<Violation> |
afterOrEqualsToRule(String fieldPath,
Comparable<T> value,
T other)
|
static <T> Optional<Violation> |
afterRule(String fieldPath,
Comparable<T> value,
T other)
|
static <T> ViolationProvider |
before(String fieldPath,
Comparable<T> value,
T other)
Checks if the compared value is strictly before the other.
|
static <T> ViolationProvider |
beforeOrEqualsTo(String fieldPath,
Comparable<T> value,
T other)
Checks if the compared value is before or equals to the other.
|
static <T> Optional<Violation> |
beforeOrEqualsToRule(String fieldPath,
Comparable<T> value,
T other)
|
static <T> Optional<Violation> |
beforeRule(String fieldPath,
Comparable<T> value,
T other)
|
static ViolationProvider |
blank(String fieldPath,
CharSequence value)
Checks if the value is blank.
|
static Optional<Violation> |
blankRule(String fieldPath,
CharSequence value)
|
static <T> ViolationProvider |
compareComparables(String fieldPath,
Comparable<T> value,
T other,
BiFunction<Comparable<T>,T,Boolean> compareFunc,
Supplier<Violation> violationFunc) |
static <T> Optional<Violation> |
compareComparablesRule(String fieldPath,
Comparable<T> value,
T other,
BiFunction<Comparable<T>,T,Boolean> compareFunc,
Supplier<Violation> violationFunc)
Returns violation in case compare function is true.
|
static ViolationProvider |
compareStrings(String fieldPath,
String value,
String other,
BiFunction<String,String,Boolean> compareFunc,
Supplier<Violation> violationFunc)
Compares the two string against a provided rule.
|
static Optional<Violation> |
compareStringsRule(String fieldPath,
String value,
String other,
BiFunction<String,String,Boolean> compareFunc,
Supplier<Violation> violationFunc)
Returns violation in case compare function is true.
|
static ViolationProvider |
empty(String fieldPath,
CharSequence value)
Checks if the value is empty.
|
static Optional<Violation> |
emptyRule(String fieldPath,
CharSequence value)
|
static <T> ViolationProvider |
equalsTo(String fieldPath,
Comparable<T> value,
T other)
Checks if the compared value equals the other.
|
static ViolationProvider |
equalsTo(String fieldPath,
String value,
String other)
Checks if the compared value equals the other.
|
static <T> Optional<Violation> |
equalsToRule(String fieldPath,
Comparable<T> value,
T other)
|
static Optional<Violation> |
equalsToRule(String fieldPath,
String value,
String other)
|
static ViolationProvider |
inRange(String fieldPath,
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 fieldPath,
Integer value,
int min,
int max)
|
static ViolationProvider |
isNull(String fieldPath,
Object value)
Checks if the value is null.
|
static Optional<Violation> |
isNullRule(String fieldPath,
Object value)
|
static ViolationProvider |
lengthBetween(String fieldPath,
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 fieldPath,
CharSequence value,
int min,
int max)
|
static ViolationProvider |
matchRegex(String fieldPath,
String value,
String regex)
Checks if the value matches the provided regex.
|
static Optional<Violation> |
matchRegexRule(String fieldPath,
String value,
String regex)
|
static ViolationProvider |
max(String fieldPath,
Integer value,
int max)
Checks if the value is smaller than or equals to the provided superior limit.
|
static Optional<Violation> |
maxRule(String fieldPath,
Integer value,
int max)
|
static ViolationProvider |
min(String fieldPath,
Integer value,
int min)
Checks if the value is grater than or equals to the provided inferior limit.
|
static Optional<Violation> |
minRule(String fieldPath,
Integer value,
int min)
|
static ViolationProvider |
notBlank(String fieldPath,
CharSequence value)
Checks if the value is not blank.
|
static Optional<Violation> |
notBlankRule(String fieldPath,
CharSequence value)
|
static ViolationProvider |
notEmpty(String fieldPath,
CharSequence value)
Checks if the value is not empty.
|
static Optional<Violation> |
notEmptyRule(String fieldPath,
CharSequence value)
|
static ViolationProvider |
notEqualsTo(String fieldPath,
String value,
String other)
Checks if the compared value is not equal to the other.
|
static Optional<Violation> |
notEqualsToRule(String fieldPath,
String value,
String other)
|
static ViolationProvider |
notNull(String fieldPath,
Object value)
Checks if the value is not null.
|
static Optional<Violation> |
notNullRule(String fieldPath,
Object value)
|
public static ViolationProvider isNull(String fieldPath, Object value)
fieldPath - path to fieldvalue - value to be checkedpublic static ViolationProvider notNull(String fieldPath, Object value)
fieldPath - path to fieldvalue - value to be checkedpublic static ViolationProvider empty(String fieldPath, CharSequence value)
fieldPath - path to fieldvalue - value to be checkedpublic static Optional<Violation> emptyRule(String fieldPath, CharSequence value)
public static ViolationProvider notEmpty(String fieldPath, CharSequence value)
fieldPath - path to fieldvalue - value to be checkedpublic static Optional<Violation> notEmptyRule(String fieldPath, CharSequence value)
public static ViolationProvider blank(String fieldPath, CharSequence value)
fieldPath - path to fieldvalue - value to be checkedpublic static Optional<Violation> blankRule(String fieldPath, CharSequence value)
public static ViolationProvider notBlank(String fieldPath, CharSequence value)
fieldPath - path to fieldvalue - value to be checkedpublic static Optional<Violation> notBlankRule(String fieldPath, CharSequence value)
public static ViolationProvider lengthBetween(String fieldPath, CharSequence value, int min, int max)
notNullRule(java.lang.String, java.lang.Object)fieldPath - path to fieldvalue - value to be checkedmin - inferior limitmax - superior limitIllegalArgumentException - if min is greater than max.public static Optional<Violation> lengthBetweenRule(String fieldPath, CharSequence value, int min, int max)
public static ViolationProvider matchRegex(String fieldPath, String value, String regex)
notNullRule(java.lang.String, java.lang.Object)fieldPath - path to fieldvalue - value to be checkedregex - a valid regex patternpublic static Optional<Violation> matchRegexRule(String fieldPath, String value, String regex)
public static ViolationProvider inRange(String fieldPath, Integer value, int min, int max)
notNullRule(java.lang.String, java.lang.Object)fieldPath - path to fieldvalue - value to be checkedmin - inferior limitmax - superior limitIllegalArgumentException - if min is greater than max.public static Optional<Violation> inRangeRule(String fieldPath, Integer value, int min, int max)
public static ViolationProvider min(String fieldPath, Integer value, int min)
notNullRule(java.lang.String, java.lang.Object)fieldPath - path to fieldvalue - value to be checkedmin - inferior limitpublic static ViolationProvider max(String fieldPath, Integer value, int max)
notNullRule(java.lang.String, java.lang.Object)fieldPath - path to fieldvalue - value to be checkedmax - superior limitpublic static <T> ViolationProvider after(String fieldPath, 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 typefieldPath - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> afterRule(String fieldPath, Comparable<T> value, T other)
public static <T> ViolationProvider afterOrEqualsTo(String fieldPath, 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 typefieldPath - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> afterOrEqualsToRule(String fieldPath, Comparable<T> value, T other)
public static <T> ViolationProvider before(String fieldPath, 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 typefieldPath - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> beforeRule(String fieldPath, Comparable<T> value, T other)
public static <T> ViolationProvider beforeOrEqualsTo(String fieldPath, 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 typefieldPath - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> beforeOrEqualsToRule(String fieldPath, Comparable<T> value, T other)
public static <T> ViolationProvider equalsTo(String fieldPath, 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 typefieldPath - path to fieldvalue - value to be checkedother - other valuepublic static <T> Optional<Violation> equalsToRule(String fieldPath, Comparable<T> value, T other)
public static ViolationProvider equalsTo(String fieldPath, String value, String other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.fieldPath - path to fieldvalue - value to be checkedother - other valuepublic static Optional<Violation> equalsToRule(String fieldPath, String value, String other)
public static ViolationProvider notEqualsTo(String fieldPath, String value, String other)
notNullRule(java.lang.String, java.lang.Object).
If other is null then a violation will be returned.fieldPath - path to fieldvalue - value to be checkedother - other valuepublic static Optional<Violation> notEqualsToRule(String fieldPath, String value, String other)
public static ViolationProvider compareStrings(String fieldPath, String value, String other, BiFunction<String,String,Boolean> compareFunc, Supplier<Violation> violationFunc)
fieldPath - path to fieldvalue - value to be checkedother - other valuecompareFunc - comparison functionviolationFunc - violation to be retrieved when compareFunc evaluates
to truepublic static Optional<Violation> compareStringsRule(String fieldPath, String value, String other, BiFunction<String,String,Boolean> compareFunc, Supplier<Violation> violationFunc)
fieldPath - path to fieldvalue - first valueother - second valuecompareFunc - function that compares the two valuesviolationFunc - the Violation that will be returnedpublic static <T> ViolationProvider compareComparables(String fieldPath, Comparable<T> value, T other, BiFunction<Comparable<T>,T,Boolean> compareFunc, Supplier<Violation> violationFunc)
public static <T> Optional<Violation> compareComparablesRule(String fieldPath, Comparable<T> value, T other, BiFunction<Comparable<T>,T,Boolean> compareFunc, Supplier<Violation> violationFunc)
fieldPath - path to fieldvalue - first valueother - second valuecompareFunc - function that compares the two valuesviolationFunc - the Violation that will be returnedCopyright © 2020. All rights reserved.