Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for configuring Error paths as an Array of path segments #60

Merged
merged 1 commit into from
Oct 27, 2014
Merged

Support for configuring Error paths as an Array of path segments #60

merged 1 commit into from
Oct 27, 2014

Conversation

whitlockjc
Copy link
Contributor

Add configurable support for Error objects to use an Array of path segments

To use, pass the reportPathAsArray option to ZSchema.

Fixes #55

@whitlockjc
Copy link
Contributor Author

There is a little extra code in this commit that could/should be removed if you agree with #59. Long story short, Report.paths is not stored internally as an array of path segments but a mix of path segments and special values for certain object keys and all array indices. This means I have to undo some of this in my code to make this work properly. If #59 were already done, a lot of the code in Report#getPath could go away.

function Report(parentOrOptions) {
// Reasonable defaults
parentOrOptions = parentOrOptions || {
reportPathAsArray: false
Copy link
Owner

Choose a reason for hiding this comment

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

do we really need explicit false here? would it behave differently if there'd be reportPathAsArray: undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's your call, I just figured my first PR should be explicit and we could relax things from there. (I didn't want to come off as lazy or making assumptions.) I will remove it.

@zaggino
Copy link
Owner

zaggino commented Oct 27, 2014

Hi @whitlockjc , wasn't here for the weekend. Just two minor comments and feel free to proceed with the #59

…gments

To use, pass the `reportPathAsArray` option to `ZSchema`.

Fixes #55
@whitlockjc
Copy link
Contributor Author

I've updated the pull request with the changes you requested. I amended the commit to avoid you having to do more work squashing the commits and such. Please let me know if I can do more to get this accepted.

@zaggino zaggino merged commit 17557f5 into zaggino:master Oct 27, 2014
@zaggino
Copy link
Owner

zaggino commented Oct 27, 2014

Looks fine to me, merged 👍

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.

Error paths as Array
2 participants