Wondering if this is possible with schema draft 03. I've gotten dependencies working elsewhere, I think there is possibly just some creative use of them required in order to use them for specifying the required
property of some field.
My current best attempt (which doesn't work) should give you some idea of what I'm after. I want a value required by default, and optional when another field has a particular value.
{
"description" : "An address...",
"type" : "object",
"properties" : {
"postcode": {
"type" : "string",
// postcode should be required by default
"required" : true,
// postcode shouldn't be required if the country is new zealand
"dependencies" : {
"country" : {
"enum" : ["NZ", "NZL", "NEW ZEALAND"]
},
"postcode" : {
"required" : false
}
}
},
"country": {
"type" : "string",
"enum" : [
// various country codes and names...
],
"default" : "AUS"
}
}
}