【发布时间】:2020-02-21 01:45:13
【问题描述】:
使用嵌套对象验证 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
}))
}))
}?
【问题讨论】:
-
您能详细说明您到底需要什么吗?
标签: javascript typescript hapijs joi