Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Allow data to be an array #65

Closed
wants to merge 2 commits into from
Closed

Allow data to be an array #65

wants to merge 2 commits into from

Conversation

daffl
Copy link
Member

@daffl daffl commented Mar 8, 2017

Closes #64

@marshallswain
Copy link
Member

marshallswain commented Mar 17, 2017

@daffl is there some pending work, here? If not feel free to :shipit:

@daffl
Copy link
Member Author

daffl commented Mar 17, 2017

Yes, there was some further discussion in #64.

@ekryski
Copy link
Member

ekryski commented Mar 31, 2017

Yeah, I might be missing something but I'm not sure if this is necessary. See my comment #64 (comment)

@eddyystop
Copy link

I've seen errors being passed back as an array for UI's which display all errors together, rather than field by field. Whereas errors being passed back as an object for Ui's that display errors by the field in question.

Is this what this issue is really about?

@daffl
Copy link
Member Author

daffl commented Apr 1, 2017

I'm not sure why this is controversial. The test shows an issue with a use case someone discovered and fixes it in a non-breaking way.

errors = newData.errors;
delete newData.errors;
}
if (data && data.errors) {
Copy link
Member

@ekryski ekryski Apr 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a side effect here. If data.errors is undefined then the data object won't be cloned. If that data object is modified elsewhere it will also be modified here.

The intention was that once the data object is passed in during the creation of a new Error, that data object should be immutable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just clone the object using:

let clone = JSON.parse(JSON.stringify(data));

In contract to Object.assign() this works well with arrays.

@ekryski
Copy link
Member

ekryski commented Apr 2, 2017

It is potentially breaking. I don't care whether data is an object or an array. It's fine if it handles both. This just needs to be tuned up a bit. I was merely pointing out that if the intention was for the errors object to be an array then that's already possible.

The data object is meant for any additional metadata beyond the errors object. For example, if you wanted to include the hook method or the user id.

@daffl
Copy link
Member Author

daffl commented May 8, 2017

Superseded by #75

@daffl daffl closed this May 8, 2017
@daffl daffl deleted the data-array-64 branch May 8, 2017 19:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants