Reputation: 77
I'm starting to use karate for testing. I need to validate one json response. JSON Schema Design:
response{
id* Integer Not null
Name* String can be null
}
now i need to verified id and name with below constraints, id should be integer and should not be null. Name can either in string or can be null.
what equation we can use in Karate.
Thanks in Advances
def jsonValidate = {name: '#integer',Name: '#present'}
so if i use Present here ,it means Name can be null
or can have value of any data type. but i need to check Name can be either String or Null Value only
Upvotes: 2
Views: 3071
Reputation: 58088
Read the docs, and try this: https://github.com/intuit/karate#optional-fields
* def jsonValidate = { id: '#number', name: '##string' }
Upvotes: 3