Zum Hauptinhalt springen

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.

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