{"action":"closed","issue":{"url":"https://api.github.com/repos/typerandom/cocoon/issues/8","labels_url":"https://api.github.com/repos/typerandom/cocoon/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/typerandom/cocoon/issues/8/comments","events_url":"https://api.github.com/repos/typerandom/cocoon/issues/8/events","html_url":"https://github.com/typerandom/cocoon/issues/8","id":70929505,"number":8,"title":"Function validation","user":{"login":"typerandom","id":1331778,"avatar_url":"https://avatars.githubusercontent.com/u/1331778?v=3","gravatar_id":"","url":"https://api.github.com/users/typerandom","html_url":"https://github.com/typerandom","followers_url":"https://api.github.com/users/typerandom/followers","following_url":"https://api.github.com/users/typerandom/following{/other_user}","gists_url":"https://api.github.com/users/typerandom/gists{/gist_id}","starred_url":"https://api.github.com/users/typerandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typerandom/subscriptions","organizations_url":"https://api.github.com/users/typerandom/orgs","repos_url":"https://api.github.com/users/typerandom/repos","events_url":"https://api.github.com/users/typerandom/events{/privacy}","received_events_url":"https://api.github.com/users/typerandom/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/typerandom/cocoon/labels/feature","name":"feature","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-25T15:45:01Z","updated_at":"2015-04-25T21:10:51Z","closed_at":"2015-04-25T21:10:51Z","body":"We should have the ability to validate a field with a custom function.\r\n\r\n##### Suggestion\r\n\r\n    type Something struct {\r\n        Value string `validate:\"func\"`\r\n    }\r\n\r\n    func (this *Something) ValidateValue(value interface{}) error {\r\n        if stringValue, ok := value.(string); ok {\r\n            if stringValue != \"something\" && stringValue != \"special\" {\r\n                return errors.New(\"Value can only be 'something' or 'special'.\")\r\n            }\r\n        }\r\n        return nil\r\n    }\r\n\r\nor specify a custom name...\r\n\r\n    type Something struct {\r\n        Value string `validate:\"func(ValidateSomeThingFn)\"`\r\n    }\r\n\r\n    func (this *Something) ValidateSomeThingFn(value interface{}) error {\r\n        // validate...\r\n    }"}}