ip-address-validator
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

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.

Package Sidebar

Install

npm i ip-address-validator

Weekly Downloads

949

Version

1.0.10

License

MIT

Unpacked Size

5.45 kB

Total Files

6

Last publish

Collaborators

  • vinaykumarbu