Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the Joi validator as a middleware #56

Open
rochdev opened this issue Aug 23, 2017 · 0 comments
Open

Expose the Joi validator as a middleware #56

rochdev opened this issue Aug 23, 2017 · 0 comments

Comments

@rochdev
Copy link

rochdev commented Aug 23, 2017

Right now the only way to use the Joi middleware is to pass a configuration to the router. It would be more flexible to be able to use the middleware directly.

For example, instead of:

router.get('/user', config, handler)

It should be possible to do:

router.get('/user', joiMiddleware(config), handler)

This is more inline with a middleware based framework, allows the validation to be used after other middlewares, and enables wrapping and testing the validator.

I think this could be done in 2 ways. Either expose the middleware directly from the module, or extract the middleware to a joi-middleware project on which joi-router would depend. The second option is my personal favorite since it would also allow the middleware to be used with other routers. The first option however is definitely easier to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants