{"action":"created","issue":{"url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/1929","repository_url":"https://api.github.com/repos/VulcanJS/Vulcan","labels_url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/1929/labels{/name}","comments_url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/1929/comments","events_url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/1929/events","html_url":"https://github.com/VulcanJS/Vulcan/issues/1929","id":305216780,"number":1929,"title":"validation.js breaks deep object validation that SimpleSchema supports","user":{"login":"nolandg","id":5650727,"avatar_url":"https://avatars0.githubusercontent.com/u/5650727?v=4","gravatar_id":"","url":"https://api.github.com/users/nolandg","html_url":"https://github.com/nolandg","followers_url":"https://api.github.com/users/nolandg/followers","following_url":"https://api.github.com/users/nolandg/following{/other_user}","gists_url":"https://api.github.com/users/nolandg/gists{/gist_id}","starred_url":"https://api.github.com/users/nolandg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolandg/subscriptions","organizations_url":"https://api.github.com/users/nolandg/orgs","repos_url":"https://api.github.com/users/nolandg/repos","events_url":"https://api.github.com/users/nolandg/events{/privacy}","received_events_url":"https://api.github.com/users/nolandg/received_events","type":"User","site_admin":false},"labels":[{"id":13375103,"url":"https://api.github.com/repos/VulcanJS/Vulcan/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-03-14T15:47:49Z","updated_at":"2018-03-15T23:21:12Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"SimpleSchema supports deep object validation, eg:\r\n````\r\n  data: {\r\n    type: Object,\r\n    optional: false,\r\n    viewableBy: ['members'],\r\n    },\r\n  },\r\n  'data.value': {\r\n    type: Number,\r\n    optional: false,\r\n  },\r\n````\r\nis perfectly valid and when it is validated in step 5:\r\nhttps://github.com/VulcanJS/Vulcan/blob/0c06dc9b55e6bb456124f38f881aebad917c8025/packages/vulcan-lib/lib/modules/validation.js#L59\r\nit passes the SimpleSchema tests fine. But it does not pass the extra Vulcan step 4:\r\nhttps://github.com/VulcanJS/Vulcan/blob/0c06dc9b55e6bb456124f38f881aebad917c8025/packages/vulcan-lib/lib/modules/validation.js#L45\r\nbecause the special Vulcan validation does not support deep keys. It's trying to do this:\r\n`document[\"data.value\"]` instead of `document.data.value`\r\n\r\nWhy does the comment say \"run SS validation for now for backwards compatibility\"? Aren't we full on using SimpleSchema?\r\n\r\nIf we just remove Step 4, it works great. SimpleSchema already checks for missing required fields just fine and does it deeply.\r\n\r\nDo you want a PR to remove Step 4?"},"comment":{"url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/comments/373553558","html_url":"https://github.com/VulcanJS/Vulcan/issues/1929#issuecomment-373553558","issue_url":"https://api.github.com/repos/VulcanJS/Vulcan/issues/1929","id":373553558,"user":{"login":"nolandg","id":5650727,"avatar_url":"https://avatars0.githubusercontent.com/u/5650727?v=4","gravatar_id":"","url":"https://api.github.com/users/nolandg","html_url":"https://github.com/nolandg","followers_url":"https://api.github.com/users/nolandg/followers","following_url":"https://api.github.com/users/nolandg/following{/other_user}","gists_url":"https://api.github.com/users/nolandg/gists{/gist_id}","starred_url":"https://api.github.com/users/nolandg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolandg/subscriptions","organizations_url":"https://api.github.com/users/nolandg/orgs","repos_url":"https://api.github.com/users/nolandg/repos","events_url":"https://api.github.com/users/nolandg/events{/privacy}","received_events_url":"https://api.github.com/users/nolandg/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T23:21:12Z","updated_at":"2018-03-15T23:21:12Z","author_association":"CONTRIBUTOR","body":"Sorry, after attempting this I'm finding it's too much work and I'm not doing it. There is too much logic to duplicate that SS handles. \r\n\r\nFor example SS supports this case: `billingAddress` object is optional but if it does exist or if it's being `$set` then all of it's required child properties like `billingAddress.city` are required. Now you have to start stepping through the tree one by one, not just blindly checking existence. That's too much to duplicate for me.\r\n\r\nAnd arrays. An array can be optional but if it exists, child properties on it's object elements can be required.\r\n"}}
{"actor":{"display_login":"nolandg"}}