【发布时间】:2021-04-23 00:23:48
【问题描述】:
我正在 nodeJs 中编写更新端点。如果选中某些标志,我想确保不会允许其他字段。
all_restaurant: Joi.boolean().required(),
merchant_id: Joi.when('all_restaurant',{'is':false,
then: Joi.string().required(), otherwise:Joi.disallow()})
如果 all_restaurant 为真,我需要在用户尝试包含任何 Mercer_id 时抛出错误,但它仍然允许我更新。 我尝试在字段之后和顶层使用 strict() 但没有任何效果。有什么办法可以做到吗?
【问题讨论】:
标签: node.js validation joi