我有一个端点,用户可以在其中查询:
$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', {
not: Joi.exist(),
then: Joi.date().required(),
})
timestamp: Joi.date()
})
之类的无效请求时,我希望返回消息/url/data
。相反,我得到了:
timestamp is required