[英]how to make nested object validation in japi joi
var nestedSchema = Joi.array().items(Joi.object().keys({
title: Joi.string(),
type: Joi.string().valid(["postback", "web_url","nested"]).required(),
url: Joi.string(),
payload: Joi.string(),
{
locale: Joi.string(),
composerInputDisabled: Joi.boolean().valid([true, false]).required(),
call_to_actions: Joi.array().items(Joi.object().keys({
title: Joi.string(),
type: Joi.string().valid(["postback", "web_url", "nested"]).required(),
url: Joi.string(),
payload: Joi.string(),
call_to_actions: Joi.array().when('type', {
is: 'nested', then: nestedSchema
}).concat(Joi.array().when('type', {
is: 'nested', then: nestedSchema
})).concat(Joi.array().when('type', {
is: 'nested', then: nestedSchema
}))
}))
}?
你可以看看这个页面: https://www.npmjs.com/package/jsonschema它认为它应该可以解决你的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.