I have an array filters-detail
with objects in it. These objects should include the values of the other properties filters-applied
and applied-second
. I use AJV and tried to use two $data
objects but it fails.
{
"additionalProperties": false,
"type": "object",
"properties": {
"filters-applied": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"maxLength": 255
}
},
"applied-second": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"maxLength": 255
}
},
"filters-detail": {
"type": "array",
"items": {
"type": "object",
"required": [
{
"$data": "2/filters-applied"
},
{
"$data": "2/applied-second"
}
]
}
}
}
}
Example data that should be valid:
{
"filters-applied": ["color", "size"],
"applied-second": ["brand"],
"filters-detail": [{ color: ["red", "blue"], size: "XS", brand: "Boss" }],
}
I managed to get only one requirement working:
"filters-detail": {
"type": "array",
"items": {
"type": "object",
"required": {
"$data": "2/filters-applied"
}
}
}
Noticeable are the missing []
, but I don't know how to leave them and add two objects to required
without violating against the JSON structure.
I need to depend on two other properties. How can I achieve this?