Closed toto6321 closed 5 years ago
Hello, genius, I found that it seems the query validator doesn't work. Here is my code:
const Koa = require('koa') const app = new Koa() const router = require('koa-joi-router') const Joi = router.Joi const p = router() p.route({ path: '/', method: 'get', validate: { query: { t: Joi.string().min(3) }, body: { email: Joi.string().email() }, type: 'json' }, handler: async ctx => { ctx.body = 'hello' } }) p.prefix('/api/v1/public') app.use(p.middleware())
If the email is missed in the request body, it works very well. However, it doesn't throw any error without a t in the request query even with the email in the body. What's wrong?
validator need to append .required() ...
Hello, genius, I found that it seems the query validator doesn't work. Here is my code:
If the email is missed in the request body, it works very well. However, it doesn't throw any error without a t in the request query even with the email in the body. What's wrong?