{"action":"created","issue":{"url":"https://api.github.com/repos/ruby-grape/grape/issues/1158","labels_url":"https://api.github.com/repos/ruby-grape/grape/issues/1158/labels{/name}","comments_url":"https://api.github.com/repos/ruby-grape/grape/issues/1158/comments","events_url":"https://api.github.com/repos/ruby-grape/grape/issues/1158/events","html_url":"https://github.com/ruby-grape/grape/pull/1158","id":107216936,"number":1158,"title":"[WIP] added declared_only validator #810","user":{"login":"hobofan","id":601283,"avatar_url":"https://avatars.githubusercontent.com/u/601283?v=3","gravatar_id":"","url":"https://api.github.com/users/hobofan","html_url":"https://github.com/hobofan","followers_url":"https://api.github.com/users/hobofan/followers","following_url":"https://api.github.com/users/hobofan/following{/other_user}","gists_url":"https://api.github.com/users/hobofan/gists{/gist_id}","starred_url":"https://api.github.com/users/hobofan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hobofan/subscriptions","organizations_url":"https://api.github.com/users/hobofan/orgs","repos_url":"https://api.github.com/users/hobofan/repos","events_url":"https://api.github.com/users/hobofan/events{/privacy}","received_events_url":"https://api.github.com/users/hobofan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-18T14:47:03Z","updated_at":"2015-09-22T12:51:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ruby-grape/grape/pulls/1158","html_url":"https://github.com/ruby-grape/grape/pull/1158","diff_url":"https://github.com/ruby-grape/grape/pull/1158.diff","patch_url":"https://github.com/ruby-grape/grape/pull/1158.patch"},"body":"Only allow declared parameters as proposed in #810.\r\n\r\nWorks like this:\r\n```\r\nparams do\r\n  optional :beer\r\n  optional :wine\r\n  optional :juice\r\n  declared_only\r\nend\r\n```\r\nNow if there is a parameter present that is not `beer`, `wine` or `juice` a validation exception will be thrown.\r\nAlso tested for nested parameters.\r\n\r\nIt is not quite finished yet:\r\n - I plan on adding a `except` option to skip the validator for some parameters. Especially in combination with the bug described in #1050 / #1085 , a param that is accepted on every endpoint would have to either be declared in every params block or will throw an exception with this validator\r\n - Not tested/tried it for Arrays yet.\r\n - Some feedback on the name of `declared_only` would be nice. I not sure if it fits in well."},"comment":{"url":"https://api.github.com/repos/ruby-grape/grape/issues/comments/142278386","html_url":"https://github.com/ruby-grape/grape/pull/1158#issuecomment-142278386","issue_url":"https://api.github.com/repos/ruby-grape/grape/issues/1158","id":142278386,"user":{"login":"dblock","id":542335,"avatar_url":"https://avatars.githubusercontent.com/u/542335?v=3","gravatar_id":"","url":"https://api.github.com/users/dblock","html_url":"https://github.com/dblock","followers_url":"https://api.github.com/users/dblock/followers","following_url":"https://api.github.com/users/dblock/following{/other_user}","gists_url":"https://api.github.com/users/dblock/gists{/gist_id}","starred_url":"https://api.github.com/users/dblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dblock/subscriptions","organizations_url":"https://api.github.com/users/dblock/orgs","repos_url":"https://api.github.com/users/dblock/repos","events_url":"https://api.github.com/users/dblock/events{/privacy}","received_events_url":"https://api.github.com/users/dblock/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T12:51:02Z","updated_at":"2015-09-22T12:51:02Z","body":"I really like this. I think it needs README and CHANGELOG and it would be good to go. Testing via expecting a warning is good AFAIK."}}