ruby-grape / ruby-grape/grape-entity

multiple error messages when used as params

Open
#263 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
729
Forks
154
PR merge metrics
No merged PRs in 30d

Description

class Entity < Grape::Entity
   expose :car,  documentation: { type: String, values: ["foo", "bar"] }
end

And then use it as validation with

params do 
  requires :all, using: Entity.documentation
end

"car is missing, car does not have a valid value"

Anyway, for it to just have the second one of the error messages? If I don't make it required then it does not show up at all.

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

Reproduce the example using Grape::Entity documentation as the schema for requires :all, using: Entity.documentation. Start by tracing how the car documentation becomes parameter validation and how missing and invalid-value errors are collected. Done means the example reports only the invalid-value message when car is present with an unsupported value, while preserving the intended behavior for missing values.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.