Conditional functions
Learn about conditional functions in the Digibee Integration Platform and how to use them.
The functions were created to:
Speed up the creation of your integrations even more.
Decrease the complexity of your pipelines.
Simplify data conversions and transformations during the flow of your pipelines.
The conditional functions return a value according to the criteria you establish and are available for components that support Double Braces expressions. To know how to provide information to the components using this resource, refer to Double Braces Functions.
EQUALTO
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function compares two objects (that can be numbers, strings, arrays, etc.) and verifies if they're the same.
Syntax
Let's say you need to validate if this object
is the same as this one:
In the example below the false
value will be returned, because the objects are different:
The return of this function will be true
or false
.
GREATERTHAN
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function compares if the first number is greater than the second.
Syntax
Payload
In the example below the "false" value will be returned:
The null
value is considered as the smallest possible value for comparison.
GREATERTHAN(null, null)
will return false
.
The return of this function will be true
or false
.
GREATERTHANEQUAL
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function compares if the first number is greater than or equal to the second.
Syntax
Payload
In the example below the false
value will be returned:
The null value is considered as the smallest possible value for comparison.
GREATERTHANEQUAL(null, null)
will return true
.
The return of this function will be true
or false
.
IF
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to make logical comparisons between a value and what you wait for.
Therefore, an IF instruction can have 2 results. The first result happens when the comparison is true and the second when it's false.
Syntax
Let's say you need to make decisions depending if the received value is true
or false
:
In the example below the condition value (value-if-false) will be assigned to JSON:
The return of this function will be any value provided in the messages of the true
/false
conditional.
LESSTHAN
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function compares if the first number is smaller than the second.
Syntax
Payload
In the example below the true
value will be returned:
The null
value is considered as the smallest possible value for comparison.
LESSTHAN(null, null)
will return false
.
The return of this function will be true
or false
.
LESSTHANEQUAL
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function compares if the first number is smaller than or equal to the second.
Syntax
Payload
In the example below the "true" value will be returned:
The null
value is considered as the smallest possible value for comparison.
LESSTHANEQUAL(null, null)
will return true
.
The return of this function will be "true" or "false".
ISOBJECT
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is an object.
Syntax
Let's say you need to verify if the received argument is an object:
Validating the argument:
The response will be false
, because the value isn't an object.
Now passing an object to the function:
Validating the argument:
The response will be true
.
ISARRAY
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is an array.
Syntax
Let's say you need to verify if the received argument is an array:
Validating the argument:
The response will be false
, because the value isn't an array.
Now passing an object to the function:
Validating the argument:
The response will be true
.
ISBOOLEAN
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is a boolean value.
Syntax
Let's say you need to verify if the received argument is a boolean value:
Validating the argument:
The response will be "true", because the value is boolean.
Now passing an object to the function:
Validating the argument:
The response will be “false”.
ISSTRING
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is a string.
Syntax
Let's say you need to verify if the received argument is a string:
Validating the argument:
The response will be true
, because the value is a string.
ISNUMBER
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is a number.
Syntax
Let's say you need to verify if the received argument is a number:
Validating the argument:
The response will be "true", because the value is a number.
ISNULL
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to verify if the provided argument is null
.
Syntax
Let's say you need to verify if the received argument is a null value:
Validating the argument:
The response will be true
, because the value is a null value.
SWITCHCASE
By using Double Braces, you can combine the function with the access to the input JSON element of a component.
The function allows you to provide multiple comparisons and the due parameters that must be returned if one of these validations returns true
. If no validation returns true
, the defined pattern will be used.
Syntax
Let's say you need to validate some conditions to make a decision:
Validating the argument:
Therefore, the function configuration will be:
Valor default: "failed"
Condition 1: ISNULL(message.argument)
Result If Condition 1 Matches: "ok"
Condition 2: ISNUMBER(message.argument)
Result If Condition 2 Matches: "nok"
The response will be "ok", because the first condition was met.
Other functions
You can also read about these functions:
Last updated