Conditions and expressions
Conditions represent event definitions, and they outline the circumstances under which a job can be completed. A condition is a recursive data type that allows for multiple conditions within it, all of which need to resolve to true for the Job to allow execution. This complex data type includes several underlying types. For more general information on conditions, visit the concepts section. To view an example of a condition, visit the Example page. For information about conditions in templates, visit the template tutorial.
Conditions can be either a single expression, or they can be nested and chained using regular boolean operators, such as And
, Or
, or Not
.
Expressions
Expressions contain comparisons of popular data types, such as integers, unsigned integers, timestamps, booleans, strings, and more.
Values
A value is the simplest type of input used in an expression. In double-sided general expressions, the value can either be a primitive type or a query that gets a primitive type.
NumValue
NumValue
represents a numeric value that can be used in an expression with several variants:
Simple(T)
: a simple numeric value.Expr(NumExprValue<T, ExprOp, FnOp>)
: a numeric expression that can be evaluated to a numeric value. It contains aNumExprValue
struct that has a left operand, an operator, and a right operand.Ref(String)
: represents a reference to a numeric value stored elsewhere.Fn(NumFnValue<T, ExprOp, FnOp>)
: represents a function that takes a numeric value as input and returns a numeric value as output. It contains aNumFnValue
struct that has an operator and a right operand.Env(NumEnvValue)
: represents a special numeric value that is derived from the environment, such as the current block height or timestamp. It contains aNumEnvValue
enum that specifies the type of environment value.
General expressions
General expressions or GenExpr
are used to compare two values using a:
left:
value,- an operator
op:
, - and a
right:
value.
The operators of general expressions vary depending on the value type.
General expressions or GenExpr
are used to compare two values using a:
left:
value,- an operator
op:
, - and a
right:
value.
The operators of general expressions vary depending on the value type.
Only values of the same Type
can be compared when writing an expression.
String operators
The following operators are used in general expressions when comparing strings.
Number operators
The following operators are used in general expressions when comparing integers or decimals.
Time expressions
Time expressions are like regular unsigned integer expressions, except they only contain a left value and an operator. The right value is filled by a BlockHeight
or Timestamp
, depending on the value type.
Time operators
Time operators can be greater than or less than a specified time.
Block expressions
Blockheights can be specified as a Unit64
and a number operator.
Queries
In addition to being used directly in expressions, queries can also be used as variables in the Condition
and Expr
. This allows for more complex expressions that can dynamically reference and compare different types of data. For more information on queries, visit the Query page.
Bool
Queries can also be written as boolean expressions, in which a query selector is evaluated as a boolean.