vidsage-core 0.1.0

Core functionality for VidSage video processing and AI commentary generation
Documentation
//! Validation functions

use std::path::Path;

/// Validate a video format
pub fn validate_video_format(format: &str) -> bool {
    matches!(
        format.to_lowercase().as_str(),
        "mp4" | "webm" | "avi" | "mov" | "mkv" | "flv" | "wmv" | "m4v"
    )
}

/// Validate a commentary style
pub fn validate_commentary_style(style: &str) -> bool {
    matches!(
        style.to_lowercase().as_str(),
        "professional"
            | "casual"
            | "educational"
            | "entertaining"
            | "analytical"
            | "storytelling"
            | "poetic"
            | "technical"
    )
}

/// Validate a language code (ISO 639-1)
pub fn validate_language_code(code: &str) -> bool {
    code.len() == 2 && code.chars().all(|c| c.is_ascii_lowercase())
}

/// Validate a resolution tuple (width, height)
pub fn validate_resolution(resolution: (u32, u32)) -> bool {
    let (width, height) = resolution;
    width > 0 && height > 0 && width <= 8192 && height <= 8192
}

/// Validate a frame rate
pub fn validate_frame_rate(frame_rate: f64) -> bool {
    frame_rate > 0.0 && frame_rate <= 120.0
}

/// Validate a compression level (0-9)
pub fn validate_compression_level(level: u8) -> bool {
    level <= 9
}

/// Validate a file path
pub fn validate_file_path(path: &Path) -> bool {
    path.is_absolute() || path.starts_with("./") || path.starts_with("../")
}

/// Validate a video processing quality
pub fn validate_video_quality(quality: &str) -> bool {
    matches!(
        quality.to_lowercase().as_str(),
        "low" | "medium" | "high" | "ultra"
    )
}

/// Validate a positive integer
pub fn validate_positive_integer(value: i64) -> bool {
    value > 0
}

/// Validate a positive float
pub fn validate_positive_float(value: f64) -> bool {
    value > 0.0
}

/// Validate a percentage (0-100)
pub fn validate_percentage(value: u8) -> bool {
    value <= 100
}