{"action":"created","comment":{"url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/comments/230024089","pull_request_review_id":170657027,"id":230024089,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDAyNDA4OQ==","diff_hunk":"@@ -25,6 +29,41 @@ class Meta:\n         # or response, including fields specified explicitly above.\n         fields = ['email', 'username', 'password']\n \n+    def validate_email(self, value):\n+        user_email_db = User.objects.filter(email=value)\n+        if user_email_db.exists():\n+            raise serializers.ValidationError(\"Email already in use\")\n+        return value\n+\n+    def validate_password(self, value):\n+        if len(value) < 8:\n+            raise serializers.ValidationError(\n+                \"Weak password. Password should be atleast 8 characters long\")\n+        elif len(value) > 25:\n+            raise serializers.ValidationError(\n+                \"Password can not be more than 25 caharacters\")\n+        elif not re.search(r'[0-9]', value):\n+            raise serializers.ValidationError(\n+                \"Weak password. Include atleast one integer\")\n+        elif value.isupper() or value.islower():\n+            raise serializers.ValidationError(\n+                \"Password should contain both upper and lower cases\")\n+        elif value.isdigit():\n+            raise serializers.ValidationError(\n+                \"Password can not contain only integers\")\n+        return value\n+\n+    def validate_username(self, value):\n+        username_db = User.objects.filter(username=value)\n+        if username_db.exists():\n+            raise serializers.ValidationError(\"Username already in use\")\n+        elif len(value) <= 2 or len(value) > 25:\n+            raise serializers.ValidationError(","path":"authors/apps/authentication/serializers.py","position":57,"original_position":57,"commit_id":"01ab6c49f7ceb71da5fcde0bb65d284770321082","original_commit_id":"01ab6c49f7ceb71da5fcde0bb65d284770321082","user":{"login":"krmroland","id":33207024,"node_id":"MDQ6VXNlcjMzMjA3MDI0","avatar_url":"https://avatars2.githubusercontent.com/u/33207024?v=4","gravatar_id":"","url":"https://api.github.com/users/krmroland","html_url":"https://github.com/krmroland","followers_url":"https://api.github.com/users/krmroland/followers","following_url":"https://api.github.com/users/krmroland/following{/other_user}","gists_url":"https://api.github.com/users/krmroland/gists{/gist_id}","starred_url":"https://api.github.com/users/krmroland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krmroland/subscriptions","organizations_url":"https://api.github.com/users/krmroland/orgs","repos_url":"https://api.github.com/users/krmroland/repos","events_url":"https://api.github.com/users/krmroland/events{/privacy}","received_events_url":"https://api.github.com/users/krmroland/received_events","type":"User","site_admin":false},"body":"The same goes for a username, I think setting unique to true in the model when defining the fields guarantees it will always be unique, in times when you want to add more validation constraints, adding custom  validators would be more practicle  than rewriting the whole thing.  [You can Read more  here](https://www.django-rest-framework.org/api-guide/validators/#writing-custom-validators)","created_at":"2018-11-01T12:21:48Z","updated_at":"2018-11-01T12:22:17Z","html_url":"https://github.com/andela/ah-backend-odin/pull/14#discussion_r230024089","pull_request_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/comments/230024089"},"html":{"href":"https://github.com/andela/ah-backend-odin/pull/14#discussion_r230024089"},"pull_request":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14","id":227275304,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3Mjc1MzA0","html_url":"https://github.com/andela/ah-backend-odin/pull/14","diff_url":"https://github.com/andela/ah-backend-odin/pull/14.diff","patch_url":"https://github.com/andela/ah-backend-odin/pull/14.patch","issue_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/14","number":14,"state":"open","locked":false,"title":"#161340173 Users should receive descriptive signup validation errors","user":{"login":"nakatuddesuzan","id":39129473,"node_id":"MDQ6VXNlcjM5MTI5NDcz","avatar_url":"https://avatars1.githubusercontent.com/u/39129473?v=4","gravatar_id":"","url":"https://api.github.com/users/nakatuddesuzan","html_url":"https://github.com/nakatuddesuzan","followers_url":"https://api.github.com/users/nakatuddesuzan/followers","following_url":"https://api.github.com/users/nakatuddesuzan/following{/other_user}","gists_url":"https://api.github.com/users/nakatuddesuzan/gists{/gist_id}","starred_url":"https://api.github.com/users/nakatuddesuzan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nakatuddesuzan/subscriptions","organizations_url":"https://api.github.com/users/nakatuddesuzan/orgs","repos_url":"https://api.github.com/users/nakatuddesuzan/repos","events_url":"https://api.github.com/users/nakatuddesuzan/events{/privacy}","received_events_url":"https://api.github.com/users/nakatuddesuzan/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nGive a user descriptive signup validation errors\r\n#### Description of Task to be completed?\r\nUsers should receive a descriptive error message when they enter invalid user parameters in an attempt to signup for example when a user signs up with an existing email address\r\n#### What are the relevant pivotal tracker stories?\r\n[#161340173](https://www.pivotaltracker.com/story/show/161340173)","created_at":"2018-10-31T12:57:12Z","updated_at":"2018-11-01T12:22:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eea698c2111645b25939d73d19cf23fa351d8ec0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14/commits","review_comments_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14/comments","review_comment_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/14/comments","statuses_url":"https://api.github.com/repos/andela/ah-backend-odin/statuses/01ab6c49f7ceb71da5fcde0bb65d284770321082","head":{"label":"andela:ft-signup-validation-errors-161340173","ref":"ft-signup-validation-errors-161340173","sha":"01ab6c49f7ceb71da5fcde0bb65d284770321082","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":153422674,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM0MjI2NzQ=","name":"ah-backend-odin","full_name":"andela/ah-backend-odin","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/ah-backend-odin","description":null,"fork":false,"url":"https://api.github.com/repos/andela/ah-backend-odin","forks_url":"https://api.github.com/repos/andela/ah-backend-odin/forks","keys_url":"https://api.github.com/repos/andela/ah-backend-odin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/ah-backend-odin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/ah-backend-odin/teams","hooks_url":"https://api.github.com/repos/andela/ah-backend-odin/hooks","issue_events_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/events{/number}","events_url":"https://api.github.com/repos/andela/ah-backend-odin/events","assignees_url":"https://api.github.com/repos/andela/ah-backend-odin/assignees{/user}","branches_url":"https://api.github.com/repos/andela/ah-backend-odin/branches{/branch}","tags_url":"https://api.github.com/repos/andela/ah-backend-odin/tags","blobs_url":"https://api.github.com/repos/andela/ah-backend-odin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/ah-backend-odin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/ah-backend-odin/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/ah-backend-odin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/ah-backend-odin/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/ah-backend-odin/languages","stargazers_url":"https://api.github.com/repos/andela/ah-backend-odin/stargazers","contributors_url":"https://api.github.com/repos/andela/ah-backend-odin/contributors","subscribers_url":"https://api.github.com/repos/andela/ah-backend-odin/subscribers","subscription_url":"https://api.github.com/repos/andela/ah-backend-odin/subscription","commits_url":"https://api.github.com/repos/andela/ah-backend-odin/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/ah-backend-odin/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/ah-backend-odin/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/ah-backend-odin/contents/{+path}","compare_url":"https://api.github.com/repos/andela/ah-backend-odin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/ah-backend-odin/merges","archive_url":"https://api.github.com/repos/andela/ah-backend-odin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/ah-backend-odin/downloads","issues_url":"https://api.github.com/repos/andela/ah-backend-odin/issues{/number}","pulls_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/ah-backend-odin/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/ah-backend-odin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/ah-backend-odin/labels{/name}","releases_url":"https://api.github.com/repos/andela/ah-backend-odin/releases{/id}","deployments_url":"https://api.github.com/repos/andela/ah-backend-odin/deployments","created_at":"2018-10-17T08:30:15Z","updated_at":"2018-11-01T10:46:17Z","pushed_at":"2018-11-01T11:30:48Z","git_url":"git://github.com/andela/ah-backend-odin.git","ssh_url":"git@github.com:andela/ah-backend-odin.git","clone_url":"https://github.com/andela/ah-backend-odin.git","svn_url":"https://github.com/andela/ah-backend-odin","homepage":null,"size":59,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"develop"}},"base":{"label":"andela:develop","ref":"develop","sha":"4370cf2c49c490ffb568fc8fb369eb7cb495b84b","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":153422674,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM0MjI2NzQ=","name":"ah-backend-odin","full_name":"andela/ah-backend-odin","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/ah-backend-odin","description":null,"fork":false,"url":"https://api.github.com/repos/andela/ah-backend-odin","forks_url":"https://api.github.com/repos/andela/ah-backend-odin/forks","keys_url":"https://api.github.com/repos/andela/ah-backend-odin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/ah-backend-odin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/ah-backend-odin/teams","hooks_url":"https://api.github.com/repos/andela/ah-backend-odin/hooks","issue_events_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/events{/number}","events_url":"https://api.github.com/repos/andela/ah-backend-odin/events","assignees_url":"https://api.github.com/repos/andela/ah-backend-odin/assignees{/user}","branches_url":"https://api.github.com/repos/andela/ah-backend-odin/branches{/branch}","tags_url":"https://api.github.com/repos/andela/ah-backend-odin/tags","blobs_url":"https://api.github.com/repos/andela/ah-backend-odin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/ah-backend-odin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/ah-backend-odin/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/ah-backend-odin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/ah-backend-odin/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/ah-backend-odin/languages","stargazers_url":"https://api.github.com/repos/andela/ah-backend-odin/stargazers","contributors_url":"https://api.github.com/repos/andela/ah-backend-odin/contributors","subscribers_url":"https://api.github.com/repos/andela/ah-backend-odin/subscribers","subscription_url":"https://api.github.com/repos/andela/ah-backend-odin/subscription","commits_url":"https://api.github.com/repos/andela/ah-backend-odin/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/ah-backend-odin/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/ah-backend-odin/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/ah-backend-odin/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/ah-backend-odin/contents/{+path}","compare_url":"https://api.github.com/repos/andela/ah-backend-odin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/ah-backend-odin/merges","archive_url":"https://api.github.com/repos/andela/ah-backend-odin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/ah-backend-odin/downloads","issues_url":"https://api.github.com/repos/andela/ah-backend-odin/issues{/number}","pulls_url":"https://api.github.com/repos/andela/ah-backend-odin/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/ah-backend-odin/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/ah-backend-odin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/ah-backend-odin/labels{/name}","releases_url":"https://api.github.com/repos/andela/ah-backend-odin/releases{/id}","deployments_url":"https://api.github.com/repos/andela/ah-backend-odin/deployments","created_at":"2018-10-17T08:30:15Z","updated_at":"2018-11-01T10:46:17Z","pushed_at":"2018-11-01T11:30:48Z","git_url":"git://github.com/andela/ah-backend-odin.git","ssh_url":"git@github.com:andela/ah-backend-odin.git","clone_url":"https://github.com/andela/ah-backend-odin.git","svn_url":"https://github.com/andela/ah-backend-odin","homepage":null,"size":59,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14"},"html":{"href":"https://github.com/andela/ah-backend-odin/pull/14"},"issue":{"href":"https://api.github.com/repos/andela/ah-backend-odin/issues/14"},"comments":{"href":"https://api.github.com/repos/andela/ah-backend-odin/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/ah-backend-odin/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/andela/ah-backend-odin/statuses/01ab6c49f7ceb71da5fcde0bb65d284770321082"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"krmroland"}}