What is the best way to validate dictionary containing custom keys with Joi?
var objToValidate = {
"a": { name: 1 }
"type": { name: 3 },
... // many other properties
}
var schema = ?
What is the best way to validate dictionary containing custom keys with Joi?
var objToValidate = {
"a": { name: 1 }
"type": { name: 3 },
... // many other properties
}
var schema = ?
you can use the keys
validation:
const object = Joi.object().keys({
a: Joi.number().min(1).max(10).integer(),
b: 'some string'
});
object.validate({ a: 5 , b : "word"}, (err, value) => { });