Is it possbile to extend a base schema or overwritte some keys of the base schema.
I have a base type, with many subtypes. A lot of the items are the same for all subtypes, but some keys are different and so I wanted to reuse the definition of the base type:
var base = Joi.object().keys({
type: Joi.string().required(),
x: ...
y: ....
z: Joi.object().keys({
.....
})
});
var concrete1 = clone(base);
concrete1.type = ....
concrete1. z.a = ...
Is something like this possible? If so how?
var base = Joi.object({ a: Joi.string() });
var other = base.keys({ b: Joi.number() });
Thanks!
@hueniverse I think the documentation should mention this. I just read that the keys function "Sets the allowed object keys", which sounds like it replaces any previous ones. I had to search the issues to find this solution.
You can open a PR to fix the documentation.
Done as PR #479.
Most helpful comment