Default value in optional param validation
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
Default value in optional param should not be respected in validation.
Lets see simple example where default is set for 'client' param.
params do
optional :client, type: Integer, default: 20
optional :filter_by_zone, type: Integer
at_least_one_of :client, :filter_by_zone
end
This params set will be valid even if no params passed in request.
Reproduce:
Send web request without params
Actually receiving:
Valid params and executing request
Expected:
Generate error "client, filter_by_zone are missing, at least one parameter must be provided".
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
Start by reproducing the validation with the optional :client and :filter_by_zone parameters shown in the issue, then inspect the parameter validation entry point that handles defaults and at_least_one_of. Done means a request with neither parameter produces the stated missing-parameter error instead of executing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100