MCPcopy Create free account
hub / github.com/biblius/validify / validate_domain_part

Function validate_domain_part

validify/src/validation/email.rs:59–72  ·  view source on GitHub ↗
(domain_part: &str)

Source from the content-addressed store, hash-verified

57/// Checks if the domain is a valid domain and if not, check whether it's an IP
58#[must_use]
59fn validate_domain_part(domain_part: &str) -> bool {
60 if EMAIL_DOMAIN_RE.is_match(domain_part) {
61 return true;
62 }
63
64 // maybe we have an ip as a domain?
65 match EMAIL_LITERAL_RE.captures(domain_part) {
66 Some(caps) => match caps.get(1) {
67 Some(c) => validate_ip(c.as_str()),
68 None => false,
69 },
70 None => false,
71 }
72}
73
74#[cfg(test)]
75mod tests {

Callers 1

validate_emailFunction · 0.85

Calls 1

validate_ipFunction · 0.85

Tested by

no test coverage detected