Validates whether the given input is a valid IPv4 address.
The IPv4 address to validate, which can be in string, number, or octet array format.
True if the input is a valid IPv4 address; otherwise, false.
import { ipv4 } from 'cidr-block';ipv4.isValidAddress("192.168.1.1"); // trueipv4.isValidAddress("256.0.0.1"); // false (octet out of range)ipv4.isValidAddress(3232235777); // trueipv4.isValidAddress([192, 168, 1, 1]); // trueipv4.isValidAddress("invalid"); // false Copy
import { ipv4 } from 'cidr-block';ipv4.isValidAddress("192.168.1.1"); // trueipv4.isValidAddress("256.0.0.1"); // false (octet out of range)ipv4.isValidAddress(3232235777); // trueipv4.isValidAddress([192, 168, 1, 1]); // trueipv4.isValidAddress("invalid"); // false
Validates whether the given input is a valid IPv4 address.