Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Joi conditional validation refer parent object

Joi.object({
    a: Joi.string(),
    b: Joi.object({
        c: Joi.when(Joi.ref('...a'), {is: 'foo', then: Joi.number().valid(1), otherwise: Joi.number().valid(2)})
    })
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Joi #conditional #validation #refer #parent #object
ADD COMMENT
Topic
Name
3+3 =