ip-address icon indicating copy to clipboard operation
ip-address copied to clipboard

Difference between isCorrent and isValid

Open fixje opened this issue 7 years ago • 5 comments

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

fixje avatar Feb 23 '18 10:02 fixje

agreed, “correctness” as a concept was really only given much thought for v6 but it can also be applied to v4, I’ll give that some thought


Sent from my phone.

On Feb 23, 2018, at 02:24, Markus Fuchs [email protected] wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

beaugunderson avatar Feb 23 '18 15:02 beaugunderson

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

atalis avatar Mar 08 '18 19:03 atalis

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 avatar Mar 08 '18 20:03 beaugunderson

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

beaugunderson avatar Mar 08 '18 20:03 beaugunderson

Thanks! Makes perfect sense!

atalis avatar Mar 08 '18 20:03 atalis