{"action":"created","issue":{"url":"https://api.github.com/repos/finagle/finch/issues/151","labels_url":"https://api.github.com/repos/finagle/finch/issues/151/labels{/name}","comments_url":"https://api.github.com/repos/finagle/finch/issues/151/comments","events_url":"https://api.github.com/repos/finagle/finch/issues/151/events","html_url":"https://github.com/finagle/finch/pull/151","id":55824524,"number":151,"title":"Validation DSL","user":{"login":"rpless","id":2407674,"avatar_url":"https://avatars.githubusercontent.com/u/2407674?v=3","gravatar_id":"","url":"https://api.github.com/users/rpless","html_url":"https://github.com/rpless","followers_url":"https://api.github.com/users/rpless/followers","following_url":"https://api.github.com/users/rpless/following{/other_user}","gists_url":"https://api.github.com/users/rpless/gists{/gist_id}","starred_url":"https://api.github.com/users/rpless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpless/subscriptions","organizations_url":"https://api.github.com/users/rpless/orgs","repos_url":"https://api.github.com/users/rpless/repos","events_url":"https://api.github.com/users/rpless/events{/privacy}","received_events_url":"https://api.github.com/users/rpless/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-28T22:18:56Z","updated_at":"2015-01-28T23:51:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/finagle/finch/pulls/151","html_url":"https://github.com/finagle/finch/pull/151","diff_url":"https://github.com/finagle/finch/pull/151.diff","patch_url":"https://github.com/finagle/finch/pull/151.patch"},"body":"This PR has a basic validation dsl for request readers as in #26. It takes the form of a `when` method on `RequestReader`s.\r\nBasic usage looks like:\r\n```scala\r\n  val user: RequestReader[User] = for {\r\n    name <- RequiredParam(\"name\").when(\"should be greater then 5 symbols\") { name.length > 5 }\r\n  } yield User(userId, name, Seq.empty[Ticket])\r\n```\r\nWould love to get some feedback on this."},"comment":{"url":"https://api.github.com/repos/finagle/finch/issues/comments/71941923","html_url":"https://github.com/finagle/finch/pull/151#issuecomment-71941923","issue_url":"https://api.github.com/repos/finagle/finch/issues/151","id":71941923,"user":{"login":"vkostyukov","id":1098539,"avatar_url":"https://avatars.githubusercontent.com/u/1098539?v=3","gravatar_id":"","url":"https://api.github.com/users/vkostyukov","html_url":"https://github.com/vkostyukov","followers_url":"https://api.github.com/users/vkostyukov/followers","following_url":"https://api.github.com/users/vkostyukov/following{/other_user}","gists_url":"https://api.github.com/users/vkostyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkostyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkostyukov/subscriptions","organizations_url":"https://api.github.com/users/vkostyukov/orgs","repos_url":"https://api.github.com/users/vkostyukov/repos","events_url":"https://api.github.com/users/vkostyukov/events{/privacy}","received_events_url":"https://api.github.com/users/vkostyukov/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T23:51:04Z","updated_at":"2015-01-28T23:51:04Z","body":"In your example, first `radFoo` should has type `Future[Int]` instead. I think we're ok here, since `Future` is not our responsibility, but we may provide an nice syntactic sugar for our users who compose readers. \r\n\r\nRegarding the `name` field. I was solving a similar problem while working on route combinators. I decided to make it easy and use `toString` method that returns a string representation of the part of a route. Thus, I didn't need to have an extra field in the trait. I think we can go with similar approach and have `toString` method on request reader that return a string representation of the reader. It may be \"a@param\", \"b@header\", \"c@cookie\" or similar. So, we can use it in \"withFilter\" method.\r\n\r\nI just realized that we have to refactor `ValidationFailed` exception since now it's actually a `ParamValidationFailed`. We should probably consider refactor it to avoid confusions."}}