I have a struct
type InputData struct {
SomeNumber int `json:"someNumber"`
SomeText string `json:"someText"`
}
I do json.Unmarshal my http request body into a struct of type InputData.
In case I pass in {"someNumber": "NaN", "someText": 42} I get something like
panic: json: cannot unmarshal string into Go struct field InputData.someNumber of type int
Is there a way to get complete and more structured error data?
For instance, a list of all the non-parseable fields along w/ the reason for that? (in my example, I'd like to know that someNumber is invalid because I passed in a string AND that someText is invalid because I passed in a number)
I doubt that's possible, but I'd still like to validate my input in that sense. Is it a use case for JSON-Schema validation?