-
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
Error when .rename() from undefined #614
Comments
To me that looks like unexpected behaviour. The |
Removing |
But why does it want rename |
That's what I'm thinking. I use rename() to ensure all my objects have those keys in camel-case, but some already have, and it's a mess if the good ones are removed instead of just doing nothing. |
This changed since #593. We'd likely need a new flag to support your use case. |
Do you have any ideas for the name of the flag? Like |
More something like |
Wouldn't this be expected behaviour? That when using |
It's been like that for ages, don't act all surprised :) |
I've never used that feature so it's just what I expect it to do from reading the docs and this issue so that's why I'm surprised :P |
Actually, I agree with @AdriVanHoudt. Moreover, it wouldn't need a flag: if the |
Seems logical to me, you ask to rename a into b, whatever's into a gets into b. |
Ah ok so if a is undefined b will be set as undefined? Ok now I get it. So a flag would make sense here to only rename if not undefined(or null?). |
So |
|
I thought of missing as in "missing key", keys are rarely explicitly undefined, but yours works as well. |
A missing key will return undefined so wouldn't that be the same? |
Exactly, missing or explicitly undefined is the same to me. |
👍 |
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. |
Hi,
here's what I'm trying to do :
I've got this Joi schema
and I'm validating this object
This give me
[ValidationError: child "clientId" fails because ["clientId" is required]]
. Changing clientId to client_id in my object works fine, but rename() shouldn't delete my keys if the rename isn't necessary, right? I think this behavior is comming from this commit but maybe it's on purpose and I missed something.Is that a bug or a feature ?
The text was updated successfully, but these errors were encountered: