ruby-grape / ruby-grape/grape-entity
multiple error messages when used as params
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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