Based on the given JSON schema, If I have to build "required" for the 'DayActivity' based on the 'Day' selected in DayHeader (e.g Only PhysicalActivity should be required If Day is SUNDAY) , how do i build the JSON schema? I've tried various approaches such if then else and definitions. When I generate JSON file based on the JSON schema, it couldn't validate the required 'DayActivity' selected by the "Day" attribute. Basically how do I refer the value selected in other property and build "required"? Appreciate any reference for this issue.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"DayHeader": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Day": {
"type": "string",
"enum": [
"SUNDAY",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY"
]
}
},
"required": [
"day"
]
},
"ActivityDetail": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"DayActivity": {
"type": "array",
"items": {
"type": "object",
"properties": {
"PhysicalActivity": {
"type": "string",
"enum": [
"Walking",
"Running"
]
},
"StudyActivity": {
"type": "string",
"enum": [
"Maths Class",
"Science Class"
]
},
"ArtActivity": {
"type": "string",
"enum": [
"Drawing",
"Dance"
]
}
}
}
}
}
}
}
}