# HG changeset patch # User Sascha L. Teichmann # Date 1548242769 -3600 # Node ID 0bc0312105e4628b8222e6625f991c53211e3419 # Parent 0a8fa6893181cd5126b9215ccfb82fd4c3ada6f8 Improved the error message a bit if an invalid country name is passed via JSON api. diff -r 0a8fa6893181 -r 0bc0312105e4 pkg/models/common.go --- a/pkg/models/common.go Wed Jan 23 12:09:23 2019 +0100 +++ b/pkg/models/common.go Wed Jan 23 12:26:09 2019 +0100 @@ -61,7 +61,6 @@ "AT", "BG", "DE", "HU", "HR", "MD", "RO", "RS", "SK", "UA", } - errNoValidCountry = errors.New("Not a valid country") ) // UnmarshalJSON ensures that the given string forms a valid @@ -71,14 +70,14 @@ if err := json.Unmarshal(data, &s); err != nil { return err } - s = strings.ToUpper(s) + u := strings.ToUpper(s) for _, v := range validCountries { - if v == s { + if v == u { *c = Country(v) return nil } } - return errNoValidCountry + return fmt.Errorf("'%s' is not a valid country", s) } // Value implements the driver.Valuer interface.