Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Conversation

mgm09a
Copy link
Contributor

@mgm09a mgm09a commented Nov 9, 2018

Fix for issue #177.

@@ -179,7 +179,7 @@
}

// invalidate field before doing any validation
if((value === "" || value === null || typeof value === "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) {
if((value !== "" || value !== null || typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) {
ctrl.$setValidity('validation', false);
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure why you are inversing the check from === to !==, that's a very big 360 from actual code. Also, not sure why I can see 2 commits attached to this PR but at the same time it shows only 1 file changed... very strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two commits with this because of line 182. We had discussed that !!value is probably not the correct check here, because it handles a value of 0 as a falsy value.

My first commit, I changed !!value and replaced it with the different method for checking if a value exists...

(value === "" || value === null || typeof value === "undefined")

...but then I realized it needed to be negated in this case. !!value essentially means if value exists, enter the body of this if block. So that we handle 0 correctly, we need to check that value exists by making sure it is not "", null or undefined.

The second commit fixes my mistake and negates the condition on line 182 so it keeps the same meaning as the original !!value.

Is that correct here?

Copy link
Contributor Author

@mgm09a mgm09a Nov 12, 2018

Choose a reason for hiding this comment

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

Okay, I have to apologize.

Yes, the !!value should be replaced by the more verbose check that value is not "", null, or undefined, but the condition should use &&s instead of ||s to properly negate the expression as a whole (otherwise it will always be true).

I understand there are multiple mistakes in this pull request. If you'd like to close this one, I can submit a "cleaner" one that should be correct from the start. My apologies, I think I got too excited to contribute to the repository and was being too hasty with my changes!

Copy link
Owner

Choose a reason for hiding this comment

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

haha don't be too rude on yourself, it's all good. 😉
I was just wondering why the inversion (=== to !==) as I thought it was an inversion of my code, and that would be a no no. But now I understand it was all your code from the start and yes it makes sense to do the !== with the &&

The first PR is always stressful, but don't worry, it's all cool. I will probably merge tonight or tomorrow. 🙊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect! Thanks for the help and support!

Fix to properly negate expression.
@ghiscoding ghiscoding merged commit ce22370 into ghiscoding:master Nov 14, 2018
ghiscoding added a commit that referenced this pull request Nov 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants