ruby-grape / ruby-grape/grape

Parameter Dynamic Required vs Optional Validation

Open
#1,015 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

First thanks for the sweet framework, my team and I are big fans of grape. And perhaps this a good opportunity to contribute back.

I was however unable to find any additional information related to the ability to change params required/optional state at runtime/request time.

The use case is that the API based off some values in the request can dynamically enforce optional vs required behavior. Namely a request that looks something like this

{
"required" : "param1,param2,param3",
...
}

As far as I can tell this is currently not possible? Maybe hooking into the pre_validation block?

Could this be added as a validation feature? Perhaps a new type called dynamic that has some matching/parsing convention that can be user defined

Thanks!

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.

Research direction

Start by examining the framework's pre_validation hook and existing parameter-validation behavior. Define how request-time required and optional states should be expressed and verified, including the proposed dynamic validation type; no file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.