reform
reform copied to clipboard
Draft of indexed errors implementation
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:
- Add one test for exactly the indexed errors, making the default, the non indexed behavior
- 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?
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
@fran-worley @apotonick should we consider these changes for the next release - if yes, let’s add it in the 2.3v milestone