Assert step

Sometimes you want to assert if a certain condition evaluates to true before proceeding with the rest of the script/steps.

For example, you may want to do a Database Single Query, and you want to ensure a row was indeed found before proceeding with the rest of the steps.

The Assert step would accept the same input as the Condition step, but would throw a 500 Internal Server Error if the condition evaluates to false.

In the case of a Database Single Query, selecting the variable of the query itself would be an effective verification.

Not totally following you but can you not simulate this with the Core Actions -> Response component using it to send any response code back to app connect and terminating the sequence

3 Likes

That’s actually a pretty interesting workaround, thank you! :grin:

I’m still leaving the feature request open because, eventually, we’re hoping for the day when a 500 Internal Server Error occurs, Wappler points out the Step at which the error occured, and when that moment arrives the Assert step would be worth over the Response step :wink:

1 Like

You could also use the Validator for this, the Validate Data step you can validate data that does not come from a form, for example your query result. If it doesn’t validate it stops and returns a 400 Error to the client.

1 Like

Can you give me a screenshot example for an expression validation (boolean)? I made it like {{var1 == var2}} and placed an “Equals To” true, but didn’t seem to work properly (always failed)