{"action":"created","comment":{"url":"https://api.github.com/repos/finagle/finch/pulls/comments/23855874","id":23855874,"diff_hunk":"@@ -76,7 +76,25 @@ package object request {\n     }\n \n     // A workaround for https://issues.scala-lang.org/browse/SI-1336\n-    def withFilter(p: A => Boolean) = self\n+    def withFilter(p: A => Boolean) = self.should(\"not fail validation\")(p)\n+\n+    /**\n+     * Validate the result of this ''RequestReader'' using a predicate. The rule is used for error reporting.\n+     *\n+     * @param rule Text describing the rule being validated\n+     * @param predicate Predicate that returns true if the data is valid\n+     *\n+     * @return Return a ''RequestReader'' that will return the value of from this reader if it is valid.\n+     *         Otherwise a ''RequestReaderError'' is returned as ''FutureException''.\n+     */\n+    def should(rule: String)(predicate: A => Boolean): RequestReader[A] = new RequestReader[A] {\n+      def apply[Req](req: Req)(implicit ev: Req => HttpRequest): Future[A] = {\n+        self(req).flatMap { a: A =>","path":"core/src/main/scala/io/finch/request/package.scala","position":27,"original_position":27,"commit_id":"b089ba5706fb294eb215f8d95cdb770684700cf1","original_commit_id":"b089ba5706fb294eb215f8d95cdb770684700cf1","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},"body":"The type declaration `a: A` is not necessary here.","created_at":"2015-01-30T17:10:21Z","updated_at":"2015-01-30T17:10:21Z","html_url":"https://github.com/finagle/finch/pull/151#discussion_r23855874","pull_request_url":"https://api.github.com/repos/finagle/finch/pulls/151","_links":{"self":{"href":"https://api.github.com/repos/finagle/finch/pulls/comments/23855874"},"html":{"href":"https://github.com/finagle/finch/pull/151#discussion_r23855874"},"pull_request":{"href":"https://api.github.com/repos/finagle/finch/pulls/151"}}},"pull_request":{"url":"https://api.github.com/repos/finagle/finch/pulls/151","id":28235092,"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","issue_url":"https://api.github.com/repos/finagle/finch/issues/151","number":151,"state":"open","locked":false,"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},"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.","created_at":"2015-01-28T22:18:56Z","updated_at":"2015-01-30T17:10:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9563065fd807d8fc2846eb060e10a572e7e20f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/finagle/finch/pulls/151/commits","review_comments_url":"https://api.github.com/repos/finagle/finch/pulls/151/comments","review_comment_url":"https://api.github.com/repos/finagle/finch/pulls/comments/{number}","comments_url":"https://api.github.com/repos/finagle/finch/issues/151/comments","statuses_url":"https://api.github.com/repos/finagle/finch/statuses/b089ba5706fb294eb215f8d95cdb770684700cf1","head":{"label":"rpless:validation-dsl","ref":"validation-dsl","sha":"b089ba5706fb294eb215f8d95cdb770684700cf1","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},"repo":{"id":22566885,"name":"finch","full_name":"rpless/finch","owner":{"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},"private":false,"html_url":"https://github.com/rpless/finch","description":"Purely Functional REST API atop of Finagle","fork":true,"url":"https://api.github.com/repos/rpless/finch","forks_url":"https://api.github.com/repos/rpless/finch/forks","keys_url":"https://api.github.com/repos/rpless/finch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rpless/finch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rpless/finch/teams","hooks_url":"https://api.github.com/repos/rpless/finch/hooks","issue_events_url":"https://api.github.com/repos/rpless/finch/issues/events{/number}","events_url":"https://api.github.com/repos/rpless/finch/events","assignees_url":"https://api.github.com/repos/rpless/finch/assignees{/user}","branches_url":"https://api.github.com/repos/rpless/finch/branches{/branch}","tags_url":"https://api.github.com/repos/rpless/finch/tags","blobs_url":"https://api.github.com/repos/rpless/finch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rpless/finch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rpless/finch/git/refs{/sha}","trees_url":"https://api.github.com/repos/rpless/finch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rpless/finch/statuses/{sha}","languages_url":"https://api.github.com/repos/rpless/finch/languages","stargazers_url":"https://api.github.com/repos/rpless/finch/stargazers","contributors_url":"https://api.github.com/repos/rpless/finch/contributors","subscribers_url":"https://api.github.com/repos/rpless/finch/subscribers","subscription_url":"https://api.github.com/repos/rpless/finch/subscription","commits_url":"https://api.github.com/repos/rpless/finch/commits{/sha}","git_commits_url":"https://api.github.com/repos/rpless/finch/git/commits{/sha}","comments_url":"https://api.github.com/repos/rpless/finch/comments{/number}","issue_comment_url":"https://api.github.com/repos/rpless/finch/issues/comments/{number}","contents_url":"https://api.github.com/repos/rpless/finch/contents/{+path}","compare_url":"https://api.github.com/repos/rpless/finch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rpless/finch/merges","archive_url":"https://api.github.com/repos/rpless/finch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rpless/finch/downloads","issues_url":"https://api.github.com/repos/rpless/finch/issues{/number}","pulls_url":"https://api.github.com/repos/rpless/finch/pulls{/number}","milestones_url":"https://api.github.com/repos/rpless/finch/milestones{/number}","notifications_url":"https://api.github.com/repos/rpless/finch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rpless/finch/labels{/name}","releases_url":"https://api.github.com/repos/rpless/finch/releases{/id}","created_at":"2014-08-03T04:04:29Z","updated_at":"2015-01-28T21:17:06Z","pushed_at":"2015-01-30T03:48:34Z","git_url":"git://github.com/rpless/finch.git","ssh_url":"git@github.com:rpless/finch.git","clone_url":"https://github.com/rpless/finch.git","svn_url":"https://github.com/rpless/finch","homepage":"","size":770,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"finagle:master","ref":"master","sha":"d8f37528f5c8fb15a04231e23178f3ae96b8b576","user":{"login":"finagle","id":7944306,"avatar_url":"https://avatars.githubusercontent.com/u/7944306?v=3","gravatar_id":"","url":"https://api.github.com/users/finagle","html_url":"https://github.com/finagle","followers_url":"https://api.github.com/users/finagle/followers","following_url":"https://api.github.com/users/finagle/following{/other_user}","gists_url":"https://api.github.com/users/finagle/gists{/gist_id}","starred_url":"https://api.github.com/users/finagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finagle/subscriptions","organizations_url":"https://api.github.com/users/finagle/orgs","repos_url":"https://api.github.com/users/finagle/repos","events_url":"https://api.github.com/users/finagle/events{/privacy}","received_events_url":"https://api.github.com/users/finagle/received_events","type":"Organization","site_admin":false},"repo":{"id":18798826,"name":"finch","full_name":"finagle/finch","owner":{"login":"finagle","id":7944306,"avatar_url":"https://avatars.githubusercontent.com/u/7944306?v=3","gravatar_id":"","url":"https://api.github.com/users/finagle","html_url":"https://github.com/finagle","followers_url":"https://api.github.com/users/finagle/followers","following_url":"https://api.github.com/users/finagle/following{/other_user}","gists_url":"https://api.github.com/users/finagle/gists{/gist_id}","starred_url":"https://api.github.com/users/finagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finagle/subscriptions","organizations_url":"https://api.github.com/users/finagle/orgs","repos_url":"https://api.github.com/users/finagle/repos","events_url":"https://api.github.com/users/finagle/events{/privacy}","received_events_url":"https://api.github.com/users/finagle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/finagle/finch","description":"Purely Functional REST API atop of Finagle","fork":false,"url":"https://api.github.com/repos/finagle/finch","forks_url":"https://api.github.com/repos/finagle/finch/forks","keys_url":"https://api.github.com/repos/finagle/finch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finagle/finch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finagle/finch/teams","hooks_url":"https://api.github.com/repos/finagle/finch/hooks","issue_events_url":"https://api.github.com/repos/finagle/finch/issues/events{/number}","events_url":"https://api.github.com/repos/finagle/finch/events","assignees_url":"https://api.github.com/repos/finagle/finch/assignees{/user}","branches_url":"https://api.github.com/repos/finagle/finch/branches{/branch}","tags_url":"https://api.github.com/repos/finagle/finch/tags","blobs_url":"https://api.github.com/repos/finagle/finch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finagle/finch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finagle/finch/git/refs{/sha}","trees_url":"https://api.github.com/repos/finagle/finch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finagle/finch/statuses/{sha}","languages_url":"https://api.github.com/repos/finagle/finch/languages","stargazers_url":"https://api.github.com/repos/finagle/finch/stargazers","contributors_url":"https://api.github.com/repos/finagle/finch/contributors","subscribers_url":"https://api.github.com/repos/finagle/finch/subscribers","subscription_url":"https://api.github.com/repos/finagle/finch/subscription","commits_url":"https://api.github.com/repos/finagle/finch/commits{/sha}","git_commits_url":"https://api.github.com/repos/finagle/finch/git/commits{/sha}","comments_url":"https://api.github.com/repos/finagle/finch/comments{/number}","issue_comment_url":"https://api.github.com/repos/finagle/finch/issues/comments/{number}","contents_url":"https://api.github.com/repos/finagle/finch/contents/{+path}","compare_url":"https://api.github.com/repos/finagle/finch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finagle/finch/merges","archive_url":"https://api.github.com/repos/finagle/finch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finagle/finch/downloads","issues_url":"https://api.github.com/repos/finagle/finch/issues{/number}","pulls_url":"https://api.github.com/repos/finagle/finch/pulls{/number}","milestones_url":"https://api.github.com/repos/finagle/finch/milestones{/number}","notifications_url":"https://api.github.com/repos/finagle/finch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finagle/finch/labels{/name}","releases_url":"https://api.github.com/repos/finagle/finch/releases{/id}","created_at":"2014-04-15T12:17:44Z","updated_at":"2015-01-30T17:05:38Z","pushed_at":"2015-01-30T17:05:41Z","git_url":"git://github.com/finagle/finch.git","ssh_url":"git@github.com:finagle/finch.git","clone_url":"https://github.com/finagle/finch.git","svn_url":"https://github.com/finagle/finch","homepage":"http://finagle.github.io/finch/docs/#io.finch.route.package","size":2431,"stargazers_count":184,"watchers_count":184,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":13,"forks":15,"open_issues":13,"watchers":184,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/finagle/finch/pulls/151"},"html":{"href":"https://github.com/finagle/finch/pull/151"},"issue":{"href":"https://api.github.com/repos/finagle/finch/issues/151"},"comments":{"href":"https://api.github.com/repos/finagle/finch/issues/151/comments"},"review_comments":{"href":"https://api.github.com/repos/finagle/finch/pulls/151/comments"},"review_comment":{"href":"https://api.github.com/repos/finagle/finch/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/finagle/finch/pulls/151/commits"},"statuses":{"href":"https://api.github.com/repos/finagle/finch/statuses/b089ba5706fb294eb215f8d95cdb770684700cf1"}}}}