I would like to know if I can define a JSON schema (draft 4) that requires at least one of many properties possible for an object. I already know of allOf
,
You may use minProperties: number
(and maxProperties: number
if needed).
That would shorten the schema definition:
{
type: "object",
minProperties: 1,
properties: [/* your actual properties definitions */],
}
Link to documentation: https://json-schema.org/understanding-json-schema/reference/object.html#size