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 SKIPPED_UNKNOWN_SEGMENT: &'static str = "STR008";
41
42 pub const VALUE_TOO_LONG: &'static str = "FMT001";
46
47 pub const INVALID_NUMERIC_FORMAT: &'static str = "FMT002";
49
50 pub const INVALID_ALPHANUMERIC_FORMAT: &'static str = "FMT003";
52
53 pub const INVALID_DATE_FORMAT: &'static str = "FMT004";
55
56 pub const VALUE_TOO_SHORT: &'static str = "FMT005";
58
59 pub const REQUIRED_ELEMENT_EMPTY: &'static str = "FMT006";
61
62 pub const INVALID_CODE_VALUE: &'static str = "COD001";
66
67 pub const CODE_NOT_ALLOWED_FOR_PID: &'static str = "COD002";
69
70 pub const ANSWER_NOT_IN_LIST: &'static str = "COD003";
72
73 pub const MISSING_REQUIRED_FIELD: &'static str = "AHB001";
77
78 pub const FIELD_NOT_ALLOWED_FOR_PID: &'static str = "AHB002";
80
81 pub const CONDITIONAL_RULE_VIOLATION: &'static str = "AHB003";
83
84 pub const UNKNOWN_PRUEFIDENTIFIKATOR: &'static str = "AHB004";
86
87 pub const CONDITION_UNKNOWN: &'static str = "AHB005";
89
90 pub const PACKAGE_CARDINALITY_VIOLATION: &'static str = "AHB006";
92
93 pub const REPEATED_IN_TRANSACTION: &'static str = "AHB007";
95
96 pub const INTERVAL_NOT_POSITIVE: &'static str = "CON001";
100
101 pub const REFERENCE_NOT_FOUND: &'static str = "CON002";
103
104 pub const BO4E_FIELD_DROPPED: &'static str = "MAP001";
108}
109
110#[cfg(test)]
111mod tests {
112 use super::*;
113
114 #[test]
115 fn test_error_code_prefixes() {
116 assert!(ErrorCodes::MISSING_MANDATORY_SEGMENT.starts_with("STR"));
117 assert!(ErrorCodes::VALUE_TOO_LONG.starts_with("FMT"));
118 assert!(ErrorCodes::INVALID_CODE_VALUE.starts_with("COD"));
119 assert!(ErrorCodes::MISSING_REQUIRED_FIELD.starts_with("AHB"));
120 }
121
122 #[test]
123 fn test_all_codes_are_unique() {
124 let codes = [
125 ErrorCodes::MISSING_MANDATORY_SEGMENT,
126 ErrorCodes::MAX_REPETITIONS_EXCEEDED,
127 ErrorCodes::UNEXPECTED_SEGMENT,
128 ErrorCodes::WRONG_SEGMENT_ORDER,
129 ErrorCodes::MISSING_MANDATORY_GROUP,
130 ErrorCodes::GROUP_MAX_REP_EXCEEDED,
131 ErrorCodes::UNT_SEGMENT_COUNT_MISMATCH,
132 ErrorCodes::SKIPPED_UNKNOWN_SEGMENT,
133 ErrorCodes::VALUE_TOO_LONG,
134 ErrorCodes::INVALID_NUMERIC_FORMAT,
135 ErrorCodes::INVALID_ALPHANUMERIC_FORMAT,
136 ErrorCodes::INVALID_DATE_FORMAT,
137 ErrorCodes::VALUE_TOO_SHORT,
138 ErrorCodes::REQUIRED_ELEMENT_EMPTY,
139 ErrorCodes::INVALID_CODE_VALUE,
140 ErrorCodes::CODE_NOT_ALLOWED_FOR_PID,
141 ErrorCodes::MISSING_REQUIRED_FIELD,
142 ErrorCodes::FIELD_NOT_ALLOWED_FOR_PID,
143 ErrorCodes::CONDITIONAL_RULE_VIOLATION,
144 ErrorCodes::UNKNOWN_PRUEFIDENTIFIKATOR,
145 ErrorCodes::CONDITION_UNKNOWN,
146 ErrorCodes::PACKAGE_CARDINALITY_VIOLATION,
147 ErrorCodes::REPEATED_IN_TRANSACTION,
148 ];
149
150 let unique: std::collections::HashSet<&str> = codes.iter().copied().collect();
151 assert_eq!(codes.len(), unique.len(), "Duplicate error codes found");
152 }
153}