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

    Function isValidCIDR

    • Validates whether the given input is a valid IPv4 CIDR.

      Parameters

      • cidr: Ipv4CidrLiteral

        The IPv4 CIDR to validate, which can be in string, object, or tuple format.

      Returns boolean

      True if the input is a valid IPv4 CIDR; otherwise, false.

      import { ipv4 } from 'cidr-block';

      ipv4.isValidCIDR("192.168.0.0/24"); // true
      ipv4.isValidCIDR("192.168.0.0/33"); // false (range out of bounds)
      ipv4.isValidCIDR({ address: "10.0.0.0", range: 8 }); // true
      ipv4.isValidCIDR([[172, 16, 0, 0], 12]); // true
      ipv4.isValidCIDR("invalid/24"); // false