问题描述
在 joi 中,我知道我可以做到:
.when('propertyName',{
is: 4,then: Joi.number().required(),otherwise: Joi.number()
.strip()
.optional()
.allow(''),})
但是,与其在 propertyName
等于 4 时触发“then”,不如在 propertyName
大于 4 时触发它。我该怎么做?请注意,propertyName
可以是任何浮点数,而不仅仅是整数。
解决方法
做is: 4
而不是is: Joi.number().greater(4)