-
Notifications
You must be signed in to change notification settings - Fork 0
isNetworkValid()
Evgheniy Kovaliov edited this page Dec 22, 2023
·
1 revision
Method that allows you to check the correctness of the ip network.
Correct ip network address must be a string in X.X.X.X/PREF format, where X.X.X.X is a correct ip address, and PREF is a correct ip prefix.
Also 'host part' (that determined by ip prefix) of address must be filled by zeros.
Parameters:
-
network— value, that will be checked.
Return:
-
true/false
ipv4.isNetworkValid('0.0.0.0/0') // true
ipv4.isNetworkValid('255.255.255.255/32') // true
ipv4.isNetworkValid('0.0.0.0/32') // true
ipv4.isNetworkValid('123.122.120.0/22') // true
ipv4.isNetworkValid('10.0.0.0/31') // true
ipv4.isNetworkValid('10.0.0.1/31') // false
ipv4.isNetworkValid('123.122.120.0/20') // false
ipv4.isNetworkValid('125.12.28.64/24') // false
ipv4.isNetworkValid('123.123.10.1') // false
ipv4.isNetworkValid(['0.0.0.0', '/0']) // false- Is used in other methods.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6