-
Notifications
You must be signed in to change notification settings - Fork 0
isMaskValid()
Evgheniy Kovaliov edited this page Dec 22, 2023
·
1 revision
Method that allows you to check the correctness of the ip subnet mask.
Correct ip subnet mask must be a string in format: X.X.X.X, where X is a number from 0 to 255.
And in binary form of ip subnet mask zeros can only be after all ones. For example: 11111111.11111111.11100000.00000000.
Parameters:
-
mask— value, that will be checked.
Return:
-
true/false
ipv4.isMaskValid('0.0.0.0'); // true
ipv4.isMaskValid('255.255.255.255'); // true
ipv4.isMaskValid('255.255.0.0'); // true
ipv4.isMaskValid('128.0.0.0'); // true
ipv4.isMaskValid('255.240.0.0'); // true
ipv4.isMaskValid('255.255.255.254'); // true
ipv4.isMaskValid('255.255.255.252'); // true
ipv4.isMaskValid('255.255.255.253'); // false
ipv4.isMaskValid('111.1.0.0'); // false
ipv4.isMaskValid('128.0.0.1'); // false
ipv4.isMaskValid('128.128.128.128'); // false
ipv4.isMaskValid('string...'); // false- Is used in other methods.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6