【问题标题】:how to make nested object validation in japi joi如何在 japi joi 中进行嵌套对象验证
【发布时间】: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


【解决方案1】:

你可以看看这个页面:https://www.npmjs.com/package/jsonschema 它认为它应该可以解决您的问题

【讨论】:

  • 它不会解决任何问题,关于 Joi 的问题,并且它完全能够处理许多复杂的验证模式。请在回答时考虑上下文。
猜你喜欢
  • 2016-02-19
  • 2018-02-27
  • 2021-04-15
  • 1970-01-01
  • 2019-04-30
  • 1970-01-01
  • 1970-01-01
  • 2020-06-29
  • 2019-04-14
相关资源
最近更新 更多