js-validator-livr
js-validator-livr copied to clipboard
How to describe a rule for a list of different objects?
I am trying to describe an object of this kind:
{
operations: [
{
properties:{
type:"1",
group: "11",
data:{data1:{},
data2:{}
}
}
},
{
properties:{
type:"2",
group: "12",
tools:["tools1","tools2"]
}
},
{
properties:{
type:"3",
group: "13",
objList:[{},{}]
}
},
{
properties:{
type:"4",
group: "14"
}
}
]
}
How can i use "variable_object" for such an object?
In general, can I validate the array as an ordered array, that is, set validation for each element?
In this example, we specify the rules depending on the value of one of the fields, but in the example above we have an array that consists of identical nested objects that differ only at the next level of nesting, and I can’t describe such an array