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

fix unknown nested key path #684

Merged
merged 1 commit into from
Jul 13, 2015
Merged

fix unknown nested key path #684

merged 1 commit into from
Jul 13, 2015

Conversation

mgartner
Copy link
Contributor

While working on building a custom error message formatter for Joi validation errors, I noticed an inconsistency with the path attribute of unknown object keys. Nested object keys don't have the full path. For example:

Joi.validate({ key: 'value' }, {}, function (err) {
  console.log(err.details[0].path); // prints "key"
});

Joi.validate({ key: { nestedKey: 'value' } }, { key: {} }, function (err) {
  console.log(err.details[0].path); // prints "key" instead of "key.nestedKey"
});

This patch adds the full path to validation errors of unknown nested keys.

@Marsup Marsup added this to the 6.6.0 milestone Jul 13, 2015
@Marsup Marsup added the bug Bug or defect label Jul 13, 2015
@Marsup Marsup self-assigned this Jul 13, 2015
Marsup added a commit that referenced this pull request Jul 13, 2015
@Marsup Marsup merged commit e202ca1 into hapijs:master Jul 13, 2015
@Marsup
Copy link
Collaborator

Marsup commented Jul 13, 2015

Thanks.

@mgartner mgartner deleted the fix-unknown-key-path branch July 13, 2015 15:44
@mgartner
Copy link
Contributor Author

Any chance of publishing a new version with this included soon?

@Marsup
Copy link
Collaborator

Marsup commented Jul 20, 2015

Done.

@lock
Copy link

lock bot commented Jan 9, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants