title: How to validate optional query parameters in Play Framework?
body: <p>So I have a routes file that looks something like this:</p>
  
  <pre><code>GET     /myRes                 controllers.MyController.get(ids: Option[String], elems: Option[String])
  </code></pre>
  
  <p>All well and good. Users can get stuff by doing:</p>
  
  <pre><code>/myRes
  /myRes?ids=X
  /myRes?elems=Y
  /myRes?ids=X&amp;elems=Y
  </code></pre>
  
  <p>However, they can also query the interface by doing:</p>
  
  <pre><code>/myRes?id=X
  </code></pre>
  
  <p>Which is problematic, because in this case the user is gets the same result as if they had queried <code>/myRes</code>, which is almost certainly not the result they expected. This has been causing a lot of confusion/bugs for developers of the API. Is there an elegant way to catch incorrect/unspecified query parameters being passed to the controller and return a hard error for such queries?</p>
  
  <p>Edit: Changed title to something more descriptive. My problem is basically validating the query parameters to catch any query parameters passed to the API which are not valid/correct.</p>