{"action":"created","comment":{"url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/comments/318049087","pull_request_review_id":280154096,"id":318049087,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxODA0OTA4Nw==","diff_hunk":"@@ -0,0 +1,238 @@\n+import {\n+  ValidationResult,\n+  FormValidationResult,\n+  FieldsValidationSchema,\n+  RecordValidationFunction,\n+  createDefaultValidationResult,\n+  RecordValidationFunctionSyncAsync,\n+  isSyncValidationResult,\n+  FieldValidationFunctionSyncAsync,\n+  FieldValidationFunction,\n+  FieldValidation,\n+} from './model';\n+\n+import { isUndefinedOrNull } from './helper';\n+\n+import {\n+  fireAllFieldsValidations,\n+  fireSingleFieldValidations,\n+  fireRecordValidations,\n+} from './validation-dispatcher';\n+import { buildFormValidationResult } from './form-validation-summary-builder';\n+\n+export class ValidationEngine {\n+  private validationsPerField: FieldsValidationSchema = {};\n+  private validationsGlobalForm: RecordValidationFunction[] = [];\n+  private asyncValidationInProgressCount = 0;\n+\n+  // TODO, in new api we are adding an optional parameter\n+  // to customize the error message (string array)\n+  //\n+  // TODO: Chain pattern applied here, check why it is useful\n+  addFieldValidation(\n+    key: string,\n+    validation: FieldValidationFunctionSyncAsync,\n+    customParams: any = {},\n+    errorMessage?: string\n+  ): ValidationEngine {\n+    const asyncValidationFn = this.convertFieldValidationToAsyncIfNeeded(\n+      validation\n+    );\n+\n+    if (!this.isFieldKeyMappingDefined(key)) {\n+      this.validationsPerField[key] = [];\n+    }\n+\n+    const fieldValidation: FieldValidation = {\n+      validator: asyncValidationFn,\n+      customArgs: customParams,\n+    };\n+\n+    if (errorMessage) {\n+      fieldValidation.errorMessage = errorMessage;\n+    }\n+\n+    this.validationsPerField[key].push({\n+      validator: asyncValidationFn,\n+      customArgs: customParams,\n+      errorMessage: errorMessage,\n+    });\n+    return this;\n+  }\n+\n+  // TODO: Should it be moved to model?","path":"src/validation-engine.ts","position":63,"original_position":63,"commit_id":"3d6f112de657aede8607fa19113e677b80f45d17","original_commit_id":"3d6f112de657aede8607fa19113e677b80f45d17","user":{"login":"Nasdan","id":4374977,"node_id":"MDQ6VXNlcjQzNzQ5Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/4374977?v=4","gravatar_id":"","url":"https://api.github.com/users/Nasdan","html_url":"https://github.com/Nasdan","followers_url":"https://api.github.com/users/Nasdan/followers","following_url":"https://api.github.com/users/Nasdan/following{/other_user}","gists_url":"https://api.github.com/users/Nasdan/gists{/gist_id}","starred_url":"https://api.github.com/users/Nasdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nasdan/subscriptions","organizations_url":"https://api.github.com/users/Nasdan/orgs","repos_url":"https://api.github.com/users/Nasdan/repos","events_url":"https://api.github.com/users/Nasdan/events{/privacy}","received_events_url":"https://api.github.com/users/Nasdan/received_events","type":"User","site_admin":false},"body":"I think, it's like a \"helper\" or \"mapper\" function, not model, isn't it?\r\n\r\nIt's like \"convert to async result\" or \"map to async result\"","created_at":"2019-08-27T12:23:40Z","updated_at":"2019-08-27T12:23:40Z","html_url":"https://github.com/Lemoncode/form-validation/pull/8#discussion_r318049087","pull_request_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/comments/318049087"},"html":{"href":"https://github.com/Lemoncode/form-validation/pull/8#discussion_r318049087"},"pull_request":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8","id":311308485,"node_id":"MDExOlB1bGxSZXF1ZXN0MzExMzA4NDg1","html_url":"https://github.com/Lemoncode/form-validation/pull/8","diff_url":"https://github.com/Lemoncode/form-validation/pull/8.diff","patch_url":"https://github.com/Lemoncode/form-validation/pull/8.patch","issue_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/8","number":8,"state":"open","locked":false,"title":"Validation engine","user":{"login":"brauliodiez","id":1457912,"node_id":"MDQ6VXNlcjE0NTc5MTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1457912?v=4","gravatar_id":"","url":"https://api.github.com/users/brauliodiez","html_url":"https://github.com/brauliodiez","followers_url":"https://api.github.com/users/brauliodiez/followers","following_url":"https://api.github.com/users/brauliodiez/following{/other_user}","gists_url":"https://api.github.com/users/brauliodiez/gists{/gist_id}","starred_url":"https://api.github.com/users/brauliodiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brauliodiez/subscriptions","organizations_url":"https://api.github.com/users/brauliodiez/orgs","repos_url":"https://api.github.com/users/brauliodiez/repos","events_url":"https://api.github.com/users/brauliodiez/events{/privacy}","received_events_url":"https://api.github.com/users/brauliodiez/received_events","type":"User","site_admin":false},"body":"","created_at":"2019-08-27T10:13:57Z","updated_at":"2019-08-27T12:23:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c3fa0759bbde7587ee3809911bc2f82367862bf","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8/commits","review_comments_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8/comments","review_comment_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/8/comments","statuses_url":"https://api.github.com/repos/Lemoncode/form-validation/statuses/3d6f112de657aede8607fa19113e677b80f45d17","head":{"label":"Lemoncode:validation-engine","ref":"validation-engine","sha":"3d6f112de657aede8607fa19113e677b80f45d17","user":{"login":"Lemoncode","id":7702396,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc3MDIzOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/7702396?v=4","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"repo":{"id":202330880,"node_id":"MDEwOlJlcG9zaXRvcnkyMDIzMzA4ODA=","name":"form-validation","full_name":"Lemoncode/form-validation","private":false,"owner":{"login":"Lemoncode","id":7702396,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc3MDIzOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/7702396?v=4","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Lemoncode/form-validation","description":"[Work in progress] form schema validator library","fork":false,"url":"https://api.github.com/repos/Lemoncode/form-validation","forks_url":"https://api.github.com/repos/Lemoncode/form-validation/forks","keys_url":"https://api.github.com/repos/Lemoncode/form-validation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lemoncode/form-validation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lemoncode/form-validation/teams","hooks_url":"https://api.github.com/repos/Lemoncode/form-validation/hooks","issue_events_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/events{/number}","events_url":"https://api.github.com/repos/Lemoncode/form-validation/events","assignees_url":"https://api.github.com/repos/Lemoncode/form-validation/assignees{/user}","branches_url":"https://api.github.com/repos/Lemoncode/form-validation/branches{/branch}","tags_url":"https://api.github.com/repos/Lemoncode/form-validation/tags","blobs_url":"https://api.github.com/repos/Lemoncode/form-validation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lemoncode/form-validation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lemoncode/form-validation/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lemoncode/form-validation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lemoncode/form-validation/statuses/{sha}","languages_url":"https://api.github.com/repos/Lemoncode/form-validation/languages","stargazers_url":"https://api.github.com/repos/Lemoncode/form-validation/stargazers","contributors_url":"https://api.github.com/repos/Lemoncode/form-validation/contributors","subscribers_url":"https://api.github.com/repos/Lemoncode/form-validation/subscribers","subscription_url":"https://api.github.com/repos/Lemoncode/form-validation/subscription","commits_url":"https://api.github.com/repos/Lemoncode/form-validation/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lemoncode/form-validation/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lemoncode/form-validation/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lemoncode/form-validation/contents/{+path}","compare_url":"https://api.github.com/repos/Lemoncode/form-validation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lemoncode/form-validation/merges","archive_url":"https://api.github.com/repos/Lemoncode/form-validation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lemoncode/form-validation/downloads","issues_url":"https://api.github.com/repos/Lemoncode/form-validation/issues{/number}","pulls_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls{/number}","milestones_url":"https://api.github.com/repos/Lemoncode/form-validation/milestones{/number}","notifications_url":"https://api.github.com/repos/Lemoncode/form-validation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lemoncode/form-validation/labels{/name}","releases_url":"https://api.github.com/repos/Lemoncode/form-validation/releases{/id}","deployments_url":"https://api.github.com/repos/Lemoncode/form-validation/deployments","created_at":"2019-08-14T10:45:38Z","updated_at":"2019-08-26T08:41:14Z","pushed_at":"2019-08-27T12:10:54Z","git_url":"git://github.com/Lemoncode/form-validation.git","ssh_url":"git@github.com:Lemoncode/form-validation.git","clone_url":"https://github.com/Lemoncode/form-validation.git","svn_url":"https://github.com/Lemoncode/form-validation","homepage":null,"size":71,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Lemoncode:master","ref":"master","sha":"a247d8db44724a55f416884533a5661baa966f4f","user":{"login":"Lemoncode","id":7702396,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc3MDIzOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/7702396?v=4","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"repo":{"id":202330880,"node_id":"MDEwOlJlcG9zaXRvcnkyMDIzMzA4ODA=","name":"form-validation","full_name":"Lemoncode/form-validation","private":false,"owner":{"login":"Lemoncode","id":7702396,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc3MDIzOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/7702396?v=4","gravatar_id":"","url":"https://api.github.com/users/Lemoncode","html_url":"https://github.com/Lemoncode","followers_url":"https://api.github.com/users/Lemoncode/followers","following_url":"https://api.github.com/users/Lemoncode/following{/other_user}","gists_url":"https://api.github.com/users/Lemoncode/gists{/gist_id}","starred_url":"https://api.github.com/users/Lemoncode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lemoncode/subscriptions","organizations_url":"https://api.github.com/users/Lemoncode/orgs","repos_url":"https://api.github.com/users/Lemoncode/repos","events_url":"https://api.github.com/users/Lemoncode/events{/privacy}","received_events_url":"https://api.github.com/users/Lemoncode/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Lemoncode/form-validation","description":"[Work in progress] form schema validator library","fork":false,"url":"https://api.github.com/repos/Lemoncode/form-validation","forks_url":"https://api.github.com/repos/Lemoncode/form-validation/forks","keys_url":"https://api.github.com/repos/Lemoncode/form-validation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lemoncode/form-validation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lemoncode/form-validation/teams","hooks_url":"https://api.github.com/repos/Lemoncode/form-validation/hooks","issue_events_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/events{/number}","events_url":"https://api.github.com/repos/Lemoncode/form-validation/events","assignees_url":"https://api.github.com/repos/Lemoncode/form-validation/assignees{/user}","branches_url":"https://api.github.com/repos/Lemoncode/form-validation/branches{/branch}","tags_url":"https://api.github.com/repos/Lemoncode/form-validation/tags","blobs_url":"https://api.github.com/repos/Lemoncode/form-validation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lemoncode/form-validation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lemoncode/form-validation/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lemoncode/form-validation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lemoncode/form-validation/statuses/{sha}","languages_url":"https://api.github.com/repos/Lemoncode/form-validation/languages","stargazers_url":"https://api.github.com/repos/Lemoncode/form-validation/stargazers","contributors_url":"https://api.github.com/repos/Lemoncode/form-validation/contributors","subscribers_url":"https://api.github.com/repos/Lemoncode/form-validation/subscribers","subscription_url":"https://api.github.com/repos/Lemoncode/form-validation/subscription","commits_url":"https://api.github.com/repos/Lemoncode/form-validation/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lemoncode/form-validation/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lemoncode/form-validation/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lemoncode/form-validation/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lemoncode/form-validation/contents/{+path}","compare_url":"https://api.github.com/repos/Lemoncode/form-validation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lemoncode/form-validation/merges","archive_url":"https://api.github.com/repos/Lemoncode/form-validation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lemoncode/form-validation/downloads","issues_url":"https://api.github.com/repos/Lemoncode/form-validation/issues{/number}","pulls_url":"https://api.github.com/repos/Lemoncode/form-validation/pulls{/number}","milestones_url":"https://api.github.com/repos/Lemoncode/form-validation/milestones{/number}","notifications_url":"https://api.github.com/repos/Lemoncode/form-validation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lemoncode/form-validation/labels{/name}","releases_url":"https://api.github.com/repos/Lemoncode/form-validation/releases{/id}","deployments_url":"https://api.github.com/repos/Lemoncode/form-validation/deployments","created_at":"2019-08-14T10:45:38Z","updated_at":"2019-08-26T08:41:14Z","pushed_at":"2019-08-27T12:10:54Z","git_url":"git://github.com/Lemoncode/form-validation.git","ssh_url":"git@github.com:Lemoncode/form-validation.git","clone_url":"https://github.com/Lemoncode/form-validation.git","svn_url":"https://github.com/Lemoncode/form-validation","homepage":null,"size":71,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8"},"html":{"href":"https://github.com/Lemoncode/form-validation/pull/8"},"issue":{"href":"https://api.github.com/repos/Lemoncode/form-validation/issues/8"},"comments":{"href":"https://api.github.com/repos/Lemoncode/form-validation/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Lemoncode/form-validation/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/Lemoncode/form-validation/statuses/3d6f112de657aede8607fa19113e677b80f45d17"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Nasdan"}}