automapper_validation/validator/
level.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub enum ValidationLevel {
10 #[serde(alias = "structure")]
13 Structure,
14
15 #[serde(alias = "conditions")]
18 Conditions,
19
20 #[default]
23 #[serde(alias = "full")]
24 Full,
25}
26
27impl std::fmt::Display for ValidationLevel {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 ValidationLevel::Structure => write!(f, "Structure"),
31 ValidationLevel::Conditions => write!(f, "Conditions"),
32 ValidationLevel::Full => write!(f, "Full"),
33 }
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn test_default_is_full() {
43 assert_eq!(ValidationLevel::default(), ValidationLevel::Full);
44 }
45
46 #[test]
47 fn test_display() {
48 assert_eq!(format!("{}", ValidationLevel::Structure), "Structure");
49 assert_eq!(format!("{}", ValidationLevel::Conditions), "Conditions");
50 assert_eq!(format!("{}", ValidationLevel::Full), "Full");
51 }
52
53 #[test]
54 fn test_serialization_roundtrip() {
55 let level = ValidationLevel::Conditions;
56 let json = serde_json::to_string(&level).unwrap();
57 let deserialized: ValidationLevel = serde_json::from_str(&json).unwrap();
58 assert_eq!(level, deserialized);
59 }
60}