I used IPAddressUtil.isIPv6LiteralAddress (ipAddress) method to validate IPv6, but this method fails for ipv6-address/prefix-length format (format is mentioned in RFC 4291 section 2.3) of IPV6.
Could anyone know any validators which validate " ipv6-address/prefix-length " format?
Legal representations of IPV6
Typically strings, that do *not* trepresent a valid IPv6 address have characters other than the hex-digits in it, or they consists of less than 8 blocks of hexdigits, or they have at least one block of hexdigits in it with more than 4 hex-digits, or they have more than one position in it, where 2 colons directly follow ...
The following are examples of valid IPv6 (normal) addresses: 2001:db8:3333:4444:5555:6666:7777:8888. 2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF. :: (implies all 8 segments are zero)
The addresses 255.1. 4.2 and fe80:2030:31:24 are not valid IPv6 addresses.
Type “ipconfig/all” on the blinking cursor then press [Enter]. NOTE: You will find the IPv6 Address network details under the Ethernet adapter Local Area Connection section.
You can use the Guava library, specifically using the com.google.common.net.InetAddresses class, calling isInetAddress().
isInetAddress
public static boolean isInetAddress(String ipString)
Returns true if the supplied string is a valid IP string literal, false otherwise.
Parameters: ipString - String to evaluated as an IP string literal
Returns: true if the argument is a valid IP string literal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With