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: Fix the problem of null judgment error #21

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

huangjunjia
Copy link

@huangjunjia huangjunjia commented Oct 17, 2023

Description

In the current null and nnull judgments, undefined will be erroneously judged to be true.

Adjusted the judgment logic, the judgment rules of null and nnull return true or false according to whether the value is nil.

And complements the logic of recursive judgment.

@self-transition
Copy link
Member

CI failed

@huangjunjia
Copy link
Author

@self-transition fixed

@self-transition
Copy link
Member

self-transition commented Oct 18, 2023

IsNil adds an extra check for undefined, so do you need to add a unit test for it?

I'm also wondering if the previous _.get call returns undefined if a non-existent key is passed in. and if that's what's expected in this case.

@huangjunjia
Copy link
Author

huangjunjia commented Oct 18, 2023

IsNil adds an extra check for undefined, so do you need to add a unit test for it?

I'm also wondering if the previous _.get call returns undefined if a non-existent key is passed in. and if that's what's expected in this case.

@self-transition Thank you very much.

I have adjusted the judgment logic based on your response.

Checks if path is a direct property of object before judge conditions, and added the relevant unit tests.

PTAL

@self-transition self-transition added the enhancement New feature or request label Oct 19, 2023
return fieldValue === null;
case 'nnull':
return fieldValue !== null;
case 'null': {
Copy link
Member

@self-transition self-transition Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to put this judgment at the beginning of the function, so that when path is not a direct property of object, it doesn't do anything and returns the original value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right! I think it should return false when path isn't direct property of object, because it mean that data is not valid.

Copy link
Member

@self-transition self-transition left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@self-transition self-transition merged commit 1f35749 into main Oct 19, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants