Lines
100 %
Functions
75 %
Branches
use sqlx::types::Uuid;
use crate::response::WebError;
/// Parse and validate UUID with custom error message
pub fn parse_uuid(uuid_str: &str, field_name: &str) -> Result<Uuid, WebError> {
Uuid::parse_str(uuid_str)
.map_err(|_| WebError::bad_request(format!("Invalid {field_name}: {uuid_str}")))
}
#[cfg(test)]
#[path = "parse_tests.rs"]
mod tests;