chore: re-map project structure to using multi workspace paradigm

This commit is contained in:
Maulana Sodiqin
2025-04-06 13:25:44 +07:00
parent de9c5a6dc1
commit b4bf78f0d6
87 changed files with 325 additions and 192 deletions
+28
View File
@@ -0,0 +1,28 @@
use axum::http::StatusCode;
use validator::Validate;
pub fn validate_request<T: Validate>(
payload: &T,
) -> Result<(), (StatusCode, String)> {
if let Err(validation_errors) = payload.validate() {
let error_messages: Vec<String> = validation_errors
.field_errors()
.iter()
.flat_map(|(_, errors)| {
errors.iter().map(move |error| {
format!(
"{}",
error
.message
.clone()
.unwrap_or_else(|| "Invalid value".into())
)
})
})
.collect();
return Err((StatusCode::BAD_REQUEST, error_messages.join(", ")));
}
Ok(())
}