{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/joi/issues/1038","repository_url":"https://api.github.com/repos/hapijs/joi","labels_url":"https://api.github.com/repos/hapijs/joi/issues/1038/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/joi/issues/1038/comments","events_url":"https://api.github.com/repos/hapijs/joi/issues/1038/events","html_url":"https://github.com/hapijs/joi/issues/1038","id":190300653,"number":1038,"title":"Can a plugin add some validations to a query parameter","user":{"login":"yamsellem","id":606754,"avatar_url":"https://avatars.githubusercontent.com/u/606754?v=3","gravatar_id":"","url":"https://api.github.com/users/yamsellem","html_url":"https://github.com/yamsellem","followers_url":"https://api.github.com/users/yamsellem/followers","following_url":"https://api.github.com/users/yamsellem/following{/other_user}","gists_url":"https://api.github.com/users/yamsellem/gists{/gist_id}","starred_url":"https://api.github.com/users/yamsellem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamsellem/subscriptions","organizations_url":"https://api.github.com/users/yamsellem/orgs","repos_url":"https://api.github.com/users/yamsellem/repos","events_url":"https://api.github.com/users/yamsellem/events{/privacy}","received_events_url":"https://api.github.com/users/yamsellem/received_events","type":"User","site_admin":false},"labels":[{"id":24848505,"url":"https://api.github.com/repos/hapijs/joi/labels/question","name":"question","color":"d4c5f9","default":true}],"state":"open","locked":false,"assignee":{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false},"assignees":[{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2016-11-18T11:46:32Z","updated_at":"2016-11-18T15:06:29Z","closed_at":null,"body":"#### Context\r\n\r\n* *node version*: 6.9.1\r\n* *joi version*: 9.2.0\r\n* *environment*: node\r\n* *used with*: hapi\r\n\r\n#### What are you trying to achieve or the steps to reproduce?\r\n\r\nCan a plugin add some validations to a query parameter — without modifying the route configuration on a live server ([as viewed here](https://github.com/hapijs/joi/issues/1025))?\r\n\r\n```js\r\n// pagination plugin\r\nconst pagination = {\r\n  register: (server, options, next) => {\r\n    server.ext('onPostAuth', (req, res) => {\r\n      ... // add the limit query params\r\n      ... // say it's a number between 1 and 100\r\n      ... // say it's optional\r\n    }\r\n}\r\n\r\n// some route\r\nserver.route({\r\n  method: 'GET',\r\n  path: '/things',\r\n  config: {\r\n    plugins: {\r\n      pagination: {},\r\n      validate: {\r\n        query: {\r\n          email: Joi.string().required()\r\n          // don't have to specify the limit query param here\r\n          // don't have to specify allowUnknown here\r\n       }\r\n     }\r\n   }\r\n}\r\n```\r\n\r\n#### Which result you had?\r\n\r\nQuery parameters validation has to be copied in every route.\r\n\r\n#### What did you expect?\r\n\r\nQuery parameters can be grouped in a dedicated plugin (or other middlewarish).\r\n\r\n_ps. nothing related, but the github template has a little english punctuation mistake: there is no space before question marks (unlike in French)._"},"comment":{"url":"https://api.github.com/repos/hapijs/joi/issues/comments/261553516","html_url":"https://github.com/hapijs/joi/issues/1038#issuecomment-261553516","issue_url":"https://api.github.com/repos/hapijs/joi/issues/1038","id":261553516,"user":{"login":"Marsup","id":796194,"avatar_url":"https://avatars.githubusercontent.com/u/796194?v=3","gravatar_id":"","url":"https://api.github.com/users/Marsup","html_url":"https://github.com/Marsup","followers_url":"https://api.github.com/users/Marsup/followers","following_url":"https://api.github.com/users/Marsup/following{/other_user}","gists_url":"https://api.github.com/users/Marsup/gists{/gist_id}","starred_url":"https://api.github.com/users/Marsup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marsup/subscriptions","organizations_url":"https://api.github.com/users/Marsup/orgs","repos_url":"https://api.github.com/users/Marsup/repos","events_url":"https://api.github.com/users/Marsup/events{/privacy}","received_events_url":"https://api.github.com/users/Marsup/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T15:06:29Z","updated_at":"2016-11-18T15:06:29Z","body":"I mean can you statically compose your schema instead of dynamically at request time ?"}}
{"actor":{"display_login":"Marsup"}}