Version: 1.16

# Boolean expressions

### Literal​

Creates a new boolean value.

``truefalse``

### Comparison​

Two values of the same type can be compared using the following operators:

OperatorDescriptionSupported types
=equal toany
!=not equal toany
<less thannumber, date, time, date-time, duration
<=less than or equal tonumber, date, time, date-time, duration
>greater thannumber, date, time, date-time, duration
>=greater than or equalnumber, date, time, date-time, duration
between [x] and [y]same as (_ >= x and _ <= y)number, date, time, date-time, duration
``5 = 5// true5 != 5// falsedate("2020-04-05") < date("2020-04-06")// truetime("08:00:00") <= time("08:00:00")// trueduration("P1D") > duration("P5D")// falseduration("P1Y") >= duration("P6M")// true5 between 3 and 7// truedate("2020-04-06") between date("2020-04-05") and date("2020-04-09")// true``
Be Careful!

The equals operator has only one equals sign (e.g. `x = y`). In other languages, the operator has two equals signs (e.g. `x == y`).

### Null check​

Any value or variable can be compared with `null` to check if it is equal to `null`, or if it exists.

Comparing `null` to a value different from `null` results in `false`. It returns `true` if the value is `null` or the variable doesn't exist.

Comparing a context entry with `null` results in `true` if the value of the entry is `null` or if the context doesn't contain an entry with this key.

``null = null// true"foo" = null// false{x: null}.x = null// true{}.y = null// true``
tip

The built-in function is defined() can be used to differentiate between a value that is `null` and a variable or context entry that doesn't exist.

``is defined(null)// trueis defined({x: null}.x)// trueis defined({}.y)// false``

### Conjunction/and​

Combines multiple boolean values following the ternary logic.

• The result is `true` if all values are `true`.
• The result is `false` if one value is `false`.
• Otherwise, the result is `null` (i.e. if a value is not a boolean.)
``true and true// truetrue and false// falsetrue and null// nulltrue and "otherwise"// nullfalse and null// falsefalse and "otherwise"// false``

### Disjunction/or​

Combines multiple boolean values following the ternary logic.

• The result is `true` if at least one value is `true`.
• The result is `false` if all values are `false`.
• Otherwise, the result is `null` (i.e. if a value is not a boolean.)
``true or false// truefalse or false// falsetrue or null// truetrue or "otherwise"// truefalse or null// nullfalse or "otherwise"// null``

### Instance of​

Checks if the value is of the given type. Available type names:

• `boolean`
• `number`
• `string`
• `date`
• `time`
• `date and time`
• `days and time duration`
• `years and months duration`
• `list`
• `context`
• `function`
• `Any`

Use the type `Any` to check if the value is not `null`.

``1 instance of number// true1 instance of string// false1 instance of Any// truenull instance of Any// falseduration("P3M") instance of years and months duration// trueduration("PT4H") instance of days and time duration// true``

### Unary-tests/in​

Evaluates a unary-tests with the given value. The keyword `in` separates the value from the unary-tests.

``5 in (3..7)// truedate("2021-06-04") in [date("2021-05-01")..date("2021-05-31")]// false5 in (3,5,7)// true5 in [2,4,6,8]// false``