Skip to content

Drop Enumerable from Grape::Exceptions::ValidationErrors#2747

Open
ericproulx wants to merge 1 commit into
masterfrom
refactor/validation-errors-drop-enumerable
Open

Drop Enumerable from Grape::Exceptions::ValidationErrors#2747
ericproulx wants to merge 1 commit into
masterfrom
refactor/validation-errors-drop-enumerable

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

Summary

  • Grape::Exceptions::ValidationErrors no longer mixes in Enumerable and no longer defines a public #each. The Enumerable surface was undocumented (the README only covers #errors, #full_messages, #message, and rescue_from), untested, and had exactly one consumer: #full_messages calling map on self.
  • #full_messages now walks #errors directly via flat_map, documenting the data shape ({ params => [validations] }) at the call site.
  • UPGRADING.md includes a before/after migration snippet for any rescue_from blocks that were iterating the exception instance.

Test plan

  • bundle exec rspec — 2313 examples, 0 failures
  • No references to each/map/to_a on ValidationErrors instances remain in lib/ or spec/ (verified by grep)

`Grape::Exceptions::ValidationErrors` mixed in `Enumerable` and exposed
a public `#each` that yielded `(attribute, error)` pairs. That surface
was undocumented (the README only covers `#errors`, `#full_messages`,
`#message`, and `rescue_from`), untested, and had a single in-class
consumer: `#full_messages` calling `map` on `self`.

Removed `include Enumerable` and `#each`. Rewrote `#full_messages` to
walk the `errors` hash directly via `flat_map`, which also documents
the actual data shape (`{ params => [validations] }`) at the call site.

UPGRADING entry added since this is a contract break, even if the
surface was undocumented.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the refactor/validation-errors-drop-enumerable branch from 8f9f58c to c893c87 Compare May 25, 2026 08:35
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 25, 2026

Danger Report

No issues found.

View run

@dblock
Copy link
Copy Markdown
Member

dblock commented May 25, 2026

Why drop the enumerator?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants