{"action":"created","issue":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/15","labels_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/15/comments","events_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/15/events","html_url":"https://github.com/jagi/meteor-astronomy/issues/15","id":79811283,"number":15,"title":"_errors is not send back to client","user":{"login":"parhelium","id":725686,"avatar_url":"https://avatars.githubusercontent.com/u/725686?v=3","gravatar_id":"","url":"https://api.github.com/users/parhelium","html_url":"https://github.com/parhelium","followers_url":"https://api.github.com/users/parhelium/followers","following_url":"https://api.github.com/users/parhelium/following{/other_user}","gists_url":"https://api.github.com/users/parhelium/gists{/gist_id}","starred_url":"https://api.github.com/users/parhelium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parhelium/subscriptions","organizations_url":"https://api.github.com/users/parhelium/orgs","repos_url":"https://api.github.com/users/parhelium/repos","events_url":"https://api.github.com/users/parhelium/events{/privacy}","received_events_url":"https://api.github.com/users/parhelium/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jagi/meteor-astronomy/labels/feature","name":"feature","color":"008000"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-23T10:44:57Z","updated_at":"2015-05-24T17:31:22Z","closed_at":null,"body":"`menu` is instance of `Astro.Class`.\r\n\r\nServer side :\r\n\r\n        if ( menu.validate() ) {\r\n            menu.save();\r\n        } else {\r\n            console.log( menu._errors._getMigrationData() );\r\n            return menu;\r\n        }\r\n\r\nAbove `console.log` show that there is invalid field in `menu`.\r\n`_errors : ReactiveDict` is not send through DDP , so client side can't see errors sent by server side.\r\nThere are some custom validators which should run on server ( unique ). So my goal is to validate on client side and then validate on server side. Eventually errors should be send back to client side.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/comments/105041185","html_url":"https://github.com/jagi/meteor-astronomy/issues/15#issuecomment-105041185","issue_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/15","id":105041185,"user":{"login":"jagi","id":1051229,"avatar_url":"https://avatars.githubusercontent.com/u/1051229?v=3","gravatar_id":"","url":"https://api.github.com/users/jagi","html_url":"https://github.com/jagi","followers_url":"https://api.github.com/users/jagi/followers","following_url":"https://api.github.com/users/jagi/following{/other_user}","gists_url":"https://api.github.com/users/jagi/gists{/gist_id}","starred_url":"https://api.github.com/users/jagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jagi/subscriptions","organizations_url":"https://api.github.com/users/jagi/orgs","repos_url":"https://api.github.com/users/jagi/repos","events_url":"https://api.github.com/users/jagi/events{/privacy}","received_events_url":"https://api.github.com/users/jagi/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T17:31:22Z","updated_at":"2015-05-24T17:31:22Z","body":"@parhelium there are a few things worth mentioning here.\r\n1. I've made an update to Validators module and now you can send errors through DDP protocol. Now it should be much easier to exchange errors between client and sever.\r\n2. I've updated the example I mentioned about and now it returns to the client server validation errors: https://github.com/jagi/meteor-astronomy-examples/blob/master/methods.js\r\n3. In your validator function you should rely on the third `collection` argument. To be honest I didn't even know that I'm passing it. It's just side effect of using underscore `_.each` method. Instead you should use `this.constructor.getCollection()` to take collection that given record belongs to.\r\n\r\nI forgot about `unique` validator, I'm glad that you mentioned about it. If you don't mind I will add it to the list of standard validators included with Validators module.\r\n\r\nThe `unique` validator will only work properly on the sever. We can have situations that not all documents are published to the client. But I don't think it's a big problem. When doing validation on both client and sever, it will still return errors from the server that we can use."}}