String functions

The following table describes the string functions.

Warning Using negation (!) at the beginning of any function can cause unexpected validation results.
Function Description
isEmpty (value) Checks whether the value is empty or null.
isNotEmpty (value) Checks whether the value isn't empty.
startsWith (value, prefix) Checks whether the value starts with the specified prefix.
contains (value, substring) Checks whether the value contains the specified substring.
doesNotContain(value, substring) Checks whether the value doesn't contain the specified substring.
endsWith (value, suffix) Checks whether the value ends with the specified suffix.
isLengthBetween (value, minLength, maxLength)

Checks whether the value has a length between the specified range.

The range is inclusive. For example, isLengthBetween ('Hello', 2, 5) returns true because Hello has a length of 5.

isLengthLess (value, maxLength) Checks whether the value has a length less than the specified length.
isLengthMore (value, minLength) Checks whether the value has a length longer than the specified length.
isLengthEq (value, length) Checks whether the value has a length equal to the specified length.
isAlpha (value)

Checks whether the value contains only alphabetical characters.

This is done through the regular expression [a-zA-Z]+.

isAlphaSpace (value) Checks whether the value contains only alphabetical characters and spaces.
isAlphanum (value) Checks whether the value contains only alphabetical characters and digits.
isAlphanumSpace (value) Checks whether the value contains only alphabetical characters, digits, and spaces.
matches (value, regular expression)

Checks whether the value matches the specified regular expression.

A regular expression must be placed between two forward slashes (/).

Examples:

  • matches ("stream", /str.*/) returns true because stream matches the pattern str.*.
  • matches ("stream", /srl.*/) returns false because stream doesn't match the pattern srl.*.