pub fn is_valid_cidr(value: &str) -> boolExpand description
Returns true when value is a CIDR range in canonical form: address/prefix where the
address parses strictly (RFC dotted-quad IPv4 / RFC 4291 IPv6, no leading-zero octets, hex
octets, partial addresses, or zone IDs), the prefix is a plain decimal integer in range, and
no host bits are set (e.g. 10.0.0.0/8 is valid, 10.0.0.1/8 is not).
This is deliberately stricter than the server, which currently stores conditions verbatim, and
stricter than .NET 10’s IPNetwork.TryParse, which silently truncates host bits and interprets
leading-zero octets as octal. Rejecting ambiguous input here avoids a client/server
disagreement about which network a rule matches.
IPv4-mapped IPv6 addresses (e.g. ::ffff:10.0.0.0/104) are also rejected as ambiguous:
client and server may disagree about whether such a range overlaps the equivalent native IPv4
CIDR. Use the native IPv4 form (e.g. 10.0.0.0/8) instead.