Built-in Functions
The engine supports a wide range of standard FEEL functions.
String Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
string | from: any | string | Converts a value to a string representation. | string(123) = "123" |
string length | string: string | number | Returns the length of a string (number of characters). | string length("foo") = 3 |
upper case | string: string | string | Converts a string to uppercase. | upper case("hello") = "HELLO" |
lower case | string: string | string | Converts a string to lowercase. | lower case("HELLO") = "hello" |
substring | string: string, start: number, length?: number | string | Returns a substring starting at the given position. | substring("hello", 2, 3) = "ell" |
substring before | string: string, match: string | string | Returns the substring before the first occurrence of match. | substring before("hello world", " ") = "hello" |
substring after | string: string, match: string | string | Returns the substring after the first occurrence of match. | substring after("hello world", " ") = "world" |
replace | input: string, pattern: string, replacement: string, flags?: string | string | Replaces occurrences of a pattern with a replacement string (supports regex). | replace("hello", "l", "L") = "heLLo" |
contains | string: string, match: string | boolean | Returns true if the string contains the match substring. | contains("hello", "ell") = true |
starts with | string: string, match: string | boolean | Returns true if the string starts with the match substring. | starts with("hello", "he") = true |
ends with | string: string, match: string | boolean | Returns true if the string ends with the match substring. | ends with("hello", "lo") = true |
string join | list: list<string>, delimiter?: string, prefix?: string, suffix?: string | string | Joins a list of strings with a delimiter. | string join(["a","b","c"], ",") = "a,b,c" |
split | string: string, delimiter: string | list<string> | Splits a string using a delimiter (regex pattern). | split("a,b,c", ",") = ["a","b","c"] |
matches | input: string, pattern: string, flags?: string | boolean | Returns true if the input matches the regex pattern. | matches("hello", "h.*o") = true |
Number Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
abs | number: number | number | Returns the absolute value of a number. | abs(-10) = 10 |
ceiling | n: number, scale?: number | number | Rounds up to the nearest integer or specified scale. | ceiling(1.4) = 2 |
floor | n: number, scale?: number | number | Rounds down to the nearest integer or specified scale. | floor(1.6) = 1 |
round up | n: number, scale: number | number | Rounds up to the specified number of decimal places. | round up(1.234, 2) = 1.24 |
round down | n: number, scale: number | number | Rounds down to the specified number of decimal places. | round down(1.236, 2) = 1.23 |
round half up | n: number, scale: number | number | Rounds to the nearest value, rounding up on .5. | round half up(1.25, 1) = 1.3 |
round half down | n: number, scale: number | number | Rounds to the nearest value, rounding down on .5. | round half down(1.25, 1) = 1.2 |
decimal | n: number, scale: number | number | Returns the decimal representation with the specified scale. | decimal(1.5, 2) = 1.50 |
modulo | dividend: number, divisor: number | number | Returns the remainder of division. | modulo(10, 3) = 1 |
sqrt | number: number | number | Returns the square root of a number. | sqrt(16) = 4 |
exp | number: number | number | Returns e raised to the power of the number. | exp(1) ≈ 2.718 |
log | number: number | number | Returns the natural logarithm of a number. | log(10) ≈ 2.303 |
even | number: number | boolean | Returns true if the number is even. | even(4) = true |
odd | number: number | boolean | Returns true if the number is odd. | odd(3) = true |
List Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
list contains | list: list, element: any | boolean | Returns true if the list contains the element. | list contains([1,2,3], 2) = true |
count | list: list | number | Returns the number of elements in a list. | count([1,2,3]) = 3 |
min | list: list<number> | number | Returns the minimum value in a list. | min([1,2,3]) = 1 |
max | list: list<number> | number | Returns the maximum value in a list. | max([1,2,3]) = 3 |
sum | list: list<number> | number | Returns the sum of all numbers in a list. | sum([1,2,3]) = 6 |
product | list: list<number> | number | Returns the product of all numbers in a list. | product([2,3,4]) = 24 |
mean | list: list<number> | number | Returns the arithmetic mean of a list of numbers. | mean([1,2,3]) = 2 |
median | list: list<number> | number | Returns the median value of a list of numbers. | median([1,2,3,4,5]) = 3 |
stddev | list: list<number> | number | Returns the standard deviation of a list of numbers. | stddev([2,4,7,5]) |
mode | list: list<number> | list<number> | Returns the mode (most frequent values) of a list. | mode([1,2,2,3]) = [2] |
all | list: list<boolean> | boolean | Returns true if all elements in the list are true. | all([true, true]) = true |
any | list: list<boolean> | boolean | Returns true if any element in the list is true. | any([false, true]) = true |
sublist | list: list, start: number, length?: number | list | Returns a sublist starting at the given position. | sublist([1,2,3,4], 2, 2) = [2,3] |
append | list: list, items...: any | list | Appends items to a list. | append([1,2], 3, 4) = [1,2,3,4] |
concatenate | list: list, lists...: list | list | Concatenates multiple lists. | concatenate([1,2], [3,4]) = [1,2,3,4] |
insert before | list: list, position: number, newItem: any | list | Inserts an element before the specified position. | insert before([1,3], 2, 2) = [1,2,3] |
remove | list: list, position: number | list | Removes an element at the specified position. | remove([1,2,3], 2) = [1,3] |
reverse | list: list | list | Reverses the order of elements in a list. | reverse([1,2,3]) = [3,2,1] |
index of | list: list, match: any | list<number> | Returns a list of positions where the match is found. | index of([1,2,3,2], 2) = [2,4] |
union | lists...: list | list | Returns the union of multiple lists (distinct values). | union([1,2], [2,3]) = [1,2,3] |
distinct values | list: list | list | Returns a list with duplicate values removed. | distinct values([1,2,2,3]) = [1,2,3] |
flatten | list: list | list | Flattens nested lists into a single list. | flatten([[1,2],[3,4]]) = [1,2,3,4] |
sort | list: list, precedes?: function | list | Sorts a list using natural order or a comparison function. | sort([3,1,2]) = [1,2,3] |
list replace | list: list, position: number, newItem: any | list | Replaces an element at the specified position. | list replace([1,2,3], 2, 5) = [1,5,3] |
Date and Time Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
date | from: string | date | Creates a date from a string or from year/month/day components. | date("2023-01-15") |
time | from: string | time | Creates a time from a string or from hour/minute/second components. | time("10:30:00") |
date and time | from: string | date and time | Creates a date-time from a string or from date and time components. | date and time("2023-01-15T10:30:00") |
duration | from: string | duration | Creates a duration from a string (ISO 8601 format). | duration("P1DT2H") |
years and months duration | from: string | years and months duration | Creates a year-month duration from a string or date parameters. | years and months duration("P1Y2M") |
day of year | date: date | number | Returns the day of the year (1-366). | day of year(date("2023-02-01")) |
month of year | date: date | string | Returns the month name. | month of year(date("2023-02-01")) = "February" |
week of year | date: date | number | Returns the week number of the year. | week of year(date("2023-02-01")) |
last day of month | date: date | date | Returns the last day of the month for a given date. | last day of month(date("2023-02-01")) |
today | `` | date | Returns the current date. | today() |
now | `` | date and time | Returns the current date and time. | now() |
Temporal Relation Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
before | point1: any, point2: any | boolean | Returns true if point1 is before point2. | before(date("2023-01-01"), date("2023-01-02")) = true |
after | point1: any, point2: any | boolean | Returns true if point1 is after point2. | after(date("2023-01-02"), date("2023-01-01")) = true |
meets | interval1: range, interval2: range | boolean | Returns true if interval1 ends exactly when interval2 starts. | meets([1..5], [5..10]) |
met by | interval1: range, interval2: range | boolean | Returns true if interval2 ends exactly when interval1 starts. | met by([5..10], [1..5]) |
overlaps | interval1: range, interval2: range | boolean | Returns true if the intervals overlap. | overlaps([1..5], [3..7]) |
overlaps before | interval1: range, interval2: range | boolean | Returns true if interval1 overlaps and ends before interval2 ends. | overlaps before([1..5], [3..7]) |
overlaps after | interval1: range, interval2: range | boolean | Returns true if interval1 overlaps and starts after interval2 starts. | overlaps after([3..7], [1..5]) |
finishes | point: any, interval: range | boolean | Returns true if point/interval finishes at the end of interval. | finishes(5, [1..5]) |
finished by | interval: range, point: any | boolean | Returns true if interval is finished by point/interval. | finished by([1..5], 5) |
includes | interval: range, point: any | boolean | Returns true if interval includes point/interval. | includes([1..10], 5) |
during | point: any, interval: range | boolean | Returns true if point/interval is during interval. | during(5, [1..10]) |
starts | point: any, interval: range | boolean | Returns true if point/interval starts at the start of interval. | starts(1, [1..5]) |
started by | interval: range, point: any | boolean | Returns true if interval is started by point/interval. | started by([1..5], 1) |
coincides | point1: any, point2: any | boolean | Returns true if two points/intervals coincide. | coincides([1..5], [1..5]) |
Context Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
get value | context: context, key: string | any | Gets a value from a context by key. | get value({a: 1}, "a") = 1 |
get entries | context: context | list<context> | Returns a list of key-value pairs from a context. | get entries({a: 1, b: 2}) |
context | entries: list | context | Creates a context from a list of key-value pairs. | context([{key: "a", value: 1}]) |
context put | context: context, key: string, value: any | context | Adds or updates a key-value pair in a context. | context put({a: 1}, "b", 2) |
context merge | contexts: list<context> | context | Merges multiple contexts into one. | context merge([{a: 1}, {b: 2}]) |
Other Functions
| Function | Parameters | Return Type | Description | Example |
|---|---|---|---|---|
is | value: any, type: string | boolean | Returns true if value is of the specified type. | is(5, "number") = true |
range | from: string | range | Creates a range from a string representation. | range("[1..10]") |
number | from: string, grouping separator?: string, decimal separator?: string | number | Converts a string to a number with optional separators. | number("1,000.50", ",", ".") |