簡體   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