繁体   English   中英

如何在 japi joi 中进行嵌套 object 验证

[英]how to make nested object validation in japi joi

使用嵌套 object 验证的 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM