To validate all incoming requests prior to finding a matching responder in a suite, you can take advantage of the pre-correlation output. The pre-correlation output allows executing a validation tool and storing the results in a data bank variable to use as part of request body correlation or custom correlation. This configuration allows invalid requests to be filtered out and responded to with customizable error messages, making it easy to enforce consistent validation rules across all requests without duplicating logic in each responder.


validation_error.
def correlateOnValidationError(context) {
value = context.getValue("Generated Data Source", "validation_error")
return value != null && value.length() > 0
} |

string-length("${validation_error}") > 0

{
"status": 400,
"error" : "${validation_error}"
} |
