sinatra-param icon indicating copy to clipboard operation
sinatra-param copied to clipboard

Return multiple errors

Open jtara opened this issue 6 years ago • 1 comments

Currently, it seems to only return the first error found. So, e.g. API user gets an error, fixes the parameter, then gets an error on a different parameter. Rinse and repeat.

It would be useful to return multiple errors. To avoid the need for "rinse and repeat".

It begs the question, though, about "message" vs "errors". I'm not sure why they both exist in the first place? If it were to check and return errors for multiple parameters, what, logically, should "message be".

Multiple errors?

errors is an array, so there must have been some intent to return multiple errors. Is it just that that feature is not implemented, or am I doing something wrong?

jtara avatar Aug 28 '18 18:08 jtara

Follow this instructions here: https://github.com/mattt/sinatra-param#exceptions

The default behaviour returns a 400 response as soon as a param validations fails. If you set :raise_sinatra_param_exceptions, true you can rescue individual exceptions and append all messages to a variable, but I'm afraid it's a bit more difficult than this.

pjmartorell avatar Mar 13 '20 10:03 pjmartorell