Drop Enumerable from Grape::Exceptions::ValidationErrors#2747
Open
ericproulx wants to merge 1 commit into
Open
Drop Enumerable from Grape::Exceptions::ValidationErrors#2747ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
`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>
8f9f58c to
c893c87
Compare
Danger ReportNo issues found. |
Member
|
Why drop the enumerator? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grape::Exceptions::ValidationErrorsno longer mixes inEnumerableand no longer defines a public#each. The Enumerable surface was undocumented (the README only covers#errors,#full_messages,#message, andrescue_from), untested, and had exactly one consumer:#full_messagescallingmaponself.#full_messagesnow walks#errorsdirectly viaflat_map, documenting the data shape ({ params => [validations] }) at the call site.UPGRADING.mdincludes a before/after migration snippet for anyrescue_fromblocks that were iterating the exception instance.Test plan
bundle exec rspec— 2313 examples, 0 failureseach/map/to_aonValidationErrorsinstances remain inlib/orspec/(verified by grep)