{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/19565","labels_url":"https://api.github.com/repos/rails/rails/issues/19565/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/19565/comments","events_url":"https://api.github.com/repos/rails/rails/issues/19565/events","html_url":"https://github.com/rails/rails/pull/19565","id":64910749,"number":19565,"title":"[Feature] require_all parameters or raise error","user":{"login":"gaurish","id":235844,"avatar_url":"https://avatars.githubusercontent.com/u/235844?v=3","gravatar_id":"","url":"https://api.github.com/users/gaurish","html_url":"https://github.com/gaurish","followers_url":"https://api.github.com/users/gaurish/followers","following_url":"https://api.github.com/users/gaurish/following{/other_user}","gists_url":"https://api.github.com/users/gaurish/gists{/gist_id}","starred_url":"https://api.github.com/users/gaurish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaurish/subscriptions","organizations_url":"https://api.github.com/users/gaurish/orgs","repos_url":"https://api.github.com/users/gaurish/repos","events_url":"https://api.github.com/users/gaurish/events{/privacy}","received_events_url":"https://api.github.com/users/gaurish/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/actionpack","name":"actionpack","color":"FFF700"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-03-28T06:48:21Z","updated_at":"2015-04-06T14:17:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/19565","html_url":"https://github.com/rails/rails/pull/19565","diff_url":"https://github.com/rails/rails/pull/19565.diff","patch_url":"https://github.com/rails/rails/pull/19565.patch"},"body":"This PR adds a method `require_all` which allows you to require multiple values in one method.\r\n\r\nfor example, in our app. I have a person object which MUST have first_name & last_name. so to do this in current code, I have to write this:\r\n\r\n```ruby\r\nparams.require(:person).require(:first_name)\r\nparams.require(:person).require(:last_name)\r\n```\r\n\r\nHere it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not DRY. So I propose a method which does this in one line:\r\n\r\n```ruby\r\nparams.require(:person).require_all(:first_name, :last_name)\r\n```\r\n\r\nComments welcome"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/90079672","html_url":"https://github.com/rails/rails/pull/19565#issuecomment-90079672","issue_url":"https://api.github.com/repos/rails/rails/issues/19565","id":90079672,"user":{"login":"fxn","id":3387,"avatar_url":"https://avatars.githubusercontent.com/u/3387?v=3","gravatar_id":"","url":"https://api.github.com/users/fxn","html_url":"https://github.com/fxn","followers_url":"https://api.github.com/users/fxn/followers","following_url":"https://api.github.com/users/fxn/following{/other_user}","gists_url":"https://api.github.com/users/fxn/gists{/gist_id}","starred_url":"https://api.github.com/users/fxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fxn/subscriptions","organizations_url":"https://api.github.com/users/fxn/orgs","repos_url":"https://api.github.com/users/fxn/repos","events_url":"https://api.github.com/users/fxn/events{/privacy}","received_events_url":"https://api.github.com/users/fxn/received_events","type":"User","site_admin":false},"created_at":"2015-04-06T14:17:24Z","updated_at":"2015-04-06T14:17:24Z","body":"Yeah, take into account in the previous example the action uses `safe_params[:person]`.\r\n\r\nAlso, conceptually, for me request validation is not really about business rules (although it is of course related to them). In my mind the server publishes a spec, client code must conform to that spec, and the server validates that an API request conforms to said spec, otherwise it is not passed down. That's for me request validation, and it is something strong parameters does not do as of today.\r\n\r\nAnyway, that's how I'd evolve (or not evolve) strong parameters and it's fine of course that we have different points of view. I understand the approach of doing just that little thing, and I being able to declare nested required keys (for only one root key) it's a normal extension to the current API `require`.\r\n"}}