softwaremill / softwaremill/tapir
[Feature] Add a way to accumulate multiple validations errors
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
Hi guys, I would like to start with congratulate me for your great work, I love use Tapir!
I wanted to ask if it was possible to create an accumulator of validation errors when validating the query parameters/body of a request.
For example in this piece of code:
import sttp.tapir._
val e = endpoint.in(
query[Int]("amount")
.validate(Validator.min(0))
.validate(Validator.max(100)))
query[Int]("taxes")
.validate(Validator.min(0))
.validate(Validator.max(100)))
This piece of code will fail at the first validate but I would like to return to my client something in this format (RFC 7807):
{
"type": "https://example.net/validation-error",
"title": "Your request parameters didn't validate.",
"invalid-params": [ {
"name": "amount",
"reason": "must be a greater than 0"
},
{
"name": "taxes",
"reason": "must be less than 100"}
]
}
Do you think that this is possible?
Thanks a lot!
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
No files or tests are named; start by tracing endpoint query/body validation and how multiple Validator results are currently handled. Define the accumulation behavior and RFC 7807 response shape, including each invalid parameter and reason, then verify that multiple validation failures are returned together.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100