JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1153
  • Score
    100M100P100Q106792F
  • License MIT

This package validates IP address and its version

Package Exports

  • ip-address-validator
  • ip-address-validator/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ip-address-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ip-address-validator

Validate the IP address and check its version

Install

npm install ip-address-validator

Usage

import {isIPAddress, isIPV6Address, isIPV4Address, ipVersion} from 'ip-address-validator';

isIPAddress('192.168.0.108');
//=> true

isIPAddress('a.b.c.d');
//=> false

isIPV4Address('10.10.8.4');
//=> true

isIPV6Address('1:2:3:4:5:6:7:8');
//=> true

isIPV6Address('::0');
//=> true

ipVersion('1:2:3:4:5:6:7:8');
//=> 6

ipVersion('10.10.8.4');
//=> 4

ipVersion('a.b.c.d');
//=> "Please enter valid IP address"

API

isIPAddress(string)

Check if the string is valid IP address.

isIPV6Address(string)

Check if the string is valid IPv6 address.

isIPV4Address(string)

Check if the string is valid IPv4 address.

ipVersion(string)

Returns 6 if the string is IPv6, Returns 4 if the string is IPv4, Returns undefined if the string is neither IPV4 nor IPV6.