{"action":"created","comment":{"url":"https://api.github.com/repos/ifwe/monocle-api/pulls/comments/57034299","id":57034299,"diff_hunk":"@@ -124,101 +133,124 @@ Request.prototype.setQuery = function(query, value) {\n     return this;\n };\n \n+\n+Request.prototype.deleteQuery = function(query) {\n+    delete this._url.query[query];\n+    return this;\n+};\n+\n Request.prototype.getQuery = function(query) {\n     return this._url.query.hasOwnProperty(query) ? this._url.query[query] : undefined;\n };\n \n+Request.prototype.validateAndCastParams = function(object) {\n+    return this.validateAndCast(this.getParams());\n+}\n+\n+Request.prototype.validateAndCastQueries = function(object) {\n+    return this.validateAndCast(this.getQueries());\n+\n+}\n+\n /**\n- * Validates the query with the provided schema.\n+ * Validates the query  or passed in params with the provided schema.\n  * Query parameters that are not included in the schema are ignored.\n- * Query parameters that are defined as type \"integer\" or \"number\" are converted accordingly.\n- * Returns a validation object with two properties:\n- *   - boolean valid -- true if the query parameters are valid\n- *   - array errors -- array of properties that are in error, if any\n+ * Query parameters that are defined as type \"integer\", \"number\", \"boolean\" or \"string\" are converted accordingly.\n+ * Pushes errors to validationErrors array if errors are gound\n  *\n- * @param object schema - a schema in json-schema format.\n- * @return object - validation result\n+ * @param object - object to validate\n  */\n-Request.prototype.validateQuery = function(schema, defaults) {\n-    // Nothing to validate if the schema is not an object (rare)\n-    if (!schema.properties) {\n-        // Clear out existing query params -- they must be in the schema to access them.\n-        this.setQueries({});\n-        return {\n-            valid: true,\n-            errors: []\n-        };\n+Request.prototype.validateAndCast = function(object) {\n+    if (!Object.keys(object).length) {\n+        return;\n     }\n \n-    // Build new query object based on defaults\n-    var query = _.assign({}, defaults);\n-\n-    // Validate query with schema\n-    var validate = jsen(schema);\n+    for (var key in object) {\n+        var value = object[key];","path":"lib/Request.js","position":95,"original_position":95,"commit_id":"461eb511b164e4260acb0700b7d4c867a226e8c3","original_commit_id":"461eb511b164e4260acb0700b7d4c867a226e8c3","user":{"login":"djvirgen","id":308786,"avatar_url":"https://avatars.githubusercontent.com/u/308786?v=3","gravatar_id":"","url":"https://api.github.com/users/djvirgen","html_url":"https://github.com/djvirgen","followers_url":"https://api.github.com/users/djvirgen/followers","following_url":"https://api.github.com/users/djvirgen/following{/other_user}","gists_url":"https://api.github.com/users/djvirgen/gists{/gist_id}","starred_url":"https://api.github.com/users/djvirgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djvirgen/subscriptions","organizations_url":"https://api.github.com/users/djvirgen/orgs","repos_url":"https://api.github.com/users/djvirgen/repos","events_url":"https://api.github.com/users/djvirgen/events{/privacy}","received_events_url":"https://api.github.com/users/djvirgen/received_events","type":"User","site_admin":false},"body":"Be sure to do a `hasOwnProperty` check.","created_at":"2016-03-22T17:46:07Z","updated_at":"2016-03-22T17:46:07Z","html_url":"https://github.com/ifwe/monocle-api/pull/47#discussion_r57034299","pull_request_url":"https://api.github.com/repos/ifwe/monocle-api/pulls/47","_links":{"self":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/comments/57034299"},"html":{"href":"https://github.com/ifwe/monocle-api/pull/47#discussion_r57034299"},"pull_request":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/ifwe/monocle-api/pulls/47","id":63654670,"html_url":"https://github.com/ifwe/monocle-api/pull/47","diff_url":"https://github.com/ifwe/monocle-api/pull/47.diff","patch_url":"https://github.com/ifwe/monocle-api/pull/47.patch","issue_url":"https://api.github.com/repos/ifwe/monocle-api/issues/47","number":47,"state":"open","locked":false,"title":"WTF-16599 Refactored code responsible of query checking","user":{"login":"marianeaj","id":1957504,"avatar_url":"https://avatars.githubusercontent.com/u/1957504?v=3","gravatar_id":"","url":"https://api.github.com/users/marianeaj","html_url":"https://github.com/marianeaj","followers_url":"https://api.github.com/users/marianeaj/followers","following_url":"https://api.github.com/users/marianeaj/following{/other_user}","gists_url":"https://api.github.com/users/marianeaj/gists{/gist_id}","starred_url":"https://api.github.com/users/marianeaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianeaj/subscriptions","organizations_url":"https://api.github.com/users/marianeaj/orgs","repos_url":"https://api.github.com/users/marianeaj/repos","events_url":"https://api.github.com/users/marianeaj/events{/privacy}","received_events_url":"https://api.github.com/users/marianeaj/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-22T00:36:42Z","updated_at":"2016-03-22T17:46:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3d72175e778d9f68d29832765434ff17fb20139","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ifwe/monocle-api/pulls/47/commits","review_comments_url":"https://api.github.com/repos/ifwe/monocle-api/pulls/47/comments","review_comment_url":"https://api.github.com/repos/ifwe/monocle-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ifwe/monocle-api/issues/47/comments","statuses_url":"https://api.github.com/repos/ifwe/monocle-api/statuses/461eb511b164e4260acb0700b7d4c867a226e8c3","head":{"label":"ifwe:update_param_checks","ref":"update_param_checks","sha":"461eb511b164e4260acb0700b7d4c867a226e8c3","user":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"repo":{"id":41873773,"name":"monocle-api","full_name":"ifwe/monocle-api","owner":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ifwe/monocle-api","description":"API router focused on consistency, flexibility, and performance.","fork":false,"url":"https://api.github.com/repos/ifwe/monocle-api","forks_url":"https://api.github.com/repos/ifwe/monocle-api/forks","keys_url":"https://api.github.com/repos/ifwe/monocle-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifwe/monocle-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifwe/monocle-api/teams","hooks_url":"https://api.github.com/repos/ifwe/monocle-api/hooks","issue_events_url":"https://api.github.com/repos/ifwe/monocle-api/issues/events{/number}","events_url":"https://api.github.com/repos/ifwe/monocle-api/events","assignees_url":"https://api.github.com/repos/ifwe/monocle-api/assignees{/user}","branches_url":"https://api.github.com/repos/ifwe/monocle-api/branches{/branch}","tags_url":"https://api.github.com/repos/ifwe/monocle-api/tags","blobs_url":"https://api.github.com/repos/ifwe/monocle-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifwe/monocle-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifwe/monocle-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifwe/monocle-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifwe/monocle-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ifwe/monocle-api/languages","stargazers_url":"https://api.github.com/repos/ifwe/monocle-api/stargazers","contributors_url":"https://api.github.com/repos/ifwe/monocle-api/contributors","subscribers_url":"https://api.github.com/repos/ifwe/monocle-api/subscribers","subscription_url":"https://api.github.com/repos/ifwe/monocle-api/subscription","commits_url":"https://api.github.com/repos/ifwe/monocle-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifwe/monocle-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifwe/monocle-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifwe/monocle-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifwe/monocle-api/contents/{+path}","compare_url":"https://api.github.com/repos/ifwe/monocle-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifwe/monocle-api/merges","archive_url":"https://api.github.com/repos/ifwe/monocle-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifwe/monocle-api/downloads","issues_url":"https://api.github.com/repos/ifwe/monocle-api/issues{/number}","pulls_url":"https://api.github.com/repos/ifwe/monocle-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ifwe/monocle-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ifwe/monocle-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifwe/monocle-api/labels{/name}","releases_url":"https://api.github.com/repos/ifwe/monocle-api/releases{/id}","deployments_url":"https://api.github.com/repos/ifwe/monocle-api/deployments","created_at":"2015-09-03T17:29:27Z","updated_at":"2016-01-12T19:03:22Z","pushed_at":"2016-03-22T00:36:43Z","git_url":"git://github.com/ifwe/monocle-api.git","ssh_url":"git@github.com:ifwe/monocle-api.git","clone_url":"https://github.com/ifwe/monocle-api.git","svn_url":"https://github.com/ifwe/monocle-api","homepage":null,"size":196,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"ifwe:master","ref":"master","sha":"f7bff6f97c47e5156c12dae14a0cdcdbb09c5688","user":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"repo":{"id":41873773,"name":"monocle-api","full_name":"ifwe/monocle-api","owner":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ifwe/monocle-api","description":"API router focused on consistency, flexibility, and performance.","fork":false,"url":"https://api.github.com/repos/ifwe/monocle-api","forks_url":"https://api.github.com/repos/ifwe/monocle-api/forks","keys_url":"https://api.github.com/repos/ifwe/monocle-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifwe/monocle-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifwe/monocle-api/teams","hooks_url":"https://api.github.com/repos/ifwe/monocle-api/hooks","issue_events_url":"https://api.github.com/repos/ifwe/monocle-api/issues/events{/number}","events_url":"https://api.github.com/repos/ifwe/monocle-api/events","assignees_url":"https://api.github.com/repos/ifwe/monocle-api/assignees{/user}","branches_url":"https://api.github.com/repos/ifwe/monocle-api/branches{/branch}","tags_url":"https://api.github.com/repos/ifwe/monocle-api/tags","blobs_url":"https://api.github.com/repos/ifwe/monocle-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifwe/monocle-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifwe/monocle-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifwe/monocle-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifwe/monocle-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ifwe/monocle-api/languages","stargazers_url":"https://api.github.com/repos/ifwe/monocle-api/stargazers","contributors_url":"https://api.github.com/repos/ifwe/monocle-api/contributors","subscribers_url":"https://api.github.com/repos/ifwe/monocle-api/subscribers","subscription_url":"https://api.github.com/repos/ifwe/monocle-api/subscription","commits_url":"https://api.github.com/repos/ifwe/monocle-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifwe/monocle-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifwe/monocle-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifwe/monocle-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifwe/monocle-api/contents/{+path}","compare_url":"https://api.github.com/repos/ifwe/monocle-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifwe/monocle-api/merges","archive_url":"https://api.github.com/repos/ifwe/monocle-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifwe/monocle-api/downloads","issues_url":"https://api.github.com/repos/ifwe/monocle-api/issues{/number}","pulls_url":"https://api.github.com/repos/ifwe/monocle-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ifwe/monocle-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ifwe/monocle-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifwe/monocle-api/labels{/name}","releases_url":"https://api.github.com/repos/ifwe/monocle-api/releases{/id}","deployments_url":"https://api.github.com/repos/ifwe/monocle-api/deployments","created_at":"2015-09-03T17:29:27Z","updated_at":"2016-01-12T19:03:22Z","pushed_at":"2016-03-22T00:36:43Z","git_url":"git://github.com/ifwe/monocle-api.git","ssh_url":"git@github.com:ifwe/monocle-api.git","clone_url":"https://github.com/ifwe/monocle-api.git","svn_url":"https://github.com/ifwe/monocle-api","homepage":null,"size":196,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/47"},"html":{"href":"https://github.com/ifwe/monocle-api/pull/47"},"issue":{"href":"https://api.github.com/repos/ifwe/monocle-api/issues/47"},"comments":{"href":"https://api.github.com/repos/ifwe/monocle-api/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ifwe/monocle-api/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/ifwe/monocle-api/statuses/461eb511b164e4260acb0700b7d4c867a226e8c3"}}}}