pub fn hostname(host: &str) -> Result<()>Expand description
Validate a hostname.
§Validation Rules
- Hostname must not be empty
- Hostname must not exceed MAX_HOSTNAME_LENGTH (253 characters per RFC 1035)
- Each label (between dots) must be 1-63 characters
- Labels can only contain letters, digits, and hyphens
- Labels cannot start or end with a hyphen
- IP addresses (v4 and v6) are allowed
§Examples
use geode_client::validate;
assert!(validate::hostname("localhost").is_ok());
assert!(validate::hostname("geode.example.com").is_ok());
assert!(validate::hostname("192.168.1.1").is_ok());
assert!(validate::hostname("::1").is_ok());
assert!(validate::hostname("").is_err());