Skip to main content

is_valid_url

Function is_valid_url 

Source
pub fn is_valid_url(value: &str) -> bool
Expand description

Check if a string is a valid URL.

Validates that the string starts with http:// or https:// and has a valid domain structure.

ยงExamples

use fastapi_core::validation::is_valid_url;

assert!(is_valid_url("https://example.com"));
assert!(is_valid_url("http://sub.domain.org/path?query=value"));
assert!(!is_valid_url("not-a-url"));
assert!(!is_valid_url("ftp://example.com")); // Only http/https