-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
payload validation for routes that have multiple method arguments #2659
Comments
I would advise making those routes separately. Payload validation doesn't make sense for GET requests. |
The right solution as @mtharrison said is to split it. |
@mtharrison @hueniverse just wanted to reduce the amount of boilerplate... seems redundant to have duplicate route properties just because of one separate property, no? isn't that the point of allowing What about allowing server.route({
method: [ 'GET', 'POST' ],
config: {
validate: [
{
query: {
value: Joi.string().required()
}
},
{
payload: {
value: Joi.string().required()
}
}
]
}
}); ...or a more explicit alternative? server.route({
method: [ 'GET', 'POST' ],
config: {
validate: {
GET: {
query: {
value: Joi.string().required()
}
},
POST: {
payload: {
value: Joi.string().required()
}
}
}
}
}); |
Method array makes sense when the routes are really identical. It is really just a shortcut and internally it is the same as adding two completely separate routes. In this case verbosity is better. |
@hueniverse The routes are near-identical with the exception of the method and validation. the handler, path, etc. are all the same. So, verbosity in the 2nd proposed solution makes sense? |
I am not going to add this. Multiple methods is a simple shortcut. If you need more, either write your own helper or just repeat the route. |
Is there a way to handle
payload
validation for routes that have multiplemethod
arguments?I get the following error:
Cannot validate HEAD or GET requests
v8.8.0
The text was updated successfully, but these errors were encountered: