samuel_perez
9 years agoOccasional Contributor
ServiceV and assertions - need to refer to assertion text that fired
I have a list of assertions defined on my VIRT for the list of required fields, i would like to send back a dynamic and accurate error message that indicates which field is missing , is there a way ...
- 9 years ago
Hiya
not sure how you've setup your assertions so don't know if there's a way of getting the info to return in a response message
but rather than creating a bunch of code you could list the fields in a DS then iterate over the list and dynamically create and update a property appending any missing fields, this can then be easily referenced in a response if any are missing, one bit of code for all then rather than a bespoke 'bunch' of code
create your list of missing fields then add to property
set property
context.mockService.setPropertyValue('failedParams',MISSINGFIELDS)
use property within response
{
"Missing fields": "${#MockService#failedParams}"
}