-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Path for array includes to contain key #385
Conversation
@@ -40,6 +40,22 @@ internals.Err.prototype.toString = function () { | |||
}; | |||
|
|||
|
|||
internals.Err.prototype.getPath = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to move this off the prototype and into an internals... otherwise it may be a little odd to have item.path
and item.getPath()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to expose this as a new API. Just pass this
as an argument.
Path for array includes to contain key
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Current behavior for an array including an object leaves the
path
without a key in the object.A message will read correctly:
"message: 'x position 1 fails because x must be a number"
While the corresponding path is:
"x.1"
This fix changes the path to read:
"x.1.x"
which then also matches the error message.This also matches the array behavior with how objects handle the same; where the final key is referenced that has the error occurring.
Assumptions: There will only be one reason so the error will be the first in the array (hence
context.reason.0
) . I couldn't find any case where it would be anything else.