Check if a string is an IP subnet in CIDR notation. Specifically, validating that the network address matches the given mask.
npm i is-subnet
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;
Check if input
is an IP CIDR subnet. Returns either true or false.
- is-cidr - Check if a string is an IP address in CIDR notation
- is-ip - Check if a string is an IP address
© stevehaskew, distributed under BSD licence
Based on previous work by Felipe Apostol and silverwind