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

Allow validation to only be run on certain req.method types #16

Closed
djdembeck opened this issue Feb 10, 2022 · 2 comments
Closed

Allow validation to only be run on certain req.method types #16

djdembeck opened this issue Feb 10, 2022 · 2 comments

Comments

@djdembeck
Copy link

For example, I don't need GET requests to be validated, only POST.

@sergioalvz
Copy link
Member

Hey @djdembeck, that's a good point. Did you try using the next-connect package? next-joi can be easily integrated with it, and it already supports this behavior:

import connect from 'next-connect';

export default connect()
  .get(validate({}), getHandlerFunction)
  .post(validate({}), postHandlerFunction);

@djdembeck
Copy link
Author

Awesome, this does exactly what I needed, thanks!

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

No branches or pull requests

2 participants