Skip to content

Use param foo in default for bar #2290

Closed
@jamesarosen

Description

@jamesarosen

What I'd like to do:

params do
  requires :foo
  optional :bar, default: -> (other_params) { "bar from foo #{other_params[:foo]} }
end

or perhaps

params do
  requires :foo
  optional :bar, coerce: -> (bar_value, other_params) { "bar from foo #{other_params[:foo]} }
end

Unfortunately, neither default nor coerce seems to accept the other params as an argument. It may be possible to get them from self (which is a ParamsScope) within that block, but it's not obvious how.

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