Feature Request - To get the field name from the incoming request
abhishek-galoda opened this issue · 2 comments
abhishek-galoda commented
Hello,
I would like to ask, if you can add a feature where in Request/Response Validation Errors we can get the "field" name . This is also provided in Kin api but not in this API.
I think this would be great addittion to this great API
daveshanley commented
OK.
eliofery commented
Is there progress in this direction?
Since it is impossible to directly obtain the field name, you have to use regular expressions.
Example:
func errorFormat(errMsg error) error {
reg, err := regexp.Compile(`Reason: (.*), Location: (.*)`)
if err != nil {
return err
}
match := reg.FindStringSubmatch(errMsg.Error())
if len(match) > 2 {
return fmt.Errorf("%s: %s", match[2], match[1])
}
return errMsg
}
Which is not entirely convenient and instead of the field name you get something like this: /properties/password/minLength