Extend your transaction monitoring rules with expression functions.
Expression functions allow you to extend your rule conditions enabling more precise transaction monitoring.
Below is a list of available expression functions, grouped by purpose. You can use these functions to build SumScript expressions.
📘
Note
For guidance on creating more complex conditions, see Advanced usage.
Array operations
Use these functions to perform operations on arrays.
arrayAvg
arrayAvg(array: NUMBER[]) → FLOAT NOT NULL
Returns the arithmetic mean of the values in a numeric array.
Arguments
Name
Type
Description
array
NUMBER[]
Numeric array.
Returns
Type
Description
FLOAT NOT NULL
Numeric result.
arrayCount
arrayCount(filter: (V) ->BOOL, array: V[]) → INT NOT NULL
Counts the elements in an array that satisfy the predicate.
Arguments
Name
Type
Description
filter
(V) ->BOOL
Predicate applied to each element (returns true to count the element).
array
V[]
Input array.
Returns
Type
Description
INT NOT NULL
Resulting integer value.
arrayFilter
arrayFilter(filter: (V) ->BOOL, array: V[]) → V[]
Filters an array by applying the predicate function to each element.
Arguments
Name
Type
Description
filter
(V) ->BOOL
Predicate applied to each element (returns true to keep the element).
array
V[]
Input array.
Returns
Type
Description
V[]
Resulting array.
arrayJoin
arrayJoin(source: V[]*) → V*
Concatenates arrays/streams into a single stream.
Arguments
Name
Type
Description
source
V[]*
Arrays/streams to concatenate.
Returns
Type
Description
V*
Result value.
arrayMap
arrayMap(fn: (V) ->R, array: V[]) → R[]
Maps an array by applying the function to each element.
Arguments
Name
Type
Description
fn
(V) ->R
Mapping function applied to each element.
array
V[]
Input array.
Returns
Type
Description
R[]
Resulting array.
arrayMax
arrayMax(array: V : COMPARABLE[]) → V : COMPARABLE
Returns the maximum element of the array.
Arguments
Name
Type
Description
array
V : COMPARABLE\[]
Comparable array.
Returns
Type
Description
V : COMPARABLE
Numeric result.
arrayMin
arrayMin(array: V : COMPARABLE[]) → V : COMPARABLE
Returns the minimum element of the array.
Arguments
Name
Type
Description
array
V : COMPARABLE[]
Comparable array.
Returns
Type
Description
V : COMPARABLE
Numeric result.
arraySlice
arraySlice(array: V[], offset: INT NOT NULL, length: INT) → V[]
Returns a slice of an array starting at the given offset (and optional length).
Arguments
Name
Type
Description
array
V[]
Input array.
offset
INT NOT NULL
Zero-based start index.
length
INT
Maximum number of elements to return.
Returns
Type
Description
V[]
Resulting array.
arrayStddevSamp
arrayStddevSamp(array: NUMBER[]) → FLOAT NOT NULL
Returns the sample standard deviation of the numeric array.
Arguments
Name
Type
Description
array
NUMBER[]
Numeric array.
Returns
Type
Description
FLOAT NOT NULL
Numeric result.
arraySum
arraySum(value: INT[]) → INT NOT NULL
arraySum(value: FLOAT[]) → FLOAT NOT NULL
Returns the sum of the numeric array.
Arguments
Name
Type
Description
value
INT[] | FLOAT[]
Numeric array.
Returns
Type
Description
INT NOT NULL | FLOAT NOT NULL
Numeric result.
countEqual
countEqual(array: V[], value: V) → INT NOT NULL
Counts how many elements in the array are equal to the given value.
Arguments
Name
Type
Description
array
V[]
Input array.
value
V
Value to compare against.
Returns
Type
Description
INT NOT NULL
Resulting integer value.
empty
// Returns `true` if the string is null or empty.
empty(s: STRING) → BOOL NOT NULL
// Returns `true` if the array is empty.
empty(array: V[]) → BOOL NOT NULL
Arguments
Name
Type
Description
s | array
STRING | V[]
Parameter.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
flatten
flatten(array: V[][]) → V[]
Flattens a 2D array into a 1D array.
Arguments
Name
Type
Description
array
V[][]
2D array to flatten.
Returns
Type
Description
V[]
Resulting array.
has
has(array: V[], value: V) → BOOL NOT NULL
Returns true if the array contains the given value.
Arguments
Name
Type
Description
array
V[]
Input array.
value
V
Value to look for.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
hasAll
hasAll(array1: V[], array2: V[]) → BOOL NOT NULL
Returns true if array1 contains all elements from array2.
Arguments
Name
Type
Description
array1
V[]
First array.
array2
V[]
Second array.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
hasAny
hasAny(array1: V[], array2: V[]) → BOOL NOT NULL
Returns true if array1 and array2 have at least one common element.
Arguments
Name
Type
Description
array1
V[]
First array.
array2
V[]
Second array.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
length
// Returns the number of characters in a string.
length(s: STRING) → INT NOT NULL
// Returns the number of elements in an array.
length(array: V[]) → INT NOT NULL
Arguments
Name
Type
Description
s | array
STRING | V[]
Parameter.
Returns
Type
Description
INT NOT NULL
Resulting integer value.
notEmpty
// Returns `true` if the string is not null and not empty.
notEmpty(s: STRING) → BOOL NOT NULL
// Returns `true` if the array is not empty.
notEmpty(array: V[]) → BOOL NOT NULL
Arguments
Name
Type
Description
s | array
STRING | V[]
Parameter.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
Date and time (basic operations)
Use these functions to perform basic date and time operations.
diffDays
diffDays(date1: DATE, date2: DATE) → INT
Returns the difference between two dates in whole days.
Arguments
Name
Type
Description
date1
DATE
Start date/time value.
date2
DATE
End date/time value.
Returns
Type
Description
INT
Difference between two dates in days.
diffHours
diffHours(date1: DATE, date2: DATE) → INT
Returns the difference between two dates in whole hours.
Arguments
Name
Type
Description
date1
DATE
Start date/time value.
date2
DATE
End date/time value.
Returns
Type
Description
INT
Difference between two dates in hours.
diffMinutes
diffMinutes(date1: DATE, date2: DATE) → INT
Returns the difference between two dates in whole minutes.
Arguments
Name
Type
Description
date1
DATE
Start date/time value.
date2
DATE
End date/time value.
Returns
Type
Description
INT
Difference between two dates in minutes.
diffSeconds
diffSeconds(date1: DATE, date2: DATE) → INT
Returns the difference between two dates in whole seconds.
Arguments
Name
Type
Description
date1
DATE
Start date/time value.
date2
DATE
End date/time value.
Returns
Type
Description
INT
Difference between two dates in seconds.
getTimeZone
getTimeZone() → ZoneId NOT NULL
Returns the engine's current time zone.
Returns
Type
Description
ZoneId NOT NULL
Time zone identifier.
now
now() → DATE NOT NULL
Returns the current date/time.
Returns
Type
Description
DATE NOT NULL
Result value.
timeDiffMinutes
timeDiffMinutes(a: DATE, b: DATE) → INT
Returns the minimal cyclic difference between two times in minutes (wraps at 24h).
Arguments
Name
Type
Description
a
DATE
Parameter.
b
DATE
Parameter.
Returns
Type
Description
INT
Result value.
timeDiffSeconds
timeDiffSeconds(a: DATE, b: DATE) → INT
Returns the minimal cyclic difference between two times in seconds (wraps at 24h).
Arguments
Name
Type
Description
a
DATE
Parameter.
b
DATE
Parameter.
Returns
Type
Description
INT
Result value.
toDayOfWeek
toDayOfWeek(localDateTime: LOCAL_DATE_TIME) → INT
Returns the ISO day-of-week number for the given local date/time (1=Monday..7=Sunday).
Arguments
Name
Type
Description
localDateTime
LOCAL_DATE_TIME
Input local date/time value.
Returns
Type
Description
INT
Resulting integer value.
toHour
toDayOfWeek(localDateTime: LOCAL_DATE_TIME) → INT
Extracts the hour of day from a local date/time (0..23).
Arguments
Name
Type
Description
localDateTime
LOCAL_DATE_TIME
Input local date/time value.
Returns
Type
Description
INT
Resulting integer value.
toRelativeMinuteNum
toRelativeMinuteNum(date: DATE) → INT
Returns the minute number within the day for the given date/time (0..1439).
Arguments
Name
Type
Description
date
DATE
Input date/time value.
Returns
Type
Description
INT
Resulting integer value.
toRelativeSecondNum
toRelativeSecondNum(date: DATE) → INT
Returns the second number within the day for the given date/time.
Arguments
Name
Type
Description
date
DATE
Input date/time value.
Returns
Type
Description
INT
Resulting integer value.
toTime
toTime(date: DATE) → DATE
Converts the input date/time value to the engine's DATE type.
Arguments
Name
Type
Description
date
DATE
Parameter.
Returns
Type
Description
DATE
Result value.
Date and time (period boundaries)
Use these functions to perform date and time operations related to period boundaries.
startOfMonth
startOfMonth(offset: INT NOT NULL) → DATE NOT NULL
Returns the start of the month for the current date shifted by the given month offset.
Arguments
Name
Type
Description
offset
INT NOT NULL
Month offset relative to the current month (can be negative).
Returns
Type
Description
DATE NOT NULL
A date/time value truncated/adjusted to the requested boundary.
startOfYear
startOfYear(offset: INT NOT NULL) → DATE NOT NULL
Returns the start of the year for the current date shifted by the given year offset.
Arguments
Name
Type
Description
offset
INT NOT NULL
Year offset relative to the current year (can be negative).
Returns
Type
Description
DATE NOT NULL
A date/time value truncated/adjusted to the requested boundary.
toLastDayOfMonth
toLastDayOfMonth(date: V : DATE) → V : DATE
Returns a date/time value moved to the last day of the month.
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
toStartOfDay
toStartOfDay(date: V : DATE) → V : DATE
Truncates a date/time value to the start of the day (00:00:00).
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
toStartOfHour
toStartOfHour(date: V : DATE) → V : DATE
Truncates a date/time value to the start of the hour (minutes/seconds set to zero).
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
toStartOfMonth
toStartOfMonth(date: V : DATE) → V : DATE
Truncates a date/time value to the first day of the month (start of day).
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
toStartOfWeek
toStartOfWeek(date: V : DATE) → V : DATE
Truncates a date/time value to the start of the week.
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
toStartOfYear
toStartOfYear(date: V : DATE) → V : DATE
Truncates a date/time value to the first day of the year (start of day).
Arguments
Name
Type
Description
date
V : DATE
Input date/time value.
Returns
Type
Description
V : DATE
A date/time value truncated/adjusted to the requested boundary.
Date and time (relative offsets)
Use these functions to perform date and time operations with relative offsets.
days
days(value: INT NOT NULL) → DURATION NOT NULL
Creates a duration representing the given number of days.
Arguments
Name
Type
Description
value
INT NOT NULL
Amount of days.
Returns
Type
Description
DURATION NOT NULL
A duration value.
daysAgo
daysAgo(value: INT NOT NULL) → DATE NOT NULL
Returns the date/time that is the given number of days before now.
Arguments
Name
Type
Description
value
INT NOT NULL
Offset in days.
Returns
Type
Description
DATE NOT NULL
A date/time value representing now minus the specified offset.
hours
hours(value: INT NOT NULL) → DURATION NOT NULL
Creates a duration representing the given number of hours.
Arguments
Name
Type
Description
value
INT NOT NULL
Amount of hours.
Returns
Type
Description
DURATION NOT NULL
A duration value.
hoursAgo
hoursAgo(value: INT NOT NULL) → DATE NOT NULL
Returns the date/time that is the given number of hours before now.
Arguments
Name
Type
Description
value
INT NOT NULL
Offset in hours.
Returns
Type
Description
DATE NOT NULL
A date/time value representing now minus the specified offset.
minutes
minutes(value: INT NOT NULL) → DURATION NOT NULL
Creates a duration representing the given number of minutes.
Arguments
Name
Type
Description
value
INT NOT NULL
Amount of minutes.
Returns
Type
Description
DURATION NOT NULL
Duration value.
minutesAgo
minutesAgo(value: INT NOT NULL) → DATE NOT NULL
Returns the date/time that is the given number of minutes before now.
Arguments
Name
Type
Description
value
INT NOT NULL
Offset in minutes.
Returns
Type
Description
DATE NOT NULL
A date/time value representing now minus the specified offset.
monthsAgo
monthsAgo(value: INT NOT NULL) → DATE NOT NULL
Returns the date/time that is the given number of months before now.
Arguments
Name
Type
Description
value
INT NOT NULL
Offset in months.
Returns
Type
Description
DATE NOT NULL
A date/time value representing now minus the specified offset.
seconds
seconds(value: INT NOT NULL) → DURATION NOT NULL
Creates a duration representing the given number of seconds.
Arguments
Name
Type
Description
value
INT NOT NULL
Amount of seconds.
Returns
Type
Description
DURATION NOT NULL
A duration value.
weeksAgo
weeksAgo(value: INT NOT NULL) → DATE NOT NULL
Returns the date/time that is the given number of weeks before now.
Arguments
Name
Type
Description
value
INT NOT NULL
Offset in weeks.
Returns
Type
Description
DATE NOT NULL
A date/time value representing now minus the specified offset.
Fuzzy matching
Use these functions to perform operations based on fuzzy matching.
fuzzyMatchExact
fuzzyMatchExact(str1: STRING, str2: STRING) → BOOL NOT NULL
Returns true if the normalized Levenshtein similarity of the strings is 1. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.
Arguments
Name
Type
Description
str1
STRING
First string to compare.
str2
STRING
Second string to compare.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
fuzzyMatchStrict
fuzzyMatchStrict(str1: STRING, str2: STRING) → BOOL NOT NULL
Returns true if the normalized Levenshtein similarity of the strings is0.9or higher. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.
Arguments
Name
Type
Description
str1
STRING
First string to compare.
str2
STRING
Second string to compare.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
fuzzyMatchDefault
fuzzyMatchDefault(str1: STRING, str2: STRING) → BOOL NOT NULL
Returns true if the normalized Levenshtein similarity of the two strings is0.8or higher. Before comparison, strings are normalized: converted to lowercase, with all special characters and redundant whitespace removed.
Arguments
Name
Type
Description
str1
STRING
First string to compare.
str2
STRING
Second string to compare.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
fuzzyMatchFuzzy
fuzzyMatchFuzzy(str1: STRING, str2: STRING) → BOOL NOT NULL
Returns true if the normalized Levenshtein similarity of the strings is0.6or higher. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.
Arguments
Name
Type
Description
str1
STRING
First string to compare.
str2
STRING
Second string to compare.
Returns
Type
Description
BOOL NOT NULL
Boolean result.
fuzzyMatchValue
fuzzyMatchValue(str1: STRING, str2: STRING) → FLOAT NOT NULL
Returns the normalized Levenshtein similarity of the strings as a value in the range [0.0, 1.0]. Before comparison, strings are normalized by converting to lowercase and removing special characters and redundant whitespace.
Arguments
Name
Type
Description
str1
STRING
First string to compare.
str2
STRING
Second string to compare.
Returns
Type
Description
FLOAT NOT NULL
Normalized Levenshtein similarity in the range.
Geo and spatial
Use these functions to perform geo and spatial operations.