How to allow any other key in Joi [duplicate] How to allow any other key in Joi [duplicate] javascript javascript

How to allow any other key in Joi [duplicate]


The correct answer is actually to use object.unknown(true).

const schema = Joi.object().keys({  a: Joi.string().required(),  b: Joi.string().required()}).unknown(true);


You can add unknown keys using object.pattern(regex, schema) this way IF you want to make sure these unknown keys are strings:

const schema = Joi.object().keys({  a: Joi.string().required(),  b: Joi.string().required()}).pattern(/./, Joi.string());