-
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 |
hasNotCRLF(String value) |
does not contain a carriage return or a line feed character (see CRLF attack [26]) |
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 |
is a year before the current year (or the current year) but not more than 120 years in the past |
isColor(String value) |
is a CSS color |
isCountryCode(String value) |
is a country code [39] |
isCurrencyCode(String value) |
is a currency code (ISO 4217) |
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 |
isFileExtensionIn(FileItem value, List<String> extenstions) |
has an extension from the specified list (by default no extensions are allowed) |
isFileSizeLess(FileItem value, Integer size) |
is a file whose size is less than specified (in bytes) |
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 |
isHostname(String value) |
is a host name: DNS host name (e.g. bit.ly), IP address, or local host name (e.g. localhost) |
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 |
isInternalUrl(String value) |
is a URL that belongs to the same domain as the current request (can be useful for redirect URL) |
isISBN(String value) |
is ISBN [64] |
isIPv4(String value) |
is an IP address version 4 |
isIPv6(String value) |
is an IP address version 6 |
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 |
isMonth(Integer value) |
is an integer between 1 and 12 |
isMonth(String value) |
represents a month for the current locale or is an integer between 1 and 12 |
isName(String value) |
contains only characters that occur in human names, i.e. [77]: [a-Z]|[\u00A0- \uD7FF\uF900-\uFDCF\uFDF0-\uFFEF] |
isNotSqlInjection(String value) |
tests to see if the value appears to be an explicit SQL Injection attack (uses OWASP AppSensor [34]) |
isOdd(Long value) |
is an odd number |
isPhone(String value) |
is an international phone number [77] (validator follows the forgiving format, thus parentheses, dots, spaces and hyphens are allowed) |
isPostcode(String value, String countryCode) (alias isZipcode) |
is a postcode valid for the specified country code (US and CA are supported [39]) |
isSSN(String value, String countryCode) |
is social security number valid for specified country code [39] |
isState(String value) |
is a US or Canadian state or province in two letter format |
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 |
isTimeZone(String value) |
is a ISO 8601 time zone [36] |
isTrue(value) |
coerces to boolean true |
isUrl(String value) |
is a well-formed URL [58] |
isWeekDay(String value) |
represents a day of the week for the current locale |
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 |