proper-ip.js
Validate IPv4 and IPv6 addresses
⚙️ Installation
npm i proper-ip
CDN Links:
- https://cdn.jsdelivr.net/npm/proper-ip@1.0.0/proper-ip.js
- https://www.unpkg.com/proper-ip@1.0.0/proper-ip.js
📖 Usage
▪ Import
// ES6
import properIp from "proper-ip";
// commonjs
const properIp = require("proper-ip");
▪ Check IPv4
properIp("192.168.0.1"); // True
properIp("10.0.0"); // False
▪ Check IPv6
properIp("2001:0db8:85a3:0000:0000:8a2e:0370:7334", "v6"); // True
properIp("hello world", "v6"); // False
Make sure to console.log()
the values to see the output!