I am using validictory for validating the attached JSON data and schema. Working so far.
However the data dictionary can have arbitrary string keys (others than \'bp
It depends on exactly what you're trying to do.
If you want the same specification, but for a range of properties, you can abstract out the definition:
{
"type": "object",
"properties": {
"bp": {"$ref": "#/definitions/categoryList"},
"foo": {"$ref": "#/definitions/categoryList"},
"bar": {"$ref": "#/definitions/categoryList"}
},
"definitions": {
"categoryList": {...}
}
}
If you want any properties to follow that schema, you can use additionalProperties
:
{
"type": "object",
"additionalProperties": {...}
}
Or a range of properties (matched by a pattern) - for instance, anything lower-case:
{
"type": "object",
"patternProperties": {
"^[a-z]+$": {...}
}
}
If you want to limit the number of properties that can be defined, then you can use "maxProperties" (v4 of the standard only):
{
"type": "object",
"additionalProperties": {...},
"maxProperties": 1
}
P.S. - in v4 of the standard, "required" is an array. In fact, even in v3, "required" defaults to false
, so your example doesn't need it at all