reform icon indicating copy to clipboard operation
reform copied to clipboard

Draft of indexed errors implementation

Open fernandes opened this issue 6 years ago • 2 comments

Hello,

Sorry if it's implemented elsewhere, I tried to find but didn't find, that's why I wrote a test case / drafted implementation so we can discuss.

Problem: When have an API, errors for collections are not indexed, so not sure about what element caused the error. Rails has implemented this behavior on https://github.com/rails/rails/pull/19686

Trying to set this configuration on my app, I wasn't successful, so implemented on Reform

Solution:

  1. Add one test for exactly the indexed errors, making the default, the non indexed behavior
  2. On Reform::Contract::Result::Errors if not using indexed errors, keep the usual behavior, else collect all the messages, but organized indexing for collections on the errors hash

TODO: @apotonick I know this class variable for configuration is stupid hahaha just wanted a fast switch for the test case, would it good how? as a feature?

fernandes avatar Oct 18 '18 17:10 fernandes

oh, now I double checked with rails implementation, it's supposed to be

:"variants[0].display_name" the id in the keys name, not an array, I'm gonna fix this

fernandes avatar Oct 18 '18 17:10 fernandes

@fran-worley @apotonick should we consider these changes for the next release - if yes, let’s add it in the 2.3v milestone

emaglio avatar Jul 12 '19 09:07 emaglio