Add support for exclusive parameter groups (e.g. exactly_one_of)
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
grape 2.0.0
Having an issue when using nested params with exactly_one_of, here is my current setup
params :required_date do
optional :date
use :date_range
exactly_one_of :date, :date_range
end
params :date_range do
requires :start_date
requires :end_date
valid_interval :start_date, :end_date
end
On my endpoint I'm using the required_date param
when I run the following:
/example_endpoint?start_date=2024-03-11&end_date=2024-03-12
It returns:
{"error":"parameter validation failed","parameters":["date","date_range"],"values":[null,null],"reason":"are missing, exactly one parameter must be provided: date, date_range"}
Any way that grape will check the nested params(start_date and end_date) instead of looking for date_range?
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
Reproduce the issue at the example endpoint using the required_date and date_range parameter definitions shown in the report. Start by tracing validation for exactly_one_of with nested params; done means start_date and end_date satisfy the date_range alternative instead of being reported as missing, while the exclusivity rule still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100