trying to learn Typescript and using Joi with Hapi to write some API code and query validation. Ran into an issue where this works:
query: joi.object({
apiKey: joi.string().required()
})
but this does not:
query: {
apiKey: joi.string().required()
}
Does anyone know what is happening here? I get a runtime error in the second case.
Joi 16
onwards you have to wrap your schema in Joi.object
. This is the reason why it is not working in the second case. If you want to use the second way, you need to use Joi 15