-
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
Add ignoreUndefined flag for rename() #616
Conversation
|
||
expect(err).to.not.exist(); | ||
expect(Object.keys(value)).to.include('a'); | ||
expect(value.a).to.equal('something'); |
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.
isn't it easier to do expect(value).to.deep.equal({ a: 'something' })
?
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.
That's right, I just copied/paste https://github.com/JbIPS/joi/blob/master/test/object.js#L652.
If you think deep.equal() is better, I'll change it
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.
it will make sure that if you tamper with the test and add an extra key or something the test itself will still want to same result. in your case the results needs to have key a but it can aswell have key b. I don't think it is a major thing but it also improves readability imo
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.
Ok, the new test is here :)
👍 |
@@ -84,6 +84,10 @@ internals.Object.prototype._base = function (value, state, options) { | |||
for (var r = 0, rl = this._inner.renames.length; r < rl; ++r) { | |||
var item = this._inner.renames[r]; | |||
|
|||
if (item.options.ignoreUndefined && target[item.from] === undefined){ |
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.
Space before brace.
To avoid future regressions can you also add tests combining this flag with override true ? And also add that flag to the docs. Thanks ! |
Added a cross test with |
nice work! |
Add ignoreUndefined flag for rename()
Thanks ! |
Thanks! Just one little question, when do you think this will be released? Just to know when I could go back to "joi": "6.1.0" on my package :) |
Finishing the work on IP validation then . |
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. |
Add a flag to ignore a missing key when renaming it.
close #614