You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vars1=Joi.array().includes(Joi.number());vars2=Joi.array().includes(Joi.string());varschema=s1.concat(s2);Joi.validate([1,"a"],schema);// works fine. allow array of mixed of number and string
Concat'ing arrays of objects: (OK)
vars1=Joi.array().includes(Joi.object().keys({"x": Joi.any()}));vars2=Joi.array().includes(Joi.object().keys({"y": Joi.any()}));varschema=s1.concat(s2);Joi.validate([{"x":1,"y":2}],schema);// works fine. allow array of objects that contain both "x" and "y" properties
Concat'ing objects of arrays of objects: (not OK)
vars1=Joi.object().keys({"prop": Joi.array().includes(Joi.object().keys({"x": Joi.any()}))});vars2=Joi.object().keys({"prop": Joi.array().includes(Joi.object().keys({"y": Joi.any()}))});varschema=s1.concat(s2);Joi.validate([{"prop": []}],schema);// works fineJoi.validate([{"prop": [{"x": 1}]}],schema);// Uh-oh, prop at position 0 fails because x is not allowed
I can work around it by concat'ing the inner object first then include it into a schema of arrays
Is there a way to deep concat like this using built-in Joi.concat?
Thanks
The text was updated successfully, but these errors were encountered:
This issue has already been fixed in master and is to be released in 6.0.0 which shouldn't be too far. Meanwhile you can test if master works for your case.
Concat'ing arrays of primitive types: (OK)
Concat'ing arrays of objects: (OK)
Concat'ing objects of arrays of objects: (not OK)
I can work around it by concat'ing the inner object first then include it into a schema of arrays
Is there a way to deep concat like this using built-in Joi.concat?
Thanks
The text was updated successfully, but these errors were encountered: