FEEL Syntax
Friendly Enough Expression Language (FEEL) is standardized by OMG. It is a side-effect-free expression language designed to be easy for business professionals to read and write.
Data Types
FEEL allows you to work with rich data types.
Primitive Types
| Type | Description | Examples |
|---|---|---|
| Number | High-precision decimal numbers. Supports scientific notation. | 10, -5.2, 1.5e3 |
| String | Text enclosed in double quotes. Special characters can be escaped. | "Hello World", "Bob's ID", "\u0009" |
| Boolean | Logical true or false. | true, false |
| Null | Represents a missing or unknown value. | null |
Temporal Types
FEEL has first-class support for dates and times.
Date: date("2023-12-31")
Time: time("14:30:00") or time("14:30:00@Europe/Paris")
Date and Time: date and time("2023-12-31T14:30:00")
Duration:
Day-Time: duration("P2DT5H") (2 Days, 5 Hours)
Year-Month: duration("P1Y6M") (1 Year, 6 Months)
Composite Types
Lists
Ordered collections of values. Elements can be of any type, including other lists.
[1, 2, 3, 4]
["Red", "Green", "Blue"]
[{x:1}, {x:2}]
Contexts
A set of key-value pairs, similar to a JSON object or a Map.
{
"Customer Name": "Alice",
"Age": 30,
"Address": {
"City": "New York",
"Zip": "10001"
}
}
Names
Names of variables, parameters and context entries can span several words and contain keywords, such as Monthly Payment, Risk in Category or Price for Item. Keywords and the literals true, false and null are lowercase and case sensitive, so If Missing and Between and Or are names, and so is TRUE.
A named argument puts the parameter's name before a colon:
Risk factor(Risk in Category: 3, Marital Status: "single")
Expressions
Arithmetic
Standard mathematical operations are supported.
10 + 5 // 15
10 - 2 // 8
10 * 3 // 30
20 / 4 // 5
2 ** 3 // 8 (Exponentiation)
(10 + 2) * 3 // 36
Boolean Logic
FEEL uses three-valued logic (true, false, null).
- AND:
true and true->true - OR:
true or false->true - Equality:
Price = 100 - Inequality:
Price != 100 - Comparison:
Price > 50,Price <= 200
Conditional (If-Then-Else)
Evaluates a condition and returns one of two values.
if Age >= 18 then "Adult" else "Minor"
Flow Control
For Loops
Iterate over lists to transform primitive values or objects.
for x in [1, 2, 3] return x * 2 // [2, 4, 6]
Quantified Expressions
Check if some or every element in a list satisfies a condition.
some price in [10, 20, 30] satisfies price > 25 // true
every price in [10, 20, 30] satisfies price > 5 // true
Unary Tests
Unary tests are expressions that test a single input value (implicit ?). They are primarily used in Decision Tables (in the input entries) or with the in operator.
| Test Type | Syntax | Meaning |
|---|---|---|
| Any | - | Any input matches. An input entry may not be empty, write - where a rule does not constrain the column |
| Literal | "High" | The input MUST match "High" |
| Numeric | 10 | The input MUST be 10 |
| Comparison | < 10 | The input MUST be less than 10 |
| Interval | [1..10] | Inclusive: 1 <= input <= 10 |
| Interval | (1..10) | Exclusive: 1 < input < 10 |
| Negation | not(10) | Any value EXCEPT 10 |
| List | 1, 2, 3 | Input matches any item (OR logic) |
| Generalized | not(1, 2) | Neither 1 nor 2 |
| Expression on the input | starts with(?, "PX"), ? > 10 | ? is the input. The test matches when the expression is true |
| Iteration over the input | some line in ? satisfies line.amount > 100 | ? works inside some, every and for too, here over a list input |
In lenient mode a test that fails on its input, such as a range against a null input, becomes null with a warning, and a null test does not match, so the decision table moves on to the next rule.
Runtime Errors and Null
A runtime error is an expression that parses but cannot work with the values it gets, such as string length(null), context(null), 10 / 0 or date("not a date"). What happens next depends on the error mode the deployment runs in (ERROR_MODE, see configuration):
- Strict (the default) stops the evaluation and reports where the failing part starts, for example
line 2, column 5: context: entries argument cannot be null. - Lenient follows the FEEL spec. Only the failing part becomes
null, the rest of the expression keeps its value, and the error is reported as a warning next to the result.
{a: 1, b: context(null)}
// strict: line 1, column 11: context: entries argument cannot be null
// lenient: {a: 1, b: null} with one warning
Unknown names, calling something that is not a function, and exceeding the evaluation limits are errors in both modes. A filter such as orders[amount > 100] drops an element it cannot evaluate in either mode, without a warning. is defined and get or else treat a value that fails as missing in both modes, so get or else(1 / 0, 0) is 0. Lenient mode reports that failure as a warning, strict mode does not.
Built-in Functions
FEEL includes a standard library of functions. See the built-in functions reference for the full list.
count([1, 2, 3])->3sum([10, 20])->30string length("foo")->3upper case("hello")->"HELLO"contains("foobar", "bar")->true
Comments
Code can be annotated with comments.
// This is a single line comment
10 + 10
/*
This is a
block comment
*/
Related
- FEEL overview - what FEEL is and where it runs across DMN and BPMN.
- Built-in functions - the full function reference.
- Tooling - autocomplete, validation, and hover docs in the editor.
- FEEL playground - try these expressions live in your browser.