cidr-block - v2.1.1
    Preparing search index...

    Function isValidAddress

    • Validates whether the given input is a valid IPv6 address.

      Parameters

      • ip: Ipv6AddressLiteral

        The IPv6 address to validate, which can be in string, bigint, or hextets array format.

      Returns boolean

      True if the input is a valid IPv6 address; otherwise, false.

      import { ipv6 } from 'cidr-block';

      ipv6.isValidAddress("2001:db8::1"); // true
      ipv6.isValidAddress("::"); // true
      ipv6.isValidAddress("::1"); // true
      ipv6.isValidAddress("gggg::1"); // false (invalid hex)
      ipv6.isValidAddress("2001:db8"); // false (incomplete)
      ipv6.isValidAddress([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]); // true