Assert V2 allows you to create the interruption of your pipeline execution when a defined condition isn't met. This condition will be evaluated according to the items of the pipeline message, given that the Double Braces are used for it.

Tip: use Assert to guarantee a condition or interrupt the flow.

Take a look at the configuration parameters of the component:

  • Condition: when this condition isn't true, the pipeline execution is interrupted (Double Braces expressions must be used in this field).

  • Error Message: defines the error message returned by the pipeline when the condition isn't true.

  • Internal Error Message: field where you define the internal error message when the condition isn't true (it's a message for internal matters only).

  • HTTP Status Code: return status of the component.

  • Fail On Error: if activated, the option interrupts the flow when the condition results as “false”; if it's not activated and the condition results as "true", then a JSON with the specified errors is returned and the flow continues.

Messages flow

Input

The component accepts any input message and can use it through Double Braces.

Output

The component doesn't change any information of the input message when the condition is true. However, it's returned to the following component or it's used as final answer if Assert V2 is the last step of the pipeline.

When the condition is false and the property Fail On Error is “true”, the output of the component follows the standard structure:

{
"timestamp": 1587151050249,
"error": "<message declares in the config errorMessage>",
"code": <errorCode>
}

If Fail On Error is “false”:

{
"error": "<message declares in the config errorMessage>",
"internalErrorMessage": "<message declares in the config internalErrorMessage>",
"code": <errorCode>,
"success": false
}

As previously seen, you must use Double Braces expressions in the CONDITION field.

To read our article about Double Braces, click here.

Assert V2 in Action

  • {{ AND( EQUALTO(message.name, "Arthur"), LESSTHAN( message.number, 40)) }}

Receiving a message:

{
"name": "Jimmy",
"number": 39
}

The condition will result as “false”.

  • {{ AND( EQUALTO(message.name, "Arthur"), LESSTHAN( message.number, 40)) }}

Receiving a message:

{
"name": "Arthur",
"number": 39
}

The condition will result as “true”.

Did this answer your question?