I have objects like this that I would like to validate using validate.js:
let inventory={
id:'86366524-9781-4570-ab36-fba5e64d1d27',
items:[
{
type:'sword',
power:33,
amount:1
},
{
type:'coin',
amount:34
}
],
owner:{
name:"batman_32",
level:33,
clan:"nightwind"
}
}
To validate the id, I wrote a custom uuid validator. But for the items, I would like to write a validator that is then applied to ever element. And for the owner I just need a way to validate the nested component.
Is there a way to do this using validate.js with either a custom plugin or by writing some sort of 'drilling' validator?
Or is there a better validation library for things like this?