Model validation, initial cut

Fixes #11.
This commit is contained in:
Matthew Dillon 2015-10-13 15:28:44 -07:00
parent a678eb4017
commit ae17363f8b
12 changed files with 162 additions and 52 deletions

17
types/validation-error.go Normal file
View file

@ -0,0 +1,17 @@
package types
import "encoding/json"
type ValidationError map[string][]string
func (v ValidationError) Error() string {
errs, err := json.Marshal(struct {
ValidationError `json:"errors"`
}{v})
if err != nil {
return err.Error()
}
return string(errs)
}