Joi在可选字段上需要错误消息

问题描述

我有一个端点,用户可以在其中查询

$scope.$$destroyed

/url/data?timestamp=1603885733790

以下架构正确验证了此行为:

/url/data?start=1603885730000&end=1603885733790

但是,首选选项是用户按时间戳提交请求。因此,当用户举起Joi.object({ start: Joi.when('timestamp',{ not: Joi.exist(),then: Joi.date().required(),}),end: Joi.when('timestamp',}) timestamp: Joi.date() }) 之类的无效请求时,我希望返回消息/url/data。相反,我得到了:

timestamp is required

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)