Draft 04 | Draft 06 | Draft 07 | Draft 2019-09 | Draft 2020-12 |
The contains property provides additional validation rules for an array of items.
The contains property holds a schema. In order for the instance JSON document to be valid, at least one item in the array must comply with this schema.
JSON Schema |
Copy Code
|
---|---|
"AnArrayOfStrings": { "type": "array", "items": { "type": "string" }, "contains": { "type": "string", "const": "My Required Value" } }, |
The schema above specifies a property 'AnArrayOfStrings', and at least one item in the array must be a string "My Required Value".
Valid JSON instance Document |
Copy Code
|
---|---|
"AnArrayOfStrings" : [ "a", "b", "My Required Value", "x" ] |