Dependent Params (given) with different value matching

Open
#1,628 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
api

Research direction

Reproduce the issue using the two dependent given blocks shown in the report, then trace Grape's parameter validation for dependent parameters and their values constraints. Done means each type value validates its corresponding resolution value without the other branch causing a conflict.

Written by the indexing model from the issue text.

Description

bug?

It seems I'm running into an issue where if I have multiple given blocks testing the same parameter, the value validation for those dependent parameters is conflicting. Here's my example:

params do
  requires :type, type: String, desc: 'Type', values: ['FRONT_CAMERA', 'REAR_CAMERA']
  given type: ->(val) { val == 'FRONT_CAMERA' } do
    requires :resolution, type: String, desc: 'Resolution', values: ['20x20']
  end
  given type: ->(val) { val == 'REAR_CAMERA' } do
     requires :resolution, type: String, desc: 'Resolution', values: ['1080x1080']
   end
end

(Pardon the falsified info)

Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby-grape/grape

All issues in ruby-grape/grape

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.