Javascript 如何将数学运算与Joi.ref()结合使用,以使用Joi验证对象?

Javascript 如何将数学运算与Joi.ref()结合使用,以使用Joi验证对象?,javascript,json,validation,object,joi,Javascript,Json,Validation,Object,Joi,我想使用Joi来验证对象,我使用了带有乘法运算的Joi.ref() var object = { a: 5, b: 6 } // this is wrong as Joi.ref('a')*2 is now allowed in max() var schema = Joi.object({ a: Joi.number().integer(), b: Joi.number().integer().min(1).max(Joi.ref('a')*2) }) Jo

我想使用Joi来验证对象,我使用了带有乘法运算的Joi.ref()

var object = {
    a: 5,
    b: 6
}

// this is wrong as Joi.ref('a')*2 is now allowed in max()
var schema = Joi.object({
    a: Joi.number().integer(),
    b: Joi.number().integer().min(1).max(Joi.ref('a')*2)
})
Joi.ref('a')*2
是不允许的。那么,我如何使用选项验证对象,使
b

使用选项

var schema = Joi.object({
    a: Joi.number().integer(),
    b: Joi.number().integer().min(1).max(Joi.ref('a', {
      adjust: (value) => value * 2
    }))
})