【发布时间】:2021-02-01 14:13:44
【问题描述】:
{
"visibleFields": {
"design.content.buttons.action.type": {
"SHOW_CLOSE": true,
"URL": true,
"CALL_PHONE": true
},
"design.content.formFields": false,
"success": false,
"design.appearance.closeButtons": true,
"design.appearance.backgroundOverlay": true,
"design.appearance.button": true,
"design.content.privacyPolicy": false,
"design.content.wheel": false,
"design.appearance.formFields": false,
"design.content.description": true,
"design.appearance.customCss": true,
"design.content.headline": true,
"design.appearance.displayEffect": true,
"design.layout.floatingbar": true,
"design.layout": true,
"design.appearance.body": true,
"design.content.buttons": true,
"design.content.images": false
}}
我有上面的 json 结构。我想使用 ref 获得“visibleFields.design.content.images”,但它不起作用。通常我可以像这样使用“visibleFields ['design.content.images']”来访问它,但我无法在架构中实现它。我该如何解决这个问题?
images: Joi.when(Joi.ref('...visibleFields.design.content.images'), {
is: false,
then: Joi.array().length(0),
otherwise: Joi.array().items(
Joi.object().keys({
type: Joi.string(),
label: Joi.string(),
backgroundColor: Joi.string(),
size: Joi.number().integer(),
horizontal: Joi.number().integer(),
vertical: Joi.number().integer(),
repeatMode: Joi.string(),
hide: Joi.boolean(),
value: Joi.string().uri(),
}),
),
})
【问题讨论】:
标签: node.js typescript joi