{"action":"created","comment":{"url":"https://api.github.com/repos/motech-implementations/mim/pulls/comments/29863578","id":29863578,"diff_hunk":"@@ -0,0 +1,114 @@\n+package org.motechproject.nms.api.web.validator;\n+\n+import org.motechproject.nms.api.web.contract.mobileAcademy.CourseResponse;\n+import org.motechproject.nms.api.web.contract.mobileAcademy.course.Chapter;\n+import org.motechproject.nms.api.web.contract.mobileAcademy.course.Lesson;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.validation.ConstraintViolation;\n+import javax.validation.Validation;\n+import javax.validation.Validator;\n+import java.util.Set;\n+\n+\n+/**\n+ * Validator helper class for API request and response\n+ */\n+public final class MobileAcademyValidator {\n+\n+    private static final String CHAPTER_NAME_FORMAT = \"Chapter<%d>\";\n+\n+    private static final String CHAPTER_END_MENU_FORMAT = \"Chapter<%d>_EndMenu\";\n+\n+    private static final String CHAPTER_SCORE_FORMAT = \"Chapter<%d>_Score\";\n+\n+    private static final String LESSON_NAME_FORMAT = \"Lesson<%d>\";\n+\n+    private static final String LESSON_CONTENT_ID_FORMAT = \"Chapter<%d>_Lesson<%d>\";\n+\n+    private static final String LESSON_CONTENT_MENU_ID_FORMAT = \"Chapter<%d>_LessonEndMenu<LessonId>\";\n+\n+    private static final String FORMAT_ERROR = \" does not meet format requirements \";\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(MobileAcademyValidator.class);\n+\n+    /**\n+     * Private constructor for static validation helpers\n+     */\n+    private MobileAcademyValidator() {\n+\n+    }\n+\n+    public static String validateCourseResponse(CourseResponse courseResponse) {\n+        Validator validator = Validation.buildDefaultValidatorFactory().getValidator();\n+        Set<ConstraintViolation<CourseResponse>> violations = validator.validate(courseResponse);\n+        StringBuilder sb = new StringBuilder();\n+\n+        if (violations.size() > 0) {\n+            for (ConstraintViolation<CourseResponse> violation : violations) {\n+                sb.append(violation.getInvalidValue() + \" : \" +\n+                        violation.getPropertyPath() + \" - \" + violation.getMessage());\n+                sb.append(\"\\n\");\n+            }\n+\n+            return sb.toString();\n+        } else {\n+            return null;\n+        }\n+    }\n+\n+    public static boolean validateCourseFormat(CourseResponse courseResponse) {\n+\n+        int i = 1;","path":"api/src/main/java/org/motechproject/nms/api/web/validator/MobileAcademyValidator.java","position":63,"original_position":63,"commit_id":"0366679af931682714313d0ec90f8d36f37d7055","original_commit_id":"0366679af931682714313d0ec90f8d36f37d7055","user":{"login":"frankhuster","id":5107550,"avatar_url":"https://avatars.githubusercontent.com/u/5107550?v=3","gravatar_id":"","url":"https://api.github.com/users/frankhuster","html_url":"https://github.com/frankhuster","followers_url":"https://api.github.com/users/frankhuster/followers","following_url":"https://api.github.com/users/frankhuster/following{/other_user}","gists_url":"https://api.github.com/users/frankhuster/gists{/gist_id}","starred_url":"https://api.github.com/users/frankhuster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankhuster/subscriptions","organizations_url":"https://api.github.com/users/frankhuster/orgs","repos_url":"https://api.github.com/users/frankhuster/repos","events_url":"https://api.github.com/users/frankhuster/events{/privacy}","received_events_url":"https://api.github.com/users/frankhuster/received_events","type":"User","site_admin":false},"body":"maybe name the `i` & `l` variables something related to what they're supposed to represent?","created_at":"2015-05-07T15:32:31Z","updated_at":"2015-05-07T15:32:31Z","html_url":"https://github.com/motech-implementations/mim/pull/222#discussion_r29863578","pull_request_url":"https://api.github.com/repos/motech-implementations/mim/pulls/222","_links":{"self":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/comments/29863578"},"html":{"href":"https://github.com/motech-implementations/mim/pull/222#discussion_r29863578"},"pull_request":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/222"}}},"pull_request":{"url":"https://api.github.com/repos/motech-implementations/mim/pulls/222","id":34898521,"html_url":"https://github.com/motech-implementations/mim/pull/222","diff_url":"https://github.com/motech-implementations/mim/pull/222.diff","patch_url":"https://github.com/motech-implementations/mim/pull/222.patch","issue_url":"https://api.github.com/repos/motech-implementations/mim/issues/222","number":222,"state":"open","locked":false,"title":"148","user":{"login":"koshalt","id":6786794,"avatar_url":"https://avatars.githubusercontent.com/u/6786794?v=3","gravatar_id":"","url":"https://api.github.com/users/koshalt","html_url":"https://github.com/koshalt","followers_url":"https://api.github.com/users/koshalt/followers","following_url":"https://api.github.com/users/koshalt/following{/other_user}","gists_url":"https://api.github.com/users/koshalt/gists{/gist_id}","starred_url":"https://api.github.com/users/koshalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koshalt/subscriptions","organizations_url":"https://api.github.com/users/koshalt/orgs","repos_url":"https://api.github.com/users/koshalt/repos","events_url":"https://api.github.com/users/koshalt/events{/privacy}","received_events_url":"https://api.github.com/users/koshalt/received_events","type":"User","site_admin":false},"body":"Fixes #148 \r\nPartial for #88 ","created_at":"2015-05-07T09:40:11Z","updated_at":"2015-05-07T15:32:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12287656d41f91d10e9485b337a5f56434d3adb5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/motech-implementations/mim/pulls/222/commits","review_comments_url":"https://api.github.com/repos/motech-implementations/mim/pulls/222/comments","review_comment_url":"https://api.github.com/repos/motech-implementations/mim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/motech-implementations/mim/issues/222/comments","statuses_url":"https://api.github.com/repos/motech-implementations/mim/statuses/0366679af931682714313d0ec90f8d36f37d7055","head":{"label":"motech-implementations:148","ref":"148","sha":"0366679af931682714313d0ec90f8d36f37d7055","user":{"login":"motech-implementations","id":6608253,"avatar_url":"https://avatars.githubusercontent.com/u/6608253?v=3","gravatar_id":"","url":"https://api.github.com/users/motech-implementations","html_url":"https://github.com/motech-implementations","followers_url":"https://api.github.com/users/motech-implementations/followers","following_url":"https://api.github.com/users/motech-implementations/following{/other_user}","gists_url":"https://api.github.com/users/motech-implementations/gists{/gist_id}","starred_url":"https://api.github.com/users/motech-implementations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech-implementations/subscriptions","organizations_url":"https://api.github.com/users/motech-implementations/orgs","repos_url":"https://api.github.com/users/motech-implementations/repos","events_url":"https://api.github.com/users/motech-implementations/events{/privacy}","received_events_url":"https://api.github.com/users/motech-implementations/received_events","type":"Organization","site_admin":false},"repo":{"id":33508795,"name":"mim","full_name":"motech-implementations/mim","owner":{"login":"motech-implementations","id":6608253,"avatar_url":"https://avatars.githubusercontent.com/u/6608253?v=3","gravatar_id":"","url":"https://api.github.com/users/motech-implementations","html_url":"https://github.com/motech-implementations","followers_url":"https://api.github.com/users/motech-implementations/followers","following_url":"https://api.github.com/users/motech-implementations/following{/other_user}","gists_url":"https://api.github.com/users/motech-implementations/gists{/gist_id}","starred_url":"https://api.github.com/users/motech-implementations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech-implementations/subscriptions","organizations_url":"https://api.github.com/users/motech-implementations/orgs","repos_url":"https://api.github.com/users/motech-implementations/repos","events_url":"https://api.github.com/users/motech-implementations/events{/privacy}","received_events_url":"https://api.github.com/users/motech-implementations/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/motech-implementations/mim","description":"mim","fork":false,"url":"https://api.github.com/repos/motech-implementations/mim","forks_url":"https://api.github.com/repos/motech-implementations/mim/forks","keys_url":"https://api.github.com/repos/motech-implementations/mim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/motech-implementations/mim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/motech-implementations/mim/teams","hooks_url":"https://api.github.com/repos/motech-implementations/mim/hooks","issue_events_url":"https://api.github.com/repos/motech-implementations/mim/issues/events{/number}","events_url":"https://api.github.com/repos/motech-implementations/mim/events","assignees_url":"https://api.github.com/repos/motech-implementations/mim/assignees{/user}","branches_url":"https://api.github.com/repos/motech-implementations/mim/branches{/branch}","tags_url":"https://api.github.com/repos/motech-implementations/mim/tags","blobs_url":"https://api.github.com/repos/motech-implementations/mim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/motech-implementations/mim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/motech-implementations/mim/git/refs{/sha}","trees_url":"https://api.github.com/repos/motech-implementations/mim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/motech-implementations/mim/statuses/{sha}","languages_url":"https://api.github.com/repos/motech-implementations/mim/languages","stargazers_url":"https://api.github.com/repos/motech-implementations/mim/stargazers","contributors_url":"https://api.github.com/repos/motech-implementations/mim/contributors","subscribers_url":"https://api.github.com/repos/motech-implementations/mim/subscribers","subscription_url":"https://api.github.com/repos/motech-implementations/mim/subscription","commits_url":"https://api.github.com/repos/motech-implementations/mim/commits{/sha}","git_commits_url":"https://api.github.com/repos/motech-implementations/mim/git/commits{/sha}","comments_url":"https://api.github.com/repos/motech-implementations/mim/comments{/number}","issue_comment_url":"https://api.github.com/repos/motech-implementations/mim/issues/comments{/number}","contents_url":"https://api.github.com/repos/motech-implementations/mim/contents/{+path}","compare_url":"https://api.github.com/repos/motech-implementations/mim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/motech-implementations/mim/merges","archive_url":"https://api.github.com/repos/motech-implementations/mim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/motech-implementations/mim/downloads","issues_url":"https://api.github.com/repos/motech-implementations/mim/issues{/number}","pulls_url":"https://api.github.com/repos/motech-implementations/mim/pulls{/number}","milestones_url":"https://api.github.com/repos/motech-implementations/mim/milestones{/number}","notifications_url":"https://api.github.com/repos/motech-implementations/mim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/motech-implementations/mim/labels{/name}","releases_url":"https://api.github.com/repos/motech-implementations/mim/releases{/id}","created_at":"2015-04-06T22:18:18Z","updated_at":"2015-05-06T22:11:40Z","pushed_at":"2015-05-07T09:46:53Z","git_url":"git://github.com/motech-implementations/mim.git","ssh_url":"git@github.com:motech-implementations/mim.git","clone_url":"https://github.com/motech-implementations/mim.git","svn_url":"https://github.com/motech-implementations/mim","homepage":null,"size":9615,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":96,"forks":2,"open_issues":96,"watchers":0,"default_branch":"master"}},"base":{"label":"motech-implementations:master","ref":"master","sha":"1c86103e41044a8834e0adacfeb8b01c810882e0","user":{"login":"motech-implementations","id":6608253,"avatar_url":"https://avatars.githubusercontent.com/u/6608253?v=3","gravatar_id":"","url":"https://api.github.com/users/motech-implementations","html_url":"https://github.com/motech-implementations","followers_url":"https://api.github.com/users/motech-implementations/followers","following_url":"https://api.github.com/users/motech-implementations/following{/other_user}","gists_url":"https://api.github.com/users/motech-implementations/gists{/gist_id}","starred_url":"https://api.github.com/users/motech-implementations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech-implementations/subscriptions","organizations_url":"https://api.github.com/users/motech-implementations/orgs","repos_url":"https://api.github.com/users/motech-implementations/repos","events_url":"https://api.github.com/users/motech-implementations/events{/privacy}","received_events_url":"https://api.github.com/users/motech-implementations/received_events","type":"Organization","site_admin":false},"repo":{"id":33508795,"name":"mim","full_name":"motech-implementations/mim","owner":{"login":"motech-implementations","id":6608253,"avatar_url":"https://avatars.githubusercontent.com/u/6608253?v=3","gravatar_id":"","url":"https://api.github.com/users/motech-implementations","html_url":"https://github.com/motech-implementations","followers_url":"https://api.github.com/users/motech-implementations/followers","following_url":"https://api.github.com/users/motech-implementations/following{/other_user}","gists_url":"https://api.github.com/users/motech-implementations/gists{/gist_id}","starred_url":"https://api.github.com/users/motech-implementations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech-implementations/subscriptions","organizations_url":"https://api.github.com/users/motech-implementations/orgs","repos_url":"https://api.github.com/users/motech-implementations/repos","events_url":"https://api.github.com/users/motech-implementations/events{/privacy}","received_events_url":"https://api.github.com/users/motech-implementations/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/motech-implementations/mim","description":"mim","fork":false,"url":"https://api.github.com/repos/motech-implementations/mim","forks_url":"https://api.github.com/repos/motech-implementations/mim/forks","keys_url":"https://api.github.com/repos/motech-implementations/mim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/motech-implementations/mim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/motech-implementations/mim/teams","hooks_url":"https://api.github.com/repos/motech-implementations/mim/hooks","issue_events_url":"https://api.github.com/repos/motech-implementations/mim/issues/events{/number}","events_url":"https://api.github.com/repos/motech-implementations/mim/events","assignees_url":"https://api.github.com/repos/motech-implementations/mim/assignees{/user}","branches_url":"https://api.github.com/repos/motech-implementations/mim/branches{/branch}","tags_url":"https://api.github.com/repos/motech-implementations/mim/tags","blobs_url":"https://api.github.com/repos/motech-implementations/mim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/motech-implementations/mim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/motech-implementations/mim/git/refs{/sha}","trees_url":"https://api.github.com/repos/motech-implementations/mim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/motech-implementations/mim/statuses/{sha}","languages_url":"https://api.github.com/repos/motech-implementations/mim/languages","stargazers_url":"https://api.github.com/repos/motech-implementations/mim/stargazers","contributors_url":"https://api.github.com/repos/motech-implementations/mim/contributors","subscribers_url":"https://api.github.com/repos/motech-implementations/mim/subscribers","subscription_url":"https://api.github.com/repos/motech-implementations/mim/subscription","commits_url":"https://api.github.com/repos/motech-implementations/mim/commits{/sha}","git_commits_url":"https://api.github.com/repos/motech-implementations/mim/git/commits{/sha}","comments_url":"https://api.github.com/repos/motech-implementations/mim/comments{/number}","issue_comment_url":"https://api.github.com/repos/motech-implementations/mim/issues/comments{/number}","contents_url":"https://api.github.com/repos/motech-implementations/mim/contents/{+path}","compare_url":"https://api.github.com/repos/motech-implementations/mim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/motech-implementations/mim/merges","archive_url":"https://api.github.com/repos/motech-implementations/mim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/motech-implementations/mim/downloads","issues_url":"https://api.github.com/repos/motech-implementations/mim/issues{/number}","pulls_url":"https://api.github.com/repos/motech-implementations/mim/pulls{/number}","milestones_url":"https://api.github.com/repos/motech-implementations/mim/milestones{/number}","notifications_url":"https://api.github.com/repos/motech-implementations/mim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/motech-implementations/mim/labels{/name}","releases_url":"https://api.github.com/repos/motech-implementations/mim/releases{/id}","created_at":"2015-04-06T22:18:18Z","updated_at":"2015-05-06T22:11:40Z","pushed_at":"2015-05-07T09:46:53Z","git_url":"git://github.com/motech-implementations/mim.git","ssh_url":"git@github.com:motech-implementations/mim.git","clone_url":"https://github.com/motech-implementations/mim.git","svn_url":"https://github.com/motech-implementations/mim","homepage":null,"size":9615,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":96,"forks":2,"open_issues":96,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/222"},"html":{"href":"https://github.com/motech-implementations/mim/pull/222"},"issue":{"href":"https://api.github.com/repos/motech-implementations/mim/issues/222"},"comments":{"href":"https://api.github.com/repos/motech-implementations/mim/issues/222/comments"},"review_comments":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/222/comments"},"review_comment":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/motech-implementations/mim/pulls/222/commits"},"statuses":{"href":"https://api.github.com/repos/motech-implementations/mim/statuses/0366679af931682714313d0ec90f8d36f37d7055"}}}}