{"action":"created","comment":{"url":"https://api.github.com/repos/8base/sdk/pulls/comments/197173083","pull_request_review_id":130865265,"id":197173083,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzE3MzA4Mw==","diff_hunk":"@@ -0,0 +1,166 @@\n+//@flow\n+\n+import R from 'ramda';\n+\n+import {\n+  FIELD_TYPE,\n+  ERROR,\n+  TEXT_FORMAT_PATTERN,\n+  DATE_FORMAT_PATTERN,\n+} from './validator.constants';\n+import {\n+  type Validator,\n+  type PreparedValidator,\n+  type ValidatorsGetter,\n+  type ValidatorsProcesser,\n+  type PropertyGetter,\n+  type Field,\n+  type ValidationError,\n+} from './validator.types';\n+\n+const getFieldTypeAttributes: PropertyGetter = R.prop('fieldTypeAttributes');\n+const getMaxPrecision: PropertyGetter = R.pipe(getFieldTypeAttributes, R.prop('precision'));\n+const getMinValue: PropertyGetter = R.pipe(getFieldTypeAttributes, R.prop('minValue'));\n+const getMaxValue: PropertyGetter = R.pipe(getFieldTypeAttributes, R.prop('maxValue'));\n+const getMaxFieldSize: PropertyGetter = R.pipe(getFieldTypeAttributes, R.prop('fieldSize'));\n+const getFormat: PropertyGetter = R.pipe(getFieldTypeAttributes, R.prop('format'));\n+\n+const checkRequired: PreparedValidator = R.ifElse(\n+  R.complement(R.either(R.isNil, R.isEmpty)),\n+  R.always(undefined),\n+  R.always(ERROR.IS_REQUIRED),\n+);\n+\n+const checkMaxPrecision: Validator = (maxPrecision) => R.ifElse(\n+  R.test(new RegExp(`^\\\\d+\\\\.?\\\\d{0,${maxPrecision}}$`)),\n+  R.always(undefined),\n+  R.always(ERROR.MAX_PRECISION),\n+);\n+\n+const checkMinValue: Validator = (minValue) => R.ifElse(\n+  R.lte(minValue),\n+  R.always(undefined),\n+  R.always(ERROR.MIN_VALUE),\n+);\n+\n+const checkMaxValue: Validator = (maxValue) => R.ifElse(\n+  R.gte(maxValue),\n+  R.always(undefined),\n+  R.always(ERROR.MAX_VALUE),\n+);\n+\n+const checkMaxFieldSize: Validator = (maxFieldSize) => R.ifElse(\n+  R.pipe(\n+    R.length,\n+    R.gte(maxFieldSize),\n+  ),\n+  R.always(undefined),\n+  R.always(ERROR.FIELD_SIZE),\n+);\n+\n+const checkTextFormat: Validator = (textFormat) => R.ifElse(\n+  R.both(\n+    R.complement(R.isNil),\n+    R.test(TEXT_FORMAT_PATTERN[textFormat]),\n+  ),\n+  R.always(undefined),\n+  R.always(ERROR[textFormat]),\n+);\n+\n+const checkDateFormat: Validator = (dateFormat) => R.ifElse(\n+  R.both(\n+    R.complement(R.isNil),\n+    R.test(DATE_FORMAT_PATTERN[dateFormat]),\n+  ),\n+  R.always(undefined),\n+  R.always(ERROR[dateFormat]),\n+);\n+\n+const getCommonValidators: ValidatorsGetter = (field) => {\n+  const validators = [];\n+\n+  if (field.isRequired) {\n+    validators.push(checkRequired);\n+  }\n+\n+  return validators;\n+};\n+\n+const getNumberFieldValidators: ValidatorsGetter = (field) => {\n+  const validators = [\n+    ...getCommonValidators(field),","path":"packages/validator/src/validator.js","position":91,"original_position":91,"commit_id":"55d750ca65a795c29cd9ac63dfd9abffedada770","original_commit_id":"55d750ca65a795c29cd9ac63dfd9abffedada770","user":{"login":"vorobeez","id":4214306,"node_id":"MDQ6VXNlcjQyMTQzMDY=","avatar_url":"https://avatars0.githubusercontent.com/u/4214306?v=4","gravatar_id":"","url":"https://api.github.com/users/vorobeez","html_url":"https://github.com/vorobeez","followers_url":"https://api.github.com/users/vorobeez/followers","following_url":"https://api.github.com/users/vorobeez/following{/other_user}","gists_url":"https://api.github.com/users/vorobeez/gists{/gist_id}","starred_url":"https://api.github.com/users/vorobeez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vorobeez/subscriptions","organizations_url":"https://api.github.com/users/vorobeez/orgs","repos_url":"https://api.github.com/users/vorobeez/repos","events_url":"https://api.github.com/users/vorobeez/events{/privacy}","received_events_url":"https://api.github.com/users/vorobeez/received_events","type":"User","site_admin":false},"body":"Will be implemented.","created_at":"2018-06-21T15:16:26Z","updated_at":"2018-06-21T15:16:26Z","html_url":"https://github.com/8base/sdk/pull/2#discussion_r197173083","pull_request_url":"https://api.github.com/repos/8base/sdk/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/8base/sdk/pulls/comments/197173083"},"html":{"href":"https://github.com/8base/sdk/pull/2#discussion_r197173083"},"pull_request":{"href":"https://api.github.com/repos/8base/sdk/pulls/2"}},"in_reply_to_id":197117300},"pull_request":{"url":"https://api.github.com/repos/8base/sdk/pulls/2","id":196421797,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NDIxNzk3","html_url":"https://github.com/8base/sdk/pull/2","diff_url":"https://github.com/8base/sdk/pull/2.diff","patch_url":"https://github.com/8base/sdk/pull/2.patch","issue_url":"https://api.github.com/repos/8base/sdk/issues/2","number":2,"state":"open","locked":false,"title":"feat(validator): add validator package. Closes CW-1338.","user":{"login":"vorobeez","id":4214306,"node_id":"MDQ6VXNlcjQyMTQzMDY=","avatar_url":"https://avatars0.githubusercontent.com/u/4214306?v=4","gravatar_id":"","url":"https://api.github.com/users/vorobeez","html_url":"https://github.com/vorobeez","followers_url":"https://api.github.com/users/vorobeez/followers","following_url":"https://api.github.com/users/vorobeez/following{/other_user}","gists_url":"https://api.github.com/users/vorobeez/gists{/gist_id}","starred_url":"https://api.github.com/users/vorobeez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vorobeez/subscriptions","organizations_url":"https://api.github.com/users/vorobeez/orgs","repos_url":"https://api.github.com/users/vorobeez/repos","events_url":"https://api.github.com/users/vorobeez/events{/privacy}","received_events_url":"https://api.github.com/users/vorobeez/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-21T11:32:47Z","updated_at":"2018-06-21T15:16:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4720e78209195d12979ad13368d472144a3b58b8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ej9x","id":15693319,"node_id":"MDQ6VXNlcjE1NjkzMzE5","avatar_url":"https://avatars3.githubusercontent.com/u/15693319?v=4","gravatar_id":"","url":"https://api.github.com/users/ej9x","html_url":"https://github.com/ej9x","followers_url":"https://api.github.com/users/ej9x/followers","following_url":"https://api.github.com/users/ej9x/following{/other_user}","gists_url":"https://api.github.com/users/ej9x/gists{/gist_id}","starred_url":"https://api.github.com/users/ej9x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ej9x/subscriptions","organizations_url":"https://api.github.com/users/ej9x/orgs","repos_url":"https://api.github.com/users/ej9x/repos","events_url":"https://api.github.com/users/ej9x/events{/privacy}","received_events_url":"https://api.github.com/users/ej9x/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/8base/sdk/pulls/2/commits","review_comments_url":"https://api.github.com/repos/8base/sdk/pulls/2/comments","review_comment_url":"https://api.github.com/repos/8base/sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/8base/sdk/issues/2/comments","statuses_url":"https://api.github.com/repos/8base/sdk/statuses/55d750ca65a795c29cd9ac63dfd9abffedada770","head":{"label":"8base:validator","ref":"validator","sha":"55d750ca65a795c29cd9ac63dfd9abffedada770","user":{"login":"8base","id":28789399,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzg5Mzk5","avatar_url":"https://avatars0.githubusercontent.com/u/28789399?v=4","gravatar_id":"","url":"https://api.github.com/users/8base","html_url":"https://github.com/8base","followers_url":"https://api.github.com/users/8base/followers","following_url":"https://api.github.com/users/8base/following{/other_user}","gists_url":"https://api.github.com/users/8base/gists{/gist_id}","starred_url":"https://api.github.com/users/8base/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8base/subscriptions","organizations_url":"https://api.github.com/users/8base/orgs","repos_url":"https://api.github.com/users/8base/repos","events_url":"https://api.github.com/users/8base/events{/privacy}","received_events_url":"https://api.github.com/users/8base/received_events","type":"Organization","site_admin":false},"repo":{"id":137734055,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc3MzQwNTU=","name":"sdk","full_name":"8base/sdk","owner":{"login":"8base","id":28789399,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzg5Mzk5","avatar_url":"https://avatars0.githubusercontent.com/u/28789399?v=4","gravatar_id":"","url":"https://api.github.com/users/8base","html_url":"https://github.com/8base","followers_url":"https://api.github.com/users/8base/followers","following_url":"https://api.github.com/users/8base/following{/other_user}","gists_url":"https://api.github.com/users/8base/gists{/gist_id}","starred_url":"https://api.github.com/users/8base/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8base/subscriptions","organizations_url":"https://api.github.com/users/8base/orgs","repos_url":"https://api.github.com/users/8base/repos","events_url":"https://api.github.com/users/8base/events{/privacy}","received_events_url":"https://api.github.com/users/8base/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/8base/sdk","description":"Easy-to-use JavaScript SDK for working with 8base","fork":false,"url":"https://api.github.com/repos/8base/sdk","forks_url":"https://api.github.com/repos/8base/sdk/forks","keys_url":"https://api.github.com/repos/8base/sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/8base/sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/8base/sdk/teams","hooks_url":"https://api.github.com/repos/8base/sdk/hooks","issue_events_url":"https://api.github.com/repos/8base/sdk/issues/events{/number}","events_url":"https://api.github.com/repos/8base/sdk/events","assignees_url":"https://api.github.com/repos/8base/sdk/assignees{/user}","branches_url":"https://api.github.com/repos/8base/sdk/branches{/branch}","tags_url":"https://api.github.com/repos/8base/sdk/tags","blobs_url":"https://api.github.com/repos/8base/sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/8base/sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/8base/sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/8base/sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/8base/sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/8base/sdk/languages","stargazers_url":"https://api.github.com/repos/8base/sdk/stargazers","contributors_url":"https://api.github.com/repos/8base/sdk/contributors","subscribers_url":"https://api.github.com/repos/8base/sdk/subscribers","subscription_url":"https://api.github.com/repos/8base/sdk/subscription","commits_url":"https://api.github.com/repos/8base/sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/8base/sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/8base/sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/8base/sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/8base/sdk/contents/{+path}","compare_url":"https://api.github.com/repos/8base/sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/8base/sdk/merges","archive_url":"https://api.github.com/repos/8base/sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/8base/sdk/downloads","issues_url":"https://api.github.com/repos/8base/sdk/issues{/number}","pulls_url":"https://api.github.com/repos/8base/sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/8base/sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/8base/sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/8base/sdk/labels{/name}","releases_url":"https://api.github.com/repos/8base/sdk/releases{/id}","deployments_url":"https://api.github.com/repos/8base/sdk/deployments","created_at":"2018-06-18T09:38:53Z","updated_at":"2018-06-19T08:29:16Z","pushed_at":"2018-06-21T11:32:47Z","git_url":"git://github.com/8base/sdk.git","ssh_url":"git@github.com:8base/sdk.git","clone_url":"https://github.com/8base/sdk.git","svn_url":"https://github.com/8base/sdk","homepage":null,"size":203,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"8base:master","ref":"master","sha":"2b6a49f29931a8bc88d7a40600a0c3cf32425666","user":{"login":"8base","id":28789399,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzg5Mzk5","avatar_url":"https://avatars0.githubusercontent.com/u/28789399?v=4","gravatar_id":"","url":"https://api.github.com/users/8base","html_url":"https://github.com/8base","followers_url":"https://api.github.com/users/8base/followers","following_url":"https://api.github.com/users/8base/following{/other_user}","gists_url":"https://api.github.com/users/8base/gists{/gist_id}","starred_url":"https://api.github.com/users/8base/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8base/subscriptions","organizations_url":"https://api.github.com/users/8base/orgs","repos_url":"https://api.github.com/users/8base/repos","events_url":"https://api.github.com/users/8base/events{/privacy}","received_events_url":"https://api.github.com/users/8base/received_events","type":"Organization","site_admin":false},"repo":{"id":137734055,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc3MzQwNTU=","name":"sdk","full_name":"8base/sdk","owner":{"login":"8base","id":28789399,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzg5Mzk5","avatar_url":"https://avatars0.githubusercontent.com/u/28789399?v=4","gravatar_id":"","url":"https://api.github.com/users/8base","html_url":"https://github.com/8base","followers_url":"https://api.github.com/users/8base/followers","following_url":"https://api.github.com/users/8base/following{/other_user}","gists_url":"https://api.github.com/users/8base/gists{/gist_id}","starred_url":"https://api.github.com/users/8base/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8base/subscriptions","organizations_url":"https://api.github.com/users/8base/orgs","repos_url":"https://api.github.com/users/8base/repos","events_url":"https://api.github.com/users/8base/events{/privacy}","received_events_url":"https://api.github.com/users/8base/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/8base/sdk","description":"Easy-to-use JavaScript SDK for working with 8base","fork":false,"url":"https://api.github.com/repos/8base/sdk","forks_url":"https://api.github.com/repos/8base/sdk/forks","keys_url":"https://api.github.com/repos/8base/sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/8base/sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/8base/sdk/teams","hooks_url":"https://api.github.com/repos/8base/sdk/hooks","issue_events_url":"https://api.github.com/repos/8base/sdk/issues/events{/number}","events_url":"https://api.github.com/repos/8base/sdk/events","assignees_url":"https://api.github.com/repos/8base/sdk/assignees{/user}","branches_url":"https://api.github.com/repos/8base/sdk/branches{/branch}","tags_url":"https://api.github.com/repos/8base/sdk/tags","blobs_url":"https://api.github.com/repos/8base/sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/8base/sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/8base/sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/8base/sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/8base/sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/8base/sdk/languages","stargazers_url":"https://api.github.com/repos/8base/sdk/stargazers","contributors_url":"https://api.github.com/repos/8base/sdk/contributors","subscribers_url":"https://api.github.com/repos/8base/sdk/subscribers","subscription_url":"https://api.github.com/repos/8base/sdk/subscription","commits_url":"https://api.github.com/repos/8base/sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/8base/sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/8base/sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/8base/sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/8base/sdk/contents/{+path}","compare_url":"https://api.github.com/repos/8base/sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/8base/sdk/merges","archive_url":"https://api.github.com/repos/8base/sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/8base/sdk/downloads","issues_url":"https://api.github.com/repos/8base/sdk/issues{/number}","pulls_url":"https://api.github.com/repos/8base/sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/8base/sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/8base/sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/8base/sdk/labels{/name}","releases_url":"https://api.github.com/repos/8base/sdk/releases{/id}","deployments_url":"https://api.github.com/repos/8base/sdk/deployments","created_at":"2018-06-18T09:38:53Z","updated_at":"2018-06-19T08:29:16Z","pushed_at":"2018-06-21T11:32:47Z","git_url":"git://github.com/8base/sdk.git","ssh_url":"git@github.com:8base/sdk.git","clone_url":"https://github.com/8base/sdk.git","svn_url":"https://github.com/8base/sdk","homepage":null,"size":203,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/8base/sdk/pulls/2"},"html":{"href":"https://github.com/8base/sdk/pull/2"},"issue":{"href":"https://api.github.com/repos/8base/sdk/issues/2"},"comments":{"href":"https://api.github.com/repos/8base/sdk/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/8base/sdk/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/8base/sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/8base/sdk/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/8base/sdk/statuses/55d750ca65a795c29cd9ac63dfd9abffedada770"}},"author_association":"NONE"}}
{"actor":{"display_login":"vorobeez"}}