Function iptools::ipv4::validate_cidr

source ·
pub fn validate_cidr(cidr: &str) -> bool
Expand description

Validate a CIDR notation

The string is considered a valid CIDR address if it consists of a valid IPv4 address in dotted-quad format followed by a forward slash (/) and a bit mask length (1-32).

Example

use iptools::ipv4::validate_cidr;
assert_eq!(validate_cidr("127.0.0.1/32"), true);
assert_eq!(validate_cidr("127.0.0.1"), false);