rskit-validation 0.1.0-alpha.1

Fluent field-level validator that collects errors and converts to AppError
Documentation
//! Stateless validation predicates.

/// Returns `true` if `value` looks like a valid e-mail address.
pub fn validate_email(value: &str) -> bool {
    let Some((local, domain)) = value.split_once('@') else {
        return false;
    };
    !local.is_empty() && domain.contains('.') && !domain.starts_with('.') && !domain.ends_with('.')
}

/// Returns `true` if `value` is an absolute HTTP or HTTPS URL.
pub fn validate_url(value: &str) -> bool {
    value.starts_with("http://") || value.starts_with("https://")
}

/// Returns `true` if `value` is a valid UUID (any version, hyphenated or not).
pub fn validate_uuid(value: &str) -> bool {
    value.parse::<uuid::Uuid>().is_ok()
}