Skip to content

Add support for exclusive parameter groups (e.g. exactly_one_of) #2418

Description

@fjesus-ic

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions