OS: Max OS X 10.12.2
Node version: 8.6.0
npm version: 5.2.0
koa version: 2.4.1
koa-joi-router version: 5.0.0
joi version: 9.2.0
I have the following route:
module.exports = {
method: 'get',
path: '/',
validate: {
query: Joi.object().keys({
search: Joi.string(),
sort: Joi.object().default({ 'name': 1 }),
}),
},
handler: async (ctx) => {
const { sort } = ctx.query;
console.log(sort);
ctx.status = 200;
},
};
The actual behavior:
when I specify a query string ex. ?search=foo, I get the correct default value for sort parameter, however for no query string I get undefined
The expected behavior:
even for no query string, the sort parameter should have { 'name': 1 } as default value