Skip to content

When using given it does not actually check that it's required #1433

Closed
@andrew13nguyen

Description

@andrew13nguyen

I have code similar to this:

params do
  optional :button_link, type: String
  given :button_link do
    requires :button_text, type: String
  end
end

post :something do
  puts params.inspect
end

When I post to "something" with no params, everything is valid, but I see that params has:

params.inspect
=> {"button_text"=>nil}

When I change the params block to this:

params do
  optional :button_link, type: String
  given :button_link do#, :authenticated_button_link do
    requires :button_text, type: String, allow_blank: false
  end
end

I get a validation error (button_text is empty). Am I using given incorrectly or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions