-
Notifications
You must be signed in to change notification settings - Fork 96
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
ability to specify Joi validation options without using Joi objects as schemas #41
Comments
I think this sounds like a cool idea, I too like the abortEarly:false, and would like to be able to tweak the skipUnknown option. I think (in my humble opinion as a user and not a contributor) that if you have a 'stained-glass' model, where more local overwrites more global defaults with 'route' options taking precedence over global options would be super flexible. |
@kotarac I'm curious, do you have a branch with your fixes in it? I might want to try that out |
@paul42 I'll get back to you, I've since decided against using joi-router but think I still have the option 1. somewhere. |
Was looking for the same, would be a good idea to have global options. |
i'd second (more like tenth) this as well. just ran into similar issues as described by @kotarac. since this has been marked as |
@rodolfoamarques please open a PR. |
Hey there!
Considering using koa-joi-router on our next few projects.
One issue I ran into is no ability to set options for Joi other than specifying the validation as Joi objects everytime and chaining an options call.
body: joi.object({ email: joi.string().email().required(), password: joi.string().required(), }).options({abortEarly: false}),
This is a bit tedious if you want something set for every validation everywhere.
F.ex. I'd like abortEarly: false to get all validation errors at once.
The way I see it, it could be done 2 ways:
Potential problems:
These "global" options overriding individual validations sent as Joi objects with options specified (like in the example above).
I'd be willing to tackle this and submit a PR if everyone's ok with the changes - already have solution 1. ready.
The text was updated successfully, but these errors were encountered: