{"action":"created","issue":{"url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/34","repository_url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal","labels_url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/34/comments","events_url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/34/events","html_url":"https://github.com/ASUKanbosalCapstone/Kanbosal/issues/34","id":140432536,"number":34,"title":"Database format validation.","user":{"login":"lburkett","id":3622791,"avatar_url":"https://avatars.githubusercontent.com/u/3622791?v=3","gravatar_id":"","url":"https://api.github.com/users/lburkett","html_url":"https://github.com/lburkett","followers_url":"https://api.github.com/users/lburkett/followers","following_url":"https://api.github.com/users/lburkett/following{/other_user}","gists_url":"https://api.github.com/users/lburkett/gists{/gist_id}","starred_url":"https://api.github.com/users/lburkett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lburkett/subscriptions","organizations_url":"https://api.github.com/users/lburkett/orgs","repos_url":"https://api.github.com/users/lburkett/repos","events_url":"https://api.github.com/users/lburkett/events{/privacy}","received_events_url":"https://api.github.com/users/lburkett/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/labels/feature","name":"feature","color":"eb6420"},{"url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-13T00:53:31Z","updated_at":"2016-03-13T01:20:42Z","closed_at":null,"body":"I guess this issue can be used as a discussion on where we want to do the database validation. The big question is if we want to do the validation client-side, server-side, or some mix of both.\r\n\r\nAt the moment I have some bare-bones validation for cards setup in the web service here [kanbosalService/collectionDriver.js](https://github.com/ASUKanbosalCapstone/Kanbosal/blob/database-implementation/kanbosalService/collectionDriver.js) that looks like such:\r\n```javascript\r\nvar ensureCardFormat = function(doc, errorCallback) {\r\n    if (!doc.title instanceof String)\r\n        errorCallback(new Error(\"title must be a string.\"));\r\n    doc.notes.forEach(function(note) {\r\n        if (!note instanceof String)\r\n            errorCallback(new Error(\"notes must be strings.\"));\r\n    });\r\n    if (!doc.documentUrl instanceof String)\r\n        errorCallback(new Error(\"documentUrl must be a string.\"));\r\n    if (!doc.timeCreated instanceof Object)\r\n        errorCallback(new Error(\"timeCreated must be an object of Date.\"));\r\n    if (!doc.timeLastEdit instanceof Object)\r\n        errorCallback(new Error(\"timeLastEdit must be an object of Date.\"));\r\n    if (!doc.status instanceof String)\r\n        errorCallback(new Error(\"status must be a string.\"));\r\n    doc.tags.forEach(function(tag) {\r\n        if (!tag instanceof String)\r\n            errorCallback(new Error(\"tags must be strings.\"));\r\n    });\r\n    doc.userIds.forEach(function(userId) {\r\n        if (!userId instanceof String)\r\n            errorCallback(new Error(\"userIds must be ObjectIDs.\"));\r\n    });\r\n    doc.lock.forEach(function(l) {\r\n        if (!l instanceof Boolean)\r\n            errorCallback(new Error(\"locks must be booleans.\"));\r\n    })\r\n}\r\n```\r\nPretty ugly, but it must be done to ensure proper document delivery.\r\n\r\nI think we should extend this to the other collections and if the format is incorrect we can just have the service respond back with an error or bad request. Another question would be, how would our application handle receiving an error in the off chance it does happen?"},"comment":{"url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/comments/195847213","html_url":"https://github.com/ASUKanbosalCapstone/Kanbosal/issues/34#issuecomment-195847213","issue_url":"https://api.github.com/repos/ASUKanbosalCapstone/Kanbosal/issues/34","id":195847213,"user":{"login":"lburkett","id":3622791,"avatar_url":"https://avatars.githubusercontent.com/u/3622791?v=3","gravatar_id":"","url":"https://api.github.com/users/lburkett","html_url":"https://github.com/lburkett","followers_url":"https://api.github.com/users/lburkett/followers","following_url":"https://api.github.com/users/lburkett/following{/other_user}","gists_url":"https://api.github.com/users/lburkett/gists{/gist_id}","starred_url":"https://api.github.com/users/lburkett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lburkett/subscriptions","organizations_url":"https://api.github.com/users/lburkett/orgs","repos_url":"https://api.github.com/users/lburkett/repos","events_url":"https://api.github.com/users/lburkett/events{/privacy}","received_events_url":"https://api.github.com/users/lburkett/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T01:20:42Z","updated_at":"2016-03-13T01:20:42Z","body":"Yes, the dates are not necessary to validate. I had them in there to originally cover my bases, but they are generated with Date objects.\r\n\r\nIs form validation going to be enough do you think? I guess the worry was someone being able to make a request to the service in some unknown way and that's why I started implementing server side checks."}}