General functions

The function... checks whether...
isEmpty (value) A value is empty, null or does not contain any element.
isNotEmpty (value) A value is not empty.
isEqual (value1, value2) A value is the same as a second value.
isNotEqual (value1, value2) A value is not the same as a second value.
isIn (value, Collection) A value is part of a collection.
areIn (Collection values, Collection collection) A collection is part of another collection.
isAny (Collection, Closure) Any value of a collection meets the criteria of a validation closure.
isEvery (Collection, Closure) All values of a collection meet the criteria of a validation closure.
isFalse (value)

A value is false, empty or null according to the Groovy truth.

Examples:

  • isFalse (something): returns true if something is false.
  • isFalse (something): returns false is something is true.
  • isFalse (false): returns true.
  • isFalse (null): returns true.
isTrue (value)

A value is true, empty or null according to the Groovy truth.

Examples:

  • isTrue (something): returns false if something is false.
  • isTrue (something): returns true is something is true.
  • isTrue (false): returns false.
  • isTrue (null): returns true.
isUnique (Collection, Closure)

All values in a collection are unique.

Examples:

  • isUnique ([1,2,3]): will evaluate to true.
  • isUnique ([1,2,3,1]): will evaluate to false.

Examples:

The closure {it % 2} allows only one even and one odd element in the list.

  • isUnique ([3, 4], {it % 2}): will evaluate to true.
  • isUnique ([1, 3, 4], {it % 2}): will evaluate to false, because both 1 and 3 are odd.
validate (value) A value is a valid function, accepting any closure that is capable of returning true or false.

Tip Validate (value) is a general validation function used to check another function.