gin-gonic / gin-gonic/examples
Expand custom error messages to include API specific errors
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.6k
- Forks
- 726
- Avg merge
- 2h 23m
- Merged PRs (30d)
- 3
Description
Is it possible to add or enlarge an existing example so as to include custom error messages that should be returned to the consumer of the API we build?
I'm not able to add a custom validator and add as well a application specific defined message that is more descriptive than:
{"error":"Key: 'Booking.CheckOut' Error:Field validation for 'CheckOut' failed on the 'required' tag"}%
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by locating the existing validation example in the examples repository and review how Gin exposes validator errors. Define the API-specific error-message behavior in the example, then verify that it returns the intended custom message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100