-
Notifications
You must be signed in to change notification settings - Fork 10
Built in validators
Function name |
Requirement to processed value parameter |
areIn(List values, List list) |
is a list which values are equal to any member of the specified list |
areIn(List values, Set set) |
is a list which values are equal to any member of the specified set |
contains(String value, CharSequence substring) |
contains the specified the specified sequence of char values |
endsWith(String value, String suffix) |
ends with the specified suffix |
isAfter(Date value, Date minDate) |
is a date after the specified one |
isAfterNow(Date value) |
is a date after now |
isAlnum(String value) |
is a string that matches /[a-zA-Z0-9]+/ |
isAlnumSpace(String value) |
is a string that matches /[a-zA-Z0-9\s]+/ |
isAlpha(String value) |
is a string that matches /[a-zA-Z]+/ |
isAlphaSpace(String value) |
is a string that matches /[a-zA-Z\s]+/ |
isAny(List values) |
is a list whose at least one member is true according to the Groovy Truth |
isAny(List values, Closure closure) |
is a list whose at least one member is valid according to a predicate |
isBefore(Date value, Date maxDate) |
is a date before the specified one
|
isBeforeNow(Date value) |
is a date before now |
isBetween(Number value, Number min, Number max) |
falls within the specified range of decimal values |
isBetween(Integer value, IntRange min..max) |
falls within the specified integer range (uses HTML5 min and max attributes for the client side [18]) |
isBirthDateAlive(Date value) |
is a date before the current year (or the current year) but not more than 120 years in the past |
isBirthYearAlive(Integer year) |
is a year before the current year (or the current year) but not more than 120 years in the past |
isEmail(String value) |
is an email address compliant to RFC [21] (uses the HTML5 email input type for the client side) |
isEmpty(List values) |
is an empty list |
isEmpty(String value) |
is a string that matches /\s*/ |
isEqual(value, object) (alias eq) |
is equal to the specified object |
isEven(Long value) |
is an even number |
isEvery(List values) |
is a list whose members are true according to the Groovy Truth |
isEvery(List values, Closure closure) |
is a list whose members are valid according to a predicate |
isFalse(value) |
coerces to boolean false |
isGreater(Number value, Number number) (alias ‒ gt) |
is a number greater than the specified number |
isGreaterEq(Number value, Number number) (alias ‒ gte) |
is a number greater or equal to the specified number |
isIn(value, List list) |
is equal to any member of the specified list |
isIn(value, Set set) |
is equal to any member of the specified set |
isLengthEq(String value, Integer length) |
has the specified string length |
isLengthBetween(String value, Integer min, Integer max) |
is within the specified range of string lengths (the range is inclusive) |
isLengthLess(String value, Integer length) |
has a string length less than specified value |
isLengthLessEq(String value, Integer length) |
has a string length less or equal to specified value |
isLengthMore(String value, Integer length) |
has a string length more than specified value |
isLengthMoreEq(String value, Integer length) |
has a string length more than or equal to the specified value |
isLess(Number value, Number number) (alias: lt) |
is a number less than the specified number |
isLessEq(Number value, Number number) (alias: lte) |
is a number less than or equal to the specified number |
isOdd(Long value) |
is an odd number |
isStrongPassword(String value, List<String> mediumPasswordRegexes, List<String> strongPasswordRegexes) |
is compliant with a strong password policy
A password is: - weak if it does not match some of mediumPasswordRegexes - medium if it does not match some of strongPasswordRegexes - strong if it matches all the given regexes
Password is invalid if it is not strong, in this case ValidationException’s parameters field contains password strength (WEAK or MEDIUM), which then can be read on the client side |
isTrue(value) |
coerces to boolean true |
matches(String value, String regexp) |
is a string that matches the specified regex (uses HTML5 attribute pattern for the client side [25]) |
startsWith(String value, String prefix) |
starts with the specified prefix |