hapipal / boilerplate

A friendly, proven starting place for your next hapi plugin or deployment
https://hapipal.com
183 stars 27 forks source link

Joi validation with mongoose models #89

Closed littlegraycells closed 4 years ago

littlegraycells commented 4 years ago

I've set up a project using the docs guide and I have a route set up like so

{
    method: 'POST',
    path: '/',
    options: {
        validate: {
            payload: {
                name: Joi.string().required()
            }
        },
        handler: async (request, h) => {
        }
    }
}

However this throws an error

Error: server.route() called by haute using /api/lib/routes/parent.js: Cannot set uncompiled validation rules without configuring a validator

This makes sense because unlike the Schwifty models, the mongoose models don't have Joi validation integrated. Can the documentation be updated to show how this can be done with mongoose models?