is it possible to validate an array of nested objects and their properties?
{
"text": "some text here...",
"tags": [
{
"id": "0",
"tag": "travel"
},
{
"id": "98023",
"tag": "Skydive"
}
]
}
Is validating the objects and properties in the array of tags possible??
Got it sorted ;)
const tagSchema = {
id: Joi.number(),
tag: Joi.string().min(2).regex(/^[A-Za-z]+$/).trim()
};
exports.createPostSchema = Joi.object().keys({
text: Joi.string().min(1).max(255).required().trim(),
tags: Joi.array().min(1).items(Joi.object(tagSchema)).required()
}).with('text', 'tags');
Doesn't work for me
"@hapi/joi": "^15.1.0"
Not nearly enough information to help you @oreshkoandrei, open another issue with more details.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Most helpful comment
Got it sorted ;)