Closed tomsteele closed 10 years ago
That looks simpler than I was originally thinking it may be. Thanks! When you have a moment, could you help me out by adding a test or two to verify its behavior? (I know the test file is kind of gnarly. Someday I'll clean it up and maybe splice it into different files.)
Added some simple tests. Also we may want to create a separate issue for this, but at the moment, the tests for empty payloads are broken. Broken in the sense that they don't operate as they should. Each request results in a 404 because test.Path is set to "".
Okie dokie, thanks!
And you're right about the tests, thanks for finding that. This package originally started much smaller and the tests have become a bit unwieldy. I have plans to splice the tests out into different files and make them easier to grok.
At that time, I'll also look at those empty payloads tests.
When a field is required and missing the response back uses field.Name. Most of the time this is going to be different from the form or JSON key name. This could be confusing to application consumers viewing these error messages.
What I've done is add some logic to populate the RequireError with the key being set to the value of field.Name, then the json tag if present, then the form value if present.