The strict CIDR validation mode ensures that CIDR addresses have a matching prefix
for the specified bit length. If a CIDR string is technically valid but the prefix
does not align with the given bit length, it will be corrected and returned as a string.
For example, 192.168.0.1/24 is considered inaccurate because the prefix should be
192.168.0.0 for a /24 subnet. In strict mode, this input is not rejected—instead,
it is interpreted as valid and automatically corrected.
When strict mode is off, IPUtil.isIP('192.168.0.1/24', true) returns true.
When strict mode is on, the method returns the corrected CIDR string:
The strict CIDR validation mode ensures that CIDR addresses have a matching prefix for the specified bit length. If a CIDR string is technically valid but the prefix does not align with the given bit length, it will be corrected and returned as a string.
For example,
192.168.0.1/24
is considered inaccurate because the prefix should be192.168.0.0
for a /24 subnet. In strict mode, this input is not rejected—instead, it is interpreted as valid and automatically corrected.When strict mode is off,
IPUtil.isIP('192.168.0.1/24', true)
returnstrue
. When strict mode is on, the method returns the corrected CIDR string: