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

Difference between isCorrent and isValid #68

Open
fixje opened this issue Feb 23, 2018 · 5 comments
Open

Difference between isCorrent and isValid #68

fixje opened this issue Feb 23, 2018 · 5 comments

Comments

@fixje
Copy link

fixje commented Feb 23, 2018

The semantics of isCorrect and isValid in Address4 and Address6 are not obvious and should be part of the documentation.

@beaugunderson
Copy link
Owner

beaugunderson commented Feb 23, 2018 via email

@atalis
Copy link

atalis commented Mar 8, 2018

So, what is the difference between the two methods? I'm trying to figure out which one to use.

@beaugunderson
Copy link
Owner

beaugunderson commented Mar 8, 2018

isValid() returns true if the address is valid, meaning it parses successfully/does not contain errors

isCorrect() should probably be renamed to avoid confusion; isPreferredForm() probably better captures the meaning...

an address like ffff:000f:: is valid but not "correct" or the "preferred form" because it contains leading zeroes, in this example (the "preferred form" would be ffff:f::)

more information on IPv6 preferred form here: https://tools.ietf.org/html/rfc5952#page-10

similarly for IPv4 an address like 192.168.000.001 is valid but not correct/preferred (192.168.0.1 would be the correct/preferred form)

make more sense?

@beaugunderson
Copy link
Owner

in the code I believe I just compare the input string to the result of correctForm() and return false if they don't match

@atalis
Copy link

atalis commented Mar 8, 2018

Thanks! Makes perfect sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants