Function domain

Source
pub fn domain(d: &str) -> bool
Expand description

Checks whether the given string is a valid domain.

The only difference from the RFC specification is that the string must have a TLD (eg.: com) and a domain (eg.: example). So the root domain (.) and the TLD only domains are reported as invalid.

ยงExample

if dator::domain("example.com") {
    // example.com is a valid domain
}
if !dator::domain(".com") {
    // .com is an invalid domain
}