Closed d2jvkpn closed 6 months ago
**Reproducing:
/* Cargo.toml::dependencies serde = { version = "1", features = ["derive"] } serde_json = "1" validator = { version = "0.17", features = ["derive"] } */ use serde::{Deserialize, Serialize}; use validator::Validate; #[derive(Serialize, Deserialize, Validate, Debug, Clone)] #[serde(rename_all = "snake_case")] pub struct Account { #[serde(skip_serializing_if = "Option::is_none")] #[validate(email)] email: Option<String>, } #[cfg(test)] mod tests { use super::*; #[test] fn t_validation() { let json_string = r#"{"email": "hello"}"#; assert!(serde_json::from_str::<Account>(json_string).is_err()); } }
You need to call the .validate() method as shown in the first code snippet of the README. We don't hook in serde
.validate()
Thank you!
**Reproducing: