
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
ip-address-validation
Advanced tools
Validate IPv4 and IPv6 addresses with a fast JavaScript module.
This is a fast module for validating IPv4 and IPv6 addresses.
It's written in JavaScript with extreme efficiency and simplicity.
A complete line-by-line code algorithm explanation is coming soon.
Buy Me a Coffee | Cash App | Patreon | PayPal
git clone https://github.com/liamloads/javascript-ip-address-validation-module.git
<script src="ip-address-validation.js" type="text/javascript"></script>
<script type="text/javascript">console.log(ipAddressValidation('127.0.0.1'));</script>
cd
npm install ip-address-validation
const ipAddressValidation = require('ip-address-validation');
console.log(ipAddressValidation('127.0.0.1'));
The module function accepts one IPv4 or IPv6 address argument.
IPv4 addresses are accepted with dotted x.x.x.x
formatting without base conversion or subnet masking.
IPv6 addresses are accepted with long x:x:x:x:x:x:x:x
, short x::x
or translated x:x:x:x:x:x:x.x.x.x
formatting.
The return value is a number
with an IP address version of either 4
or 6
.
If the argument isn't a valid IPv4 or IPv6 address, the return value is false
.
console.log(ipAddressValidation('127.0.0.1'));
// 4
console.log(ipAddressValidation(' 127.0.0.1'));
// false
console.log(ipAddressValidation('127.0.0.1/32'));
// false
console.log(ipAddressValidation('127.0.0.1000'));
// false
console.log(ipAddressValidation('::1'));
// 6
console.log(ipAddressValidation(':::1'));
// false
console.log(ipAddressValidation('0000:0000:0000:0000:0000:0000:0000:0001'));
// 6
console.log(ipAddressValidation('0000:0000:0000:0001::127.0.0.1'));
// 6
console.log(ipAddressValidation('0000:0000:0000:0000:0001::127.0.0.1000'));
// false
console.log(ipAddressValidation('AB:ab::cd:CD'));
// 6
FAQs
Validate IPv4 and IPv6 addresses with a fast JavaScript module.
The npm package ip-address-validation receives a total of 0 weekly downloads. As such, ip-address-validation popularity was classified as not popular.
We found that ip-address-validation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.