isIPv6

import { isIPv6 } from "jsr:@ende/net/unstable-ip";

function ยท experimental

function isIPv6(addr: string): boolean

Validates whether a given string is a IPv6 address.

See parseIPv6 for the accepted syntax.

addr: string

IPv6 address in a string format (e.g., "2001:db8::1").

Returns

A boolean indicating if the string is a valid IPv6 address.

Example: Check if the address is a IPv6

import { isIPv6 } from "@ende/net/unstable-ip"
import { assert, assertFalse } from "@ende/assert"

const correctIp = "2001::db8:0:1"
const incorrectIp = "2001::db8::1"

assert(isIPv6(correctIp))
assertFalse(isIPv6(incorrectIp))

Source