Categories
javascript joi node.js validation

What is the difference between Joi.object() and Joi.object().keys()?

According to Joi documentation, you can use Joi.object() like so:

const object = Joi.object({
a: Joi.number().min(1).max(10).integer(),
b: Joi.any()
});

But you can also write an equivalent code using Joi.object().keys() like so:

const object = Joi.object().keys({
a: Joi.number().min(1).max(10).integer(),
b: Joi.any()
});

What’s the difference between the two?