use url::Url;
use validator::ValidationError;

/// Validate that a URL has an HTTP(S) scheme and host.
pub fn validate_url(url: &Url) -> Result<(), ValidationError> {
    match (url.scheme(), url.host_str()) {
        ("http" | "https", Some(_)) => Ok(()),
        (_, Some(_)) => Err(ValidationError::new("invalid_scheme")),
        (_, None) => Err(ValidationError::new("missing_host")),
    }
}
