softwaremill / softwaremill/tapir
Can we support custom error message for Enumeration Validation?
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
Feature request
Since we can validate an Enumeration using sttp.tapir.Validator.Enumeration, I want to have a custom message for the invalid case.
Use case
For example, when we want to validate a list of enumeration inputs, if one of them fails the validation, the error message is too generic to specify which one is wrong.
Proposed solution
We can add an optional field to sttp.tapir.Validator.Enumeration as showMessageOpt: Option[T => String] to handle the error message.
Besides this approach, do we have any workaround? If not, I can help to implement this.
Contributor guide
No contributing guide indexed for this repository
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
Start at sttp.tapir.Validator.Enumeration and trace how invalid enumeration values are converted into validation errors. Check the existing validation behavior before deciding how the optional message function should be applied, especially when validating lists. Done means callers can provide a value-specific custom message while the default behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100