is-subnet
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

is-subnet

Check if a string is an IP subnet in CIDR notation. Specifically, validating that the network address matches the given mask.

Install

npm i is-subnet

Usage

const isSubnet = require("is-subnet");

isSubnet("192.168.0.0/24"); //=> true
isSubnet("192.168.0.1/24"); //=> false
isSubnet("192.168.0.0"); //=> false
isSubnet("2001:db8::/64"); //=> true;
isSubnet("2001:db8::1/64"); //=> false;
isSubnet("2001:db8::"); //=> false;

API

isSubnet(input)

Check if input is an IP CIDR subnet. Returns either true or false.

Related

  • is-cidr - Check if a string is an IP address in CIDR notation
  • is-ip - Check if a string is an IP address

License

© stevehaskew, distributed under BSD licence

Based on previous work by Felipe Apostol and silverwind

Package Sidebar

Install

npm i is-subnet

Weekly Downloads

37

Version

1.0.0

License

BSD-2-Clause

Unpacked Size

5.08 kB

Total Files

5

Last publish

Collaborators

  • stevehaskew