Skip to main content

Condition Tree

Condition trees are a way to define custom conditions for various Skate Results features. With condition trees, you can access variables of a given context and define conditions based on them.

Syntax​

Condition trees are written in JSON format. If you are not familiar with JSON, please check out the official JSON documentation.

A condition tree is an object with a single key-value pair. The key is the operator, and the value is an array of arguments. The arguments can be either values or other condition trees. A value can either be a string, number, boolean, null, or a reference to a variable in the context. To reference a variable, use the ref key with the variable name as the value.

{ "ref": "athlete.name" }

The following table lists all available operators and their syntax.

Syntaxarg1arg2Explanation
trueResolves to true.
falseResolves to false.
{ "or": arg1 }Array: cond. treesResolves to true, if any item of arg1 is true.
{ "and": arg1 }Array: cond. treesResolves to true, if all items of arg1 are true.
{ "not": arg1 }Condition treeResolves to the opposite of arg1.
{ ">": [arg1, arg2] }String, Number or ref.String, Number or ref.Resolves to true, if arg1 is greater than arg2.
Resolves to false, if an argument is not a number or string.
{ ">=": [arg1, arg2] }String, Number or ref.String, Number or ref.Resolves to true, if arg1 is greater or equal to arg2.
Resolves to false, if an argument is not a number.
{ "<": [arg1, arg2] }String, Number or ref.String, Number or ref.Resolves to true, if arg1 is less than arg2.
Resolve to false, if an argument is not a number.
{ "<=": [arg1, arg2] }String, Number or ref.String, Number or ref.Resolves to true, if arg1 is less or equal to arg2.
Resolves to false, if types are not numbers.
{ "==": [arg1, arg2] }Value or ref.Value or ref.Resolves to true, if arg1 equals arg2.
Resolves to false, if types of arguments are different.
{ "!=": [arg1, arg2] }Value or ref.Value or ref.Resolves to false, if arg1 does not equal arg2.
Resolves to true, if types of arguments are different.
{ "in": [arg1, arg2] }Value or ref.Array: Value or refResolves to true, if arg1 is in arg2.
Resolves to false, if types of arguments are different.
{ "not-in": [arg1, arg2] }Value or ref.Array: Value or refResolves to true, if arg1 is not in arg2.
Resolves to false, if types of arguments are different.

Date and Time Handling​

Condition trees support special handling for strings in ISO8601 format when used in comparison operators (>, >=, <, <=, ==, !=):

  • Date: YYYY-MM-DD (e.g., 2024-12-31)
  • Date Time: YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS (e.g., 2024-12-31T14:30:00 or 2024-12-31T14:30:00.123)
  • Date Time with Timezone: YYYY-MM-DDTHH:mm:ss±HH:mm, YYYY-MM-DDTHH:mm:ss.SSS±HH:mm, YYYY-MM-DDTHH:mm:ssZ, or YYYY-MM-DDTHH:mm:ss.SSSZ (e.g., 2024-12-31T14:30:00+01:00, 2024-12-31T14:30:00.123+01:00, or 2024-12-31T14:30:00Z)

Comparison Rules​

When comparing dates and times, the following rules apply:

  1. Date vs. Date Time: When a date is compared to a date time, midnight (00:00:00) is assumed for the date.

    • Example: 2024-12-31 is treated as 2024-12-31T00:00:00
  2. Timezone Handling: When a date or date time without timezone is compared to one with timezone, the event's timezone is assumed for the value without timezone.

    • Example: If the event timezone is Europe/Berlin (UTC+1), 2024-12-31T14:30:00 is treated as 2024-12-31T14:30:00+01:00

Example​

The following condition tree resolves to true, if the athlete's name is "Andi" and the athlete's gender is not "female".

{
"and": [
{ "==": [{ "ref": "athlete.name" }, "Andi"] },
{ "!=": [{ "ref": "athlete.gender" }, "female"] }
]
}

Features​

Condition trees are currently used in the following features:

  • Forms (work in progress): Conditional fields, emails, and validations
  • Livestream inserts: Conditionally show/hide sources