Below is a sample JSON I need to validate -
{
"request": {
"hdr": {
"version": "1.0"
},
"bd": {
"id": 1,
"name": "test",
"address": "test",
"items": {
"code": "PP"
}
}
}
}
with dependency conditions as below -
1) request.bd.name field should be present only when request.hdr.version is 1.4. For any other version this is an invalid field and should not be present in JSON.
2) request.bd.address field max length should be 50 in case request.bd.items.code is PP but should be 60 in case of any other value.
I referred to jsonSchema attribute conditionally required but that seems to be deal with a simple case where all elements are in the same level.
I am not sure how to implement this in my scenario where fields in one subschema are dependent on fields in another parallel subschema.
Please help advise.
I am planning to use https://github.com/everit-org/json-schema for validation but I think the JSON schema would be more or less the same irrespective of the JSON validation implementation selected.