Assert V1 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, through an Expression Language.

Take a look at the configuration parameters of the component:

  • Condition: condition given through the SIMPLE Expression Language, that when the condition isn't true, will interrupt the pipeline execution.

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

  • HTTP Status Code: return HTTP status of the component.

Messages flow

Input

The component accepts any input message and can use it through the SIMPLE Expression Language.

Output

The component doesn't change any information from the input message when the condition is true. Therefore, it's returned to the following component or it's used as the final output if this component is the last step of the pipeline.

When the condition isn't true, the output of this component will follow the standard pattern:

{
"timestamp": <moment of the interruption in timestamp format>,
"error": "<message configured in Error Message parameter>",
"code": <status code configured in HTTP Status Code parameter>
}

SIMPLE Technology

It's an Expression Language intended to be practical and simple to evaluate Expressions and Predicates without demanding new dependencies or JSON Path technology knowledge.

Let’s say you need to validate certain information about city that's manipulated in the pipeline:

{

"city" : "New York"

}

Only the messages that contain the field "city" within the value "New York" can be accepted. Otherwise, the pipeline execution should be interrupted.

The Condition parameter should be configured as follows:

#{city} == 'New York'

Know the other options for the SIMPLE expressions declaration:

  • ==
    Equal to

  • =~
    Equal to, case-insensitive when comparing strings.

  • >
    Greather than

  • >=
    Greater than or equal to

  • <
    Less than

  • !=
    Different

  • !=~
    Different than, case-insensitive when comparing strings

  • regex
    Validates if a string matches the specified RegEx

Eg.: #{city} regex 'New.*'

  • &&
    AND logical operator

Eg.: #{city} == 'New York' && #{state} == 'NY'

  • ||
    OR logical operator.

Eg.: #{city} == 'New York' || #{state} == 'NY'

  • contains
    Validates if a certain value is contained in a string.

Eg.: #{city} contains 'York'

Did this answer your question?