{"action":"created","issue":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/3","labels_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/3/comments","events_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/3/events","html_url":"https://github.com/jagi/meteor-astronomy/issues/3","id":69024187,"number":3,"title":"How validators should work?","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},"labels":[{"url":"https://api.github.com/repos/jagi/meteor-astronomy/labels/discussion","name":"discussion","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-04-16T22:43:27Z","updated_at":"2015-04-21T12:33:41Z","closed_at":null,"body":"Hi, I have question to you about validators. I'm working now on implementing them as a module for Meteor Astronomy. Here is the [repository](https://github.com/jagi/meteor-astronomy-validators). It's not finished yet and I need your support on how it should work to be the most intuitive and easy in use. Please take a look at read me in the repository.\r\n\r\nLet me describe here how it works. Right now, we can [define array of validators](https://github.com/jagi/meteor-astronomy-validators#usage) in the class schema. In validator definition, we have to provide name of the `field` on which validation should take place, type of the validator, some options if required and error messages. We can also add validators that works on many fields like [Compare](https://github.com/jagi/meteor-astronomy-validators#compare) validator. To validate object we call `validate()` function on given object. Now few questions arises.\r\n\r\n1. Should validation take place automatically when calling `save()` method on the object?\r\n2. In what form would you like to get error message? Should it throw exception that you're gonna catch and display somewhere error or you want just `true` or `false` return value from the `validate()` method? And later you would like to call function like for instance `object.getErrors()` to get all errors.\r\n3. Right now you can have multiple validators per one field and validators that work on two fields (Compare). With validators working on one field there is no problem because we exactly know with what field it's related. But where to display error messages saying for instance that two values are not equal? What kind of customisation would you like to see?\r\n4. Do you need possibility to validate single field? Or single validator that works on two fields? Like `object.validate('comparePasswords')`?\r\n5. Do you want error messages to be reactive?\r\n\r\nIf you have any other idea I'm open for discussion :)"},"comment":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/comments/94776883","html_url":"https://github.com/jagi/meteor-astronomy/issues/3#issuecomment-94776883","issue_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/3","id":94776883,"user":{"login":"VladShcherbin","id":6711845,"avatar_url":"https://avatars.githubusercontent.com/u/6711845?v=3","gravatar_id":"","url":"https://api.github.com/users/VladShcherbin","html_url":"https://github.com/VladShcherbin","followers_url":"https://api.github.com/users/VladShcherbin/followers","following_url":"https://api.github.com/users/VladShcherbin/following{/other_user}","gists_url":"https://api.github.com/users/VladShcherbin/gists{/gist_id}","starred_url":"https://api.github.com/users/VladShcherbin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladShcherbin/subscriptions","organizations_url":"https://api.github.com/users/VladShcherbin/orgs","repos_url":"https://api.github.com/users/VladShcherbin/repos","events_url":"https://api.github.com/users/VladShcherbin/events{/privacy}","received_events_url":"https://api.github.com/users/VladShcherbin/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T12:33:41Z","updated_at":"2015-04-21T12:33:41Z","body":"@jagi yes, sure. it would be awesome to have that api\r\n\r\n```js\r\ntitle: 'string|min:5|max:30'\r\n```\r\n\r\nthank you! you are doing a great job! cant wait to see forms with this validators"}}