json-api error format

Part of #11.
This commit is contained in:
Matthew Dillon 2015-10-14 10:28:09 -07:00
parent 2894efaf46
commit 708eed5817
6 changed files with 62 additions and 14 deletions

View file

@ -43,11 +43,15 @@ func (s *SpeciesBase) validate() types.ValidationError {
sv := make(types.ValidationError, 0)
if s.GenusID == 0 {
sv["Genus"] = []string{helpers.MustProvideAValue}
sv = append(sv, types.NewValidationError(
"genus",
helpers.MustProvideAValue))
}
if s.SpeciesName == "" {
sv["Species"] = []string{helpers.MustProvideAValue}
sv = append(sv, types.NewValidationError(
"speciesName",
helpers.MustProvideAValue))
}
if len(sv) > 0 {