{"action":"closed","issue":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/671","repository_url":"https://api.github.com/repos/jagi/meteor-astronomy","labels_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/671/labels{/name}","comments_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/671/comments","events_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/671/events","html_url":"https://github.com/jagi/meteor-astronomy/issues/671","id":310319386,"node_id":"MDU6SXNzdWUzMTAzMTkzODY=","number":671,"title":"Functions inside objects trigger lots of warnings on schema validation","user":{"login":"derwok","id":4393698,"node_id":"MDQ6VXNlcjQzOTM2OTg=","avatar_url":"https://avatars1.githubusercontent.com/u/4393698?v=4","gravatar_id":"","url":"https://api.github.com/users/derwok","html_url":"https://github.com/derwok","followers_url":"https://api.github.com/users/derwok/followers","following_url":"https://api.github.com/users/derwok/following{/other_user}","gists_url":"https://api.github.com/users/derwok/gists{/gist_id}","starred_url":"https://api.github.com/users/derwok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derwok/subscriptions","organizations_url":"https://api.github.com/users/derwok/orgs","repos_url":"https://api.github.com/users/derwok/repos","events_url":"https://api.github.com/users/derwok/events{/privacy}","received_events_url":"https://api.github.com/users/derwok/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-01T12:16:40Z","updated_at":"2019-01-04T23:59:51Z","closed_at":"2019-01-04T23:59:50Z","author_association":"NONE","body":"First of all - thank you for providing this great package! We use it for Schema validation in our open source meeting minutes WebApp https://www.4minitz.com\r\n\r\nWe migrated from the aledeed:simple-schema to Astronomy.\r\n\r\nWhen saving objects via Astronony we get this kind (client side) warning \"all over the place\":\r\n\r\n```\r\n[\"MeetingSeriesSchema\" class][\"findLabelByName\" field] Trying to set a value of the field that does not exist in the class\r\n[\"MeetingSeriesSchema\" class][\"upsertLabel\" field] Trying to set a value of the field that does not exist in the class\r\n[\"MeetingSeriesSchema\" class][\"getAvailableLabels\" field] Trying to set a value of the field that does not exist in the class\r\n```\r\n\r\n`findLabelByName`, `upsertLabel` and `getAvailableLabels` are functions attached to the object to be stored. The reason for the warnings seem to be all thes \"intelligent\" functions. We enriched the \"dumb\" database objects by the functions defined in a separate class by tranforming them:\r\n\r\n```\r\nlet MeetingSeriesCollection = new Mongo.Collection('meetingSeries', {\r\n    transform: function (doc) {\r\n        return new MeetingSeries(doc);\r\n    }\r\n});\r\n```\r\nThe Schema is attached like so:\r\n```\r\nexport const MeetingSeriesSchema = SchemaClass.create({\r\n    name: 'MeetingSeriesSchema',\r\n    collection: MeetingSeriesCollection,\r\n    fields: {\r\n        project: {type: String},\r\n        name: {type: String},\r\n        createdAt: {type: Date},\r\n```\r\n\r\nSo, while we understand that Astronomy provides a way to add functions to objects inside the schema, this would be a rather huge refactoring for us. To \"whitelist\" our functions somehow inside the schema would lead to error prone house keeping.\r\n\r\nBut, as far as we know, functions can not be stored to MongoDB anyhow. So it seems save that they are stripped in insert/update operations or during validation. Or that they are simply not considered in validations. \r\n\r\nOur question now is: \r\n* Can we configure schema validation to ignore or silently clean functions attached to objects on insert/update? {Preferred}\r\n* Or can we swallow the warnings that currently pollute the client log? {Preferred we could only do this for functions - other warnings are still of interrest!}\r\n* Is there a pre-validation hook where we could somehow inject our removing of functions {Helpful. But not really preferred... as it modifies the object that might be used after insers/update. This might lead to some surprises of the caller}\r\n"}}
{"actor":{"display_login":"lukejagodzinski"}}