{"action":"created","comment":{"url":"https://api.github.com/repos/yetibot/yetibot/pulls/comments/226075500","pull_request_review_id":165812205,"id":226075500,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjA3NTUwMA==","diff_hunk":"@@ -0,0 +1,52 @@\n+(ns yetibot.models.postal-code\n+  (:require\n+   [clojure.string :as str]))\n+\n+;;\n+;; Postal Code validation, qualification, and cleanup\n+;;\n+\n+(defn- nl-cleanup\n+  [d s]\n+  (str d \" \" (str/upper-case s)))\n+\n+(defn gb-cleanup\n+  [a b c d]\n+  (->> (filter #(not (nil? %)) [a b c d])\n+       (str/join \" \")\n+       str/upper-case))\n+\n+(def postal-codes\n+  {\"US\" {:re #\"(?x) (\\d{5}) (?: [-+] \\d{4} )?\"}\n+\n+   \"RO\" {:re #\"(\\d{6})\"}\n+\n+   \"BR\" {:re #\"(\\d{5}-\\d{3})\"}\n+\n+   ;; https://en.wikipedia.org/wiki/Postal_codes_in_the_Netherlands\n+   \"NL\" {:re #\"(?ix) (\\d{4}) \\s* ([a-rt-z][a-z] | s[bce-rt-z])\"\n+         :cleanup nl-cleanup}\n+   \n+   ;; https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation\n+   \"GB\" {:re #\"(?ix) (?: ([a-z][a-hj-y]?[0-9][a-z0-9]?) \\s* ([0-9][a-z]{2}) |\n+                         (gir) \\s* (0a{2}) )\"\n+         :cleanup gb-cleanup}\n+   \n+   \"AU\" {:re #\"(\\d{4})\"}\n+\n+   \"PH\" {:re #\"(\\d{4})\"}})\n+\n+(defn- pc-chk-clean\n+  [s postal-codes]\n+  (reduce-kv (fn [_ cc {:keys [:re :cleanup]}]\n+            (when-let [[_ & groups] (re-matches re s)]\n+              (let [cleanup (or cleanup (partial str))]\n+                (reduced [cc (apply cleanup groups)]))))\n+          nil\n+          postal-codes))\n+","path":"src/yetibot/models/postal_code.clj","position":47,"original_position":47,"commit_id":"88b59a07bfabfd075dca60e8ef907c168295b7a5","original_commit_id":"88b59a07bfabfd075dca60e8ef907c168295b7a5","user":{"login":"jcorrado","id":524522,"node_id":"MDQ6VXNlcjUyNDUyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/524522?v=4","gravatar_id":"","url":"https://api.github.com/users/jcorrado","html_url":"https://github.com/jcorrado","followers_url":"https://api.github.com/users/jcorrado/followers","following_url":"https://api.github.com/users/jcorrado/following{/other_user}","gists_url":"https://api.github.com/users/jcorrado/gists{/gist_id}","starred_url":"https://api.github.com/users/jcorrado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcorrado/subscriptions","organizations_url":"https://api.github.com/users/jcorrado/orgs","repos_url":"https://api.github.com/users/jcorrado/repos","events_url":"https://api.github.com/users/jcorrado/events{/privacy}","received_events_url":"https://api.github.com/users/jcorrado/received_events","type":"User","site_admin":false},"body":"Playing with this now. Thanks!","created_at":"2018-10-17T20:03:57Z","updated_at":"2018-10-17T20:03:57Z","html_url":"https://github.com/yetibot/yetibot/pull/755#discussion_r226075500","pull_request_url":"https://api.github.com/repos/yetibot/yetibot/pulls/755","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/comments/226075500"},"html":{"href":"https://github.com/yetibot/yetibot/pull/755#discussion_r226075500"},"pull_request":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/755"}},"in_reply_to_id":226034962},"pull_request":{"url":"https://api.github.com/repos/yetibot/yetibot/pulls/755","id":223649642,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNjQ5NjQy","html_url":"https://github.com/yetibot/yetibot/pull/755","diff_url":"https://github.com/yetibot/yetibot/pull/755.diff","patch_url":"https://github.com/yetibot/yetibot/pull/755.patch","issue_url":"https://api.github.com/repos/yetibot/yetibot/issues/755","number":755,"state":"open","locked":false,"title":"Add postal code model","user":{"login":"jcorrado","id":524522,"node_id":"MDQ6VXNlcjUyNDUyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/524522?v=4","gravatar_id":"","url":"https://api.github.com/users/jcorrado","html_url":"https://github.com/jcorrado","followers_url":"https://api.github.com/users/jcorrado/followers","following_url":"https://api.github.com/users/jcorrado/following{/other_user}","gists_url":"https://api.github.com/users/jcorrado/gists{/gist_id}","starred_url":"https://api.github.com/users/jcorrado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcorrado/subscriptions","organizations_url":"https://api.github.com/users/jcorrado/orgs","repos_url":"https://api.github.com/users/jcorrado/repos","events_url":"https://api.github.com/users/jcorrado/events{/privacy}","received_events_url":"https://api.github.com/users/jcorrado/received_events","type":"User","site_admin":false},"body":"I'll be using this in the upcoming weather API migration changes (#740).  Since I broke it out as a separate model, I figured I'd PR it on its own, first.\r\n\r\nI looked around for a Java lib to use but didn't turn anything up - suggestions welcome.\r\n\r\nSupports AU, BR, GB, NL, PH, RO, US.  Selected for Yetibot contributors and large English speaking populations.\r\n\r\nI'll add Canada next.  HK doesn't use postal codes, save to route mail from mainland China.","created_at":"2018-10-17T15:26:43Z","updated_at":"2018-10-17T20:03:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8c2adc449d4acd7df91c863d7f5adf527fa0691","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/yetibot/yetibot/pulls/755/commits","review_comments_url":"https://api.github.com/repos/yetibot/yetibot/pulls/755/comments","review_comment_url":"https://api.github.com/repos/yetibot/yetibot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yetibot/yetibot/issues/755/comments","statuses_url":"https://api.github.com/repos/yetibot/yetibot/statuses/88b59a07bfabfd075dca60e8ef907c168295b7a5","head":{"label":"jcorrado:add-postal-code-model","ref":"add-postal-code-model","sha":"88b59a07bfabfd075dca60e8ef907c168295b7a5","user":{"login":"jcorrado","id":524522,"node_id":"MDQ6VXNlcjUyNDUyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/524522?v=4","gravatar_id":"","url":"https://api.github.com/users/jcorrado","html_url":"https://github.com/jcorrado","followers_url":"https://api.github.com/users/jcorrado/followers","following_url":"https://api.github.com/users/jcorrado/following{/other_user}","gists_url":"https://api.github.com/users/jcorrado/gists{/gist_id}","starred_url":"https://api.github.com/users/jcorrado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcorrado/subscriptions","organizations_url":"https://api.github.com/users/jcorrado/orgs","repos_url":"https://api.github.com/users/jcorrado/repos","events_url":"https://api.github.com/users/jcorrado/events{/privacy}","received_events_url":"https://api.github.com/users/jcorrado/received_events","type":"User","site_admin":false},"repo":{"id":151431861,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE0MzE4NjE=","name":"yetibot","full_name":"jcorrado/yetibot","private":false,"owner":{"login":"jcorrado","id":524522,"node_id":"MDQ6VXNlcjUyNDUyMg==","avatar_url":"https://avatars3.githubusercontent.com/u/524522?v=4","gravatar_id":"","url":"https://api.github.com/users/jcorrado","html_url":"https://github.com/jcorrado","followers_url":"https://api.github.com/users/jcorrado/followers","following_url":"https://api.github.com/users/jcorrado/following{/other_user}","gists_url":"https://api.github.com/users/jcorrado/gists{/gist_id}","starred_url":"https://api.github.com/users/jcorrado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcorrado/subscriptions","organizations_url":"https://api.github.com/users/jcorrado/orgs","repos_url":"https://api.github.com/users/jcorrado/repos","events_url":"https://api.github.com/users/jcorrado/events{/privacy}","received_events_url":"https://api.github.com/users/jcorrado/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jcorrado/yetibot","description":":electric_plug: Extreme chatops, where chat ∈ {irc,slack} 🔧 New contributors welcome 👍","fork":true,"url":"https://api.github.com/repos/jcorrado/yetibot","forks_url":"https://api.github.com/repos/jcorrado/yetibot/forks","keys_url":"https://api.github.com/repos/jcorrado/yetibot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jcorrado/yetibot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jcorrado/yetibot/teams","hooks_url":"https://api.github.com/repos/jcorrado/yetibot/hooks","issue_events_url":"https://api.github.com/repos/jcorrado/yetibot/issues/events{/number}","events_url":"https://api.github.com/repos/jcorrado/yetibot/events","assignees_url":"https://api.github.com/repos/jcorrado/yetibot/assignees{/user}","branches_url":"https://api.github.com/repos/jcorrado/yetibot/branches{/branch}","tags_url":"https://api.github.com/repos/jcorrado/yetibot/tags","blobs_url":"https://api.github.com/repos/jcorrado/yetibot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jcorrado/yetibot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jcorrado/yetibot/git/refs{/sha}","trees_url":"https://api.github.com/repos/jcorrado/yetibot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jcorrado/yetibot/statuses/{sha}","languages_url":"https://api.github.com/repos/jcorrado/yetibot/languages","stargazers_url":"https://api.github.com/repos/jcorrado/yetibot/stargazers","contributors_url":"https://api.github.com/repos/jcorrado/yetibot/contributors","subscribers_url":"https://api.github.com/repos/jcorrado/yetibot/subscribers","subscription_url":"https://api.github.com/repos/jcorrado/yetibot/subscription","commits_url":"https://api.github.com/repos/jcorrado/yetibot/commits{/sha}","git_commits_url":"https://api.github.com/repos/jcorrado/yetibot/git/commits{/sha}","comments_url":"https://api.github.com/repos/jcorrado/yetibot/comments{/number}","issue_comment_url":"https://api.github.com/repos/jcorrado/yetibot/issues/comments{/number}","contents_url":"https://api.github.com/repos/jcorrado/yetibot/contents/{+path}","compare_url":"https://api.github.com/repos/jcorrado/yetibot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jcorrado/yetibot/merges","archive_url":"https://api.github.com/repos/jcorrado/yetibot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jcorrado/yetibot/downloads","issues_url":"https://api.github.com/repos/jcorrado/yetibot/issues{/number}","pulls_url":"https://api.github.com/repos/jcorrado/yetibot/pulls{/number}","milestones_url":"https://api.github.com/repos/jcorrado/yetibot/milestones{/number}","notifications_url":"https://api.github.com/repos/jcorrado/yetibot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jcorrado/yetibot/labels{/name}","releases_url":"https://api.github.com/repos/jcorrado/yetibot/releases{/id}","deployments_url":"https://api.github.com/repos/jcorrado/yetibot/deployments","created_at":"2018-10-03T15:06:57Z","updated_at":"2018-10-15T11:44:44Z","pushed_at":"2018-10-17T17:49:13Z","git_url":"git://github.com/jcorrado/yetibot.git","ssh_url":"git@github.com:jcorrado/yetibot.git","clone_url":"https://github.com/jcorrado/yetibot.git","svn_url":"https://github.com/jcorrado/yetibot","homepage":"https://yetibot.com","size":1711,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0","node_id":"MDc6TGljZW5zZTc="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yetibot:master","ref":"master","sha":"3c6d0af22016a0dddb928088d74a241d54e98703","user":{"login":"yetibot","id":30079520,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMDc5NTIw","avatar_url":"https://avatars2.githubusercontent.com/u/30079520?v=4","gravatar_id":"","url":"https://api.github.com/users/yetibot","html_url":"https://github.com/yetibot","followers_url":"https://api.github.com/users/yetibot/followers","following_url":"https://api.github.com/users/yetibot/following{/other_user}","gists_url":"https://api.github.com/users/yetibot/gists{/gist_id}","starred_url":"https://api.github.com/users/yetibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yetibot/subscriptions","organizations_url":"https://api.github.com/users/yetibot/orgs","repos_url":"https://api.github.com/users/yetibot/repos","events_url":"https://api.github.com/users/yetibot/events{/privacy}","received_events_url":"https://api.github.com/users/yetibot/received_events","type":"Organization","site_admin":false},"repo":{"id":2977472,"node_id":"MDEwOlJlcG9zaXRvcnkyOTc3NDcy","name":"yetibot","full_name":"yetibot/yetibot","private":false,"owner":{"login":"yetibot","id":30079520,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMDc5NTIw","avatar_url":"https://avatars2.githubusercontent.com/u/30079520?v=4","gravatar_id":"","url":"https://api.github.com/users/yetibot","html_url":"https://github.com/yetibot","followers_url":"https://api.github.com/users/yetibot/followers","following_url":"https://api.github.com/users/yetibot/following{/other_user}","gists_url":"https://api.github.com/users/yetibot/gists{/gist_id}","starred_url":"https://api.github.com/users/yetibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yetibot/subscriptions","organizations_url":"https://api.github.com/users/yetibot/orgs","repos_url":"https://api.github.com/users/yetibot/repos","events_url":"https://api.github.com/users/yetibot/events{/privacy}","received_events_url":"https://api.github.com/users/yetibot/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/yetibot/yetibot","description":":electric_plug: Extreme chatops, where chat ∈ {irc,slack} 🔧 New contributors welcome 👍","fork":false,"url":"https://api.github.com/repos/yetibot/yetibot","forks_url":"https://api.github.com/repos/yetibot/yetibot/forks","keys_url":"https://api.github.com/repos/yetibot/yetibot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yetibot/yetibot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yetibot/yetibot/teams","hooks_url":"https://api.github.com/repos/yetibot/yetibot/hooks","issue_events_url":"https://api.github.com/repos/yetibot/yetibot/issues/events{/number}","events_url":"https://api.github.com/repos/yetibot/yetibot/events","assignees_url":"https://api.github.com/repos/yetibot/yetibot/assignees{/user}","branches_url":"https://api.github.com/repos/yetibot/yetibot/branches{/branch}","tags_url":"https://api.github.com/repos/yetibot/yetibot/tags","blobs_url":"https://api.github.com/repos/yetibot/yetibot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yetibot/yetibot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yetibot/yetibot/git/refs{/sha}","trees_url":"https://api.github.com/repos/yetibot/yetibot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yetibot/yetibot/statuses/{sha}","languages_url":"https://api.github.com/repos/yetibot/yetibot/languages","stargazers_url":"https://api.github.com/repos/yetibot/yetibot/stargazers","contributors_url":"https://api.github.com/repos/yetibot/yetibot/contributors","subscribers_url":"https://api.github.com/repos/yetibot/yetibot/subscribers","subscription_url":"https://api.github.com/repos/yetibot/yetibot/subscription","commits_url":"https://api.github.com/repos/yetibot/yetibot/commits{/sha}","git_commits_url":"https://api.github.com/repos/yetibot/yetibot/git/commits{/sha}","comments_url":"https://api.github.com/repos/yetibot/yetibot/comments{/number}","issue_comment_url":"https://api.github.com/repos/yetibot/yetibot/issues/comments{/number}","contents_url":"https://api.github.com/repos/yetibot/yetibot/contents/{+path}","compare_url":"https://api.github.com/repos/yetibot/yetibot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yetibot/yetibot/merges","archive_url":"https://api.github.com/repos/yetibot/yetibot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yetibot/yetibot/downloads","issues_url":"https://api.github.com/repos/yetibot/yetibot/issues{/number}","pulls_url":"https://api.github.com/repos/yetibot/yetibot/pulls{/number}","milestones_url":"https://api.github.com/repos/yetibot/yetibot/milestones{/number}","notifications_url":"https://api.github.com/repos/yetibot/yetibot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yetibot/yetibot/labels{/name}","releases_url":"https://api.github.com/repos/yetibot/yetibot/releases{/id}","deployments_url":"https://api.github.com/repos/yetibot/yetibot/deployments","created_at":"2011-12-14T03:44:00Z","updated_at":"2018-10-17T17:11:31Z","pushed_at":"2018-10-17T17:49:14Z","git_url":"git://github.com/yetibot/yetibot.git","ssh_url":"git@github.com:yetibot/yetibot.git","clone_url":"https://github.com/yetibot/yetibot.git","svn_url":"https://github.com/yetibot/yetibot","homepage":"https://yetibot.com","size":1684,"stargazers_count":185,"watchers_count":185,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"archived":false,"open_issues_count":249,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0","node_id":"MDc6TGljZW5zZTc="},"forks":43,"open_issues":249,"watchers":185,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/755"},"html":{"href":"https://github.com/yetibot/yetibot/pull/755"},"issue":{"href":"https://api.github.com/repos/yetibot/yetibot/issues/755"},"comments":{"href":"https://api.github.com/repos/yetibot/yetibot/issues/755/comments"},"review_comments":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/755/comments"},"review_comment":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yetibot/yetibot/pulls/755/commits"},"statuses":{"href":"https://api.github.com/repos/yetibot/yetibot/statuses/88b59a07bfabfd075dca60e8ef907c168295b7a5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jcorrado"}}