List of objects with required values #191
-
How do you define required values in a list? I have a list of objects with a property which is an enum with 10 options. But the list must contain at least 4 items with specific field values. For example if the list is for contact information, the field property of each list object can be The list must have a telephone number either
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
"type": "array",
"items": { // this schema applies to all items
"type": "object",
"required": [ "address", "first_name", "last_name" ],
"properties": {
"address": { "type": "string", ... },
.. all your other property definitions here...
},
"oneOf": [
{ "required": [ "phone_ number" ] },
{ "required": [ "cell_ number" ] }
]
} See https://json-schema.org/understanding-json-schema/reference/combining.html and https://json-schema.org/understanding-json-schema/reference/array.html |
Beta Was this translation helpful? Give feedback.
See https://json-schema.org/understanding-json-schema/reference/combining.html and https://json-schema.org/understanding-json-schema/reference/array.html