validate() function

Asserts that a string is a valid address of either family.

Signature:

export declare function validate(ip: string): void;

Parameters

Parameter

Type

Description

ip

string

the string to check

Returns:

void

Nothing. It either passes or throws.

Exceptions

TypeError 'Given network address "<ip>" is invalid!'

Remarks

The throwing counterpart of isValid(), used internally before conversion. Prefer isValid() when a bad address is an expected input rather than a programming error.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.