Given a JSON schema such as
{
"type": "object",
"properties": {
"ageInYears": {
"type": "integer",
"minimum": 0,
"maximum": 120
},
"spouseAgeInYears": {
"type": "integer",
"minimum": 0,
"maximum": 120
},
"childAgeInYears": {
"type": "integer",
"minimum": 0,
"maximum": 120
}
}
}
Notice that the attributes of each property are identical, so to avoid this repetition I'd like to somehow define a custom type
"age": {
"type": "integer",
"minimum": 0,
"maximum": 120
}
and then refer to it within my schema, e.g.
{
"type": "object",
"properties": {
"ageInYears": {
"type": "age"
},
"spouseAgeInYears": {
"type": "age"
},
"childAgeInYears": {
"type": "age"
}
}
}
It seems that the purpose of the "format" attribute is to implement this sort of type customisation, but I can't find any examples of how to define a custom "format" value.