{"action":"created","issue":{"url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/87","labels_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/87/labels{/name}","comments_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/87/comments","events_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/87/events","html_url":"https://github.com/holidayextras/jsonapi-server/pull/87","id":125577606,"number":87,"title":"Use Jois sanitisation as well as validation for input+output","user":{"login":"theninj4","id":3055120,"avatar_url":"https://avatars.githubusercontent.com/u/3055120?v=3","gravatar_id":"","url":"https://api.github.com/users/theninj4","html_url":"https://github.com/theninj4","followers_url":"https://api.github.com/users/theninj4/followers","following_url":"https://api.github.com/users/theninj4/following{/other_user}","gists_url":"https://api.github.com/users/theninj4/gists{/gist_id}","starred_url":"https://api.github.com/users/theninj4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theninj4/subscriptions","organizations_url":"https://api.github.com/users/theninj4/orgs","repos_url":"https://api.github.com/users/theninj4/repos","events_url":"https://api.github.com/users/theninj4/events{/privacy}","received_events_url":"https://api.github.com/users/theninj4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/holidayextras/jsonapi-server/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-08T09:49:06Z","updated_at":"2016-01-08T09:50:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/holidayextras/jsonapi-server/pulls/87","html_url":"https://github.com/holidayextras/jsonapi-server/pull/87","diff_url":"https://github.com/holidayextras/jsonapi-server/pull/87.diff","patch_url":"https://github.com/holidayextras/jsonapi-server/pull/87.patch"},"body":"In the past we've been using Joi to simply validate objects. Joi will also sanitise data, which does some useful things like:\r\n\r\n1. Query string properties (which are always interpreted as strings) will be coerced into the correct type - so number types in a query string will become numbers.\r\n2. We can apply default values to both attribute and search parameters.\r\n\r\nYou can test this by starting the example server with debugging:\r\n```\r\n$ DEBUG=jsonApi:handler:search npm start\r\n```\r\nand visiting http://localhost:16006/rest/articles?query=123\r\n\r\nYou'll see in the console the type coercion taking place - the `query` param becomes a number:\r\n```\r\n  jsonApi:handler:search {\"type\":\"articles\",\"query\":123,\"page\":{\"offset\":0,\"limit\":50}} .......\r\n```\r\n\r\nYou'll see in the response payload every article has a new attribute `status: \"published\"` which is added by the new Joi schema `status: jsonApi.Joi.string().default(\"published\")`."},"comment":{"url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/comments/169949891","html_url":"https://github.com/holidayextras/jsonapi-server/pull/87#issuecomment-169949891","issue_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/87","id":169949891,"user":{"login":"theninj4","id":3055120,"avatar_url":"https://avatars.githubusercontent.com/u/3055120?v=3","gravatar_id":"","url":"https://api.github.com/users/theninj4","html_url":"https://github.com/theninj4","followers_url":"https://api.github.com/users/theninj4/followers","following_url":"https://api.github.com/users/theninj4/following{/other_user}","gists_url":"https://api.github.com/users/theninj4/gists{/gist_id}","starred_url":"https://api.github.com/users/theninj4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theninj4/subscriptions","organizations_url":"https://api.github.com/users/theninj4/orgs","repos_url":"https://api.github.com/users/theninj4/repos","events_url":"https://api.github.com/users/theninj4/events{/privacy}","received_events_url":"https://api.github.com/users/theninj4/received_events","type":"User","site_admin":false},"created_at":"2016-01-08T09:50:13Z","updated_at":"2016-01-08T09:50:13Z","body":"This resolves #84 @futurist "}}