automapper_validation/validator/
codes.rs1pub struct ErrorCodes;
11
12impl ErrorCodes {
13 pub const MISSING_MANDATORY_SEGMENT: &'static str = "STR001";
17
18 pub const MAX_REPETITIONS_EXCEEDED: &'static str = "STR002";
20
21 pub const UNEXPECTED_SEGMENT: &'static str = "STR003";
23
24 pub const WRONG_SEGMENT_ORDER: &'static str = "STR004";
26
27 pub const MISSING_MANDATORY_GROUP: &'static str = "STR005";
29
30 pub const GROUP_MAX_REP_EXCEEDED: &'static str = "STR006";
32
33 pub const UNT_SEGMENT_COUNT_MISMATCH: &'static str = "STR007";
35
36 pub const VALUE_TOO_LONG: &'static str = "FMT001";
40
41 pub const INVALID_NUMERIC_FORMAT: &'static str = "FMT002";
43
44 pub const INVALID_ALPHANUMERIC_FORMAT: &'static str = "FMT003";
46
47 pub const INVALID_DATE_FORMAT: &'static str = "FMT004";
49
50 pub const VALUE_TOO_SHORT: &'static str = "FMT005";
52
53 pub const REQUIRED_ELEMENT_EMPTY: &'static str = "FMT006";
55
56 pub const INVALID_CODE_VALUE: &'static str = "COD001";
60
61 pub const CODE_NOT_ALLOWED_FOR_PID: &'static str = "COD002";
63
64 pub const MISSING_REQUIRED_FIELD: &'static str = "AHB001";
68
69 pub const FIELD_NOT_ALLOWED_FOR_PID: &'static str = "AHB002";
71
72 pub const CONDITIONAL_RULE_VIOLATION: &'static str = "AHB003";
74
75 pub const UNKNOWN_PRUEFIDENTIFIKATOR: &'static str = "AHB004";
77
78 pub const CONDITION_UNKNOWN: &'static str = "AHB005";
80
81 pub const PACKAGE_CARDINALITY_VIOLATION: &'static str = "AHB006";
83}
84
85#[cfg(test)]
86mod tests {
87 use super::*;
88
89 #[test]
90 fn test_error_code_prefixes() {
91 assert!(ErrorCodes::MISSING_MANDATORY_SEGMENT.starts_with("STR"));
92 assert!(ErrorCodes::VALUE_TOO_LONG.starts_with("FMT"));
93 assert!(ErrorCodes::INVALID_CODE_VALUE.starts_with("COD"));
94 assert!(ErrorCodes::MISSING_REQUIRED_FIELD.starts_with("AHB"));
95 }
96
97 #[test]
98 fn test_all_codes_are_unique() {
99 let codes = [
100 ErrorCodes::MISSING_MANDATORY_SEGMENT,
101 ErrorCodes::MAX_REPETITIONS_EXCEEDED,
102 ErrorCodes::UNEXPECTED_SEGMENT,
103 ErrorCodes::WRONG_SEGMENT_ORDER,
104 ErrorCodes::MISSING_MANDATORY_GROUP,
105 ErrorCodes::GROUP_MAX_REP_EXCEEDED,
106 ErrorCodes::UNT_SEGMENT_COUNT_MISMATCH,
107 ErrorCodes::VALUE_TOO_LONG,
108 ErrorCodes::INVALID_NUMERIC_FORMAT,
109 ErrorCodes::INVALID_ALPHANUMERIC_FORMAT,
110 ErrorCodes::INVALID_DATE_FORMAT,
111 ErrorCodes::VALUE_TOO_SHORT,
112 ErrorCodes::REQUIRED_ELEMENT_EMPTY,
113 ErrorCodes::INVALID_CODE_VALUE,
114 ErrorCodes::CODE_NOT_ALLOWED_FOR_PID,
115 ErrorCodes::MISSING_REQUIRED_FIELD,
116 ErrorCodes::FIELD_NOT_ALLOWED_FOR_PID,
117 ErrorCodes::CONDITIONAL_RULE_VIOLATION,
118 ErrorCodes::UNKNOWN_PRUEFIDENTIFIKATOR,
119 ErrorCodes::CONDITION_UNKNOWN,
120 ErrorCodes::PACKAGE_CARDINALITY_VIOLATION,
121 ];
122
123 let unique: std::collections::HashSet<&str> = codes.iter().copied().collect();
124 assert_eq!(codes.len(), unique.len(), "Duplicate error codes found");
125 }
126}