I am looking to represent a variety of objects in a schema through an array called contents
. This array can include any number of elements, but they must fall into one of two categories: one type represents text while the other type represents images.
Up until now, I have struggled to correctly enforce the validation. It appears that using (nested) required
within a oneOf
does not work as expected. I have also experimented with using definitions
, but it seems that approach is not quite suitable.
Despite trying out several online validators, they seem to permit me to include invalid values in the item-2
value
object. The value
property appears to be the main hindrance here. Unfortunately, due to legacy constraints, I am constrained to maintaining this as an object within an array.
Is there a way to validate and uphold the correct type and requirements for this object?
(this is not the schema, but the data itself. Unfortunately, the original json layout was designed using the keyword type
!)
{
"uuid":"780aa509-6b40-4cfe-9620-74a9659bfd59",
"contents":
[
{
"name":"item-1",
"label":"My editable text Label",
"value":"This text is editable",
"type":"text"
},
{
"name":"item-2",
"label":"My editable image label",
"index":0,
"type":"image",
"value":
[
{
"name":"1542293213356.png",
"rect":[0,0,286,286]
}
]
}
],
"version":"2.0"
}