javascript - Joi nested schemas and default values -


i'm trying joi enforce default values on secondary schema referenced another. have 2 schemas so:

const schemaa = joi.object().keys({   title: joi.string().default(''),   time: joi.number().min(1).default(5000) })  const schemab = joi.object().keys({   enabled: joi.bool().default(false),   a: schemaa }) 

what want provide object a not defined , have joi apply default values instead this:

const input = {enabled: true}  const {value} = schemab.validate(input)  //expect value equal this: const expected = {   enabled: true,   a: {     title: '',     time: 5000   } } 

the problem since key optional not enforced. want optional yet filled schemaa defaults if not present. i've been looking through documentation, can't seem find info on though i'm missing obvious. tips?


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

minify - Minimizing css files -

php - How to remove letter in front of the word laravel -