[英]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.