Skip to content

fix unknown nested key path#684

Merged
Marsup merged 1 commit intohapijs:masterfrom
mgartner:fix-unknown-key-path
Jul 13, 2015
Merged

fix unknown nested key path#684
Marsup merged 1 commit intohapijs:masterfrom
mgartner:fix-unknown-key-path

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