Reputation: 109
How to match the reponse having empty fields(' ') which are not passing NULL, If I try #notnull in match each response, the script is getting pass. but I see few empty fields in the response
Upvotes: 1
Views: 963
Reputation: 58088
If your server is returning blank spaces but you want to validate them as null, either you or the server is wrong.
That said, you can easily validate anything you want using Karate:
* def isBlank = function(s){ return s ? ('' + s).trim() === '' : true }
* def foo = { bar: ' ' }
* match foo == { bar: '#? isBlank(_)' }
Or you could even use a RegEx:
* match foo == { bar: '#regex [ ]*' }
Please refer to the docs.
Upvotes: 1