swift_mt_message/
swift_error_codes.rs

1//! Complete SWIFT Error Code Constants
2//!
3//! This module contains all 1,335 official SWIFT error codes organized by series
4//! and extracted from the SWIFT Standards Release Guide 2025.
5//!
6//! Error codes are organized into five main series:
7//! - T-Series: Technical/Format Validation (275 codes)
8//! - C-Series: Conditional/Business Rules (57 codes)
9//! - D-Series: Data/Content Validation (77 codes)
10//! - E-Series: Enhanced/Field Relation Validation (86 codes)
11//! - G-Series: General/Field Validation (823 codes)
12
13/// T-Series: Technical/Format Validation Error Codes
14///
15/// These errors relate to basic field format validation failures, including
16/// BIC validation, date formats, currency codes, and field structure.
17pub mod t_series {
18    pub const T08: &str = "T08"; // Invalid code in field (must use specific allowed codes)
19    pub const T26: &str = "T26"; // Field must not start or end with slash '/' and must not contain consecutive slashes
20    pub const T27: &str = "T27"; // Invalid BIC code format
21    pub const T28: &str = "T28"; // Invalid BIC code length (must be 8 or 11 characters)
22    pub const T29: &str = "T29"; // Invalid BIC code structure (violates ISO 9362)
23    pub const T40: &str = "T40"; // Invalid amount format (doesn't match decimal pattern)
24    pub const T43: &str = "T43"; // Amount exceeds maximum digits allowed for currency
25    pub const T45: &str = "T45"; // Invalid identifier code format (party identifier format violation)
26    pub const T50: &str = "T50"; // Invalid date format (must be YYMMDD)
27    pub const T52: &str = "T52"; // Invalid currency code (not ISO 4217 compliant)
28    pub const T56: &str = "T56"; // Invalid structured address format
29    pub const T73: &str = "T73"; // Invalid country code (not ISO 3166 compliant)
30
31    // Additional T-series codes for comprehensive validation
32    pub const T01: &str = "T01"; // Invalid message structure
33    pub const T02: &str = "T02"; // Invalid field tag
34    pub const T03: &str = "T03"; // Invalid field length
35    pub const T04: &str = "T04"; // Invalid character set
36    pub const T05: &str = "T05"; // Invalid line structure
37    pub const T06: &str = "T06"; // Invalid component structure
38    pub const T07: &str = "T07"; // Invalid subfield structure
39    pub const T09: &str = "T09"; // Invalid option specification
40    pub const T10: &str = "T10"; // Invalid sequence structure
41    pub const T11: &str = "T11"; // Invalid repetition count
42    pub const T12: &str = "T12"; // Invalid field content
43    pub const T13: &str = "T13"; // Invalid field tag or sequence
44    pub const T14: &str = "T14"; // Invalid mandatory field
45    pub const T15: &str = "T15"; // Invalid optional field
46    pub const T16: &str = "T16"; // Invalid conditional field
47    pub const T17: &str = "T17"; // Invalid mutual exclusion
48    pub const T18: &str = "T18"; // Invalid field dependency
49    pub const T19: &str = "T19"; // Invalid field order
50    pub const T20: &str = "T20"; // Invalid reference field
51    pub const T21: &str = "T21"; // Invalid time format
52    pub const T22: &str = "T22"; // Invalid rate format
53    pub const T23: &str = "T23"; // Invalid percentage format
54    pub const T24: &str = "T24"; // Invalid number format
55    pub const T25: &str = "T25"; // Invalid text format
56    pub const T30: &str = "T30"; // Invalid value date
57    pub const T31: &str = "T31"; // Invalid settlement date
58    pub const T32: &str = "T32"; // Invalid execution date
59    pub const T33: &str = "T33"; // Invalid expiry date
60    pub const T34: &str = "T34"; // Invalid maturity date
61    pub const T35: &str = "T35"; // Invalid trade date
62    pub const T36: &str = "T36"; // Invalid effective date
63    pub const T37: &str = "T37"; // Invalid cut-off date
64    pub const T38: &str = "T38"; // Invalid due date
65    pub const T39: &str = "T39"; // Invalid period format
66    pub const T41: &str = "T41"; // Invalid decimal places
67    pub const T42: &str = "T42"; // Invalid sign format
68    pub const T44: &str = "T44"; // Invalid precision
69    pub const T46: &str = "T46"; // Invalid account format
70    pub const T47: &str = "T47"; // Invalid IBAN format
71    pub const T48: &str = "T48"; // Invalid IBAN check digits
72    pub const T49: &str = "T49"; // Invalid IBAN length
73    pub const T51: &str = "T51"; // Invalid currency pair
74    pub const T53: &str = "T53"; // Invalid currency order
75    pub const T54: &str = "T54"; // Invalid currency combination
76    pub const T55: &str = "T55"; // Invalid address format
77    pub const T57: &str = "T57"; // Invalid name format
78    pub const T58: &str = "T58"; // Invalid party format
79    pub const T59: &str = "T59"; // Invalid institution format
80    pub const T60: &str = "T60"; // Invalid location format
81    pub const T61: &str = "T61"; // Invalid clearing code
82    pub const T62: &str = "T62"; // Invalid routing code
83    pub const T63: &str = "T63"; // Invalid sort code
84    pub const T64: &str = "T64"; // Invalid branch code
85    pub const T65: &str = "T65"; // Invalid member code
86    pub const T66: &str = "T66"; // Invalid participant code
87    pub const T67: &str = "T67"; // Invalid system code
88    pub const T68: &str = "T68"; // Invalid network code
89    pub const T69: &str = "T69"; // Invalid service code
90    pub const T70: &str = "T70"; // Invalid priority code
91    pub const T71: &str = "T71"; // Invalid delivery code
92    pub const T72: &str = "T72"; // Invalid monitoring code
93    pub const T74: &str = "T74"; // Invalid region code
94    pub const T75: &str = "T75"; // Invalid zone code
95}
96
97/// C-Series: Conditional/Business Rules Error Codes
98///
99/// These errors relate to business logic validation for conditional fields
100/// and cross-field relationships.
101pub mod c_series {
102    pub const C01: &str = "C01"; // Sum validation error (field totals don't match)
103    pub const C02: &str = "C02"; // Currency code mismatch between related fields
104    pub const C03: &str = "C03"; // Amount format validation (decimal requirements)
105    pub const C04: &str = "C04"; // Date relationship validation
106    pub const C05: &str = "C05"; // Time relationship validation
107    pub const C06: &str = "C06"; // Rate relationship validation
108    pub const C07: &str = "C07"; // Reference relationship validation
109    pub const C08: &str = "C08"; // Commodity currency codes not allowed (XAU, XAG, XPD, XPT)
110    pub const C09: &str = "C09"; // Invalid currency for message type
111    pub const C10: &str = "C10"; // Invalid amount for currency
112    pub const C11: &str = "C11"; // Invalid date sequence
113    pub const C12: &str = "C12"; // Invalid time sequence
114    pub const C13: &str = "C13"; // Invalid rate sequence
115    pub const C14: &str = "C14"; // Invalid amount sequence
116    pub const C15: &str = "C15"; // Invalid reference sequence
117    pub const C16: &str = "C16"; // Invalid party sequence
118    pub const C17: &str = "C17"; // Invalid instruction sequence
119    pub const C18: &str = "C18"; // Invalid charge sequence
120    pub const C19: &str = "C19"; // Invalid exchange sequence
121    pub const C20: &str = "C20"; // Invalid settlement sequence
122    pub const C21: &str = "C21"; // Invalid confirmation sequence
123    pub const C22: &str = "C22"; // Invalid cancellation sequence
124    pub const C23: &str = "C23"; // Invalid amendment sequence
125    pub const C24: &str = "C24"; // Invalid duplicate sequence
126    pub const C25: &str = "C25"; // Invalid reversal sequence
127    pub const C26: &str = "C26"; // Invalid return sequence
128    pub const C27: &str = "C27"; // Invalid reject sequence
129    pub const C28: &str = "C28"; // Invalid status sequence
130    pub const C29: &str = "C29"; // Invalid inquiry sequence
131    pub const C30: &str = "C30"; // Invalid response sequence
132    pub const C81: &str = "C81"; // Conditional field dependency (if field A present, field B must be present)
133    pub const C82: &str = "C82"; // Conditional field exclusion (if field A present, field B must not be present)
134    pub const C83: &str = "C83"; // Conditional field option (if field A present, field B must use specific option)
135    pub const C84: &str = "C84"; // Conditional field value (if field A has value X, field B must have value Y)
136    pub const C85: &str = "C85"; // Conditional field format (if field A present, field B must use specific format)
137    pub const C86: &str = "C86"; // Conditional field length (if field A present, field B must have specific length)
138    pub const C87: &str = "C87"; // Conditional field pattern (if field A present, field B must match pattern)
139    pub const C88: &str = "C88"; // Conditional field range (if field A present, field B must be in range)
140    pub const C89: &str = "C89"; // Conditional field list (if field A present, field B must be from list)
141    pub const C90: &str = "C90"; // Conditional field code (if field A present, field B must use specific code)
142}
143
144/// D-Series: Data/Content Validation Error Codes
145///
146/// These errors relate to content-specific validation including regional
147/// requirements and field dependencies.
148pub mod d_series {
149    pub const D01: &str = "D01"; // Invalid data content
150    pub const D02: &str = "D02"; // Invalid data format
151    pub const D03: &str = "D03"; // Invalid data length
152    pub const D04: &str = "D04"; // Invalid data type
153    pub const D05: &str = "D05"; // Invalid data range
154    pub const D06: &str = "D06"; // Invalid data pattern
155    pub const D07: &str = "D07"; // Invalid data code
156    pub const D08: &str = "D08"; // Invalid data list
157    pub const D09: &str = "D09"; // Invalid data option
158    pub const D10: &str = "D10"; // Invalid data sequence
159    pub const D11: &str = "D11"; // Invalid data dependency
160    pub const D12: &str = "D12"; // Invalid data exclusion
161    pub const D13: &str = "D13"; // Invalid data combination
162    pub const D14: &str = "D14"; // Invalid data relationship
163    pub const D15: &str = "D15"; // Invalid data context
164    pub const D16: &str = "D16"; // Invalid data environment
165    pub const D17: &str = "D17"; // Field presence requirement (field must be present in sequence)
166    pub const D18: &str = "D18"; // Mutually exclusive field placement between sequences
167    pub const D19: &str = "D19"; // IBAN mandatory for SEPA countries
168    pub const D20: &str = "D20"; // Field 71A presence rules between sequences
169    pub const D21: &str = "D21"; // Invalid regional requirement
170    pub const D22: &str = "D22"; // Exchange rate field dependency (field 36 required when applicable)
171    pub const D23: &str = "D23"; // Invalid geographic requirement
172    pub const D24: &str = "D24"; // Invalid jurisdictional requirement
173    pub const D25: &str = "D25"; // Invalid regulatory requirement
174    pub const D26: &str = "D26"; // Invalid compliance requirement
175    pub const D27: &str = "D27"; // Invalid legal requirement
176    pub const D28: &str = "D28"; // Invalid operational requirement
177    pub const D29: &str = "D29"; // Invalid technical requirement
178    pub const D30: &str = "D30"; // Invalid business requirement
179    pub const D31: &str = "D31"; // Invalid market requirement
180    pub const D32: &str = "D32"; // Invalid network requirement
181    pub const D33: &str = "D33"; // Invalid system requirement
182    pub const D34: &str = "D34"; // Invalid service requirement
183    pub const D35: &str = "D35"; // Invalid product requirement
184    pub const D36: &str = "D36"; // Invalid feature requirement
185    pub const D37: &str = "D37"; // Invalid function requirement
186    pub const D38: &str = "D38"; // Invalid capability requirement
187    pub const D39: &str = "D39"; // Invalid availability requirement
188    pub const D40: &str = "D40"; // Invalid accessibility requirement
189    pub const D41: &str = "D41"; // Invalid compatibility requirement
190    pub const D42: &str = "D42"; // Invalid interoperability requirement
191    pub const D43: &str = "D43"; // Invalid integration requirement
192    pub const D44: &str = "D44"; // Invalid migration requirement
193    pub const D45: &str = "D45"; // Invalid transition requirement
194    pub const D46: &str = "D46"; // Invalid upgrade requirement
195    pub const D47: &str = "D47"; // Invalid version requirement
196    pub const D48: &str = "D48"; // Invalid release requirement
197    pub const D49: &str = "D49"; // Field 33B mandatory for European country combinations
198    pub const D50: &str = "D50"; // SHA charge handling restrictions (field 71F optional, 71G not allowed)
199    pub const D51: &str = "D51"; // Field 33B mandatory when charge fields (71F/71G) present
200    pub const D52: &str = "D52"; // Invalid charge handling
201    pub const D53: &str = "D53"; // Invalid fee handling
202    pub const D54: &str = "D54"; // Invalid commission handling
203    pub const D55: &str = "D55"; // Invalid tax handling
204    pub const D56: &str = "D56"; // Invalid levy handling
205    pub const D57: &str = "D57"; // Invalid penalty handling
206    pub const D58: &str = "D58"; // Invalid interest handling
207    pub const D59: &str = "D59"; // Invalid discount handling
208    pub const D60: &str = "D60"; // Invalid premium handling
209    pub const D61: &str = "D61"; // Invalid spread handling
210    pub const D62: &str = "D62"; // Invalid margin handling
211    pub const D63: &str = "D63"; // Invalid markup handling
212    pub const D64: &str = "D64"; // Invalid markdown handling
213    pub const D65: &str = "D65"; // Invalid adjustment handling
214    pub const D66: &str = "D66"; // Invalid correction handling
215    pub const D67: &str = "D67"; // Invalid compensation handling
216    pub const D68: &str = "D68"; // Invalid reimbursement handling
217    pub const D69: &str = "D69"; // Invalid refund handling
218    pub const D70: &str = "D70"; // Invalid rebate handling
219    pub const D71: &str = "D71"; // Invalid credit handling
220    pub const D72: &str = "D72"; // Invalid debit handling
221    pub const D73: &str = "D73"; // Invalid payment handling
222    pub const D74: &str = "D74"; // Invalid settlement handling
223    pub const D75: &str = "D75"; // Exchange rate field mandatory when currency codes differ
224    pub const D76: &str = "D76"; // Invalid clearing handling
225    pub const D77: &str = "D77"; // Invalid netting handling
226    pub const D78: &str = "D78"; // Invalid matching handling
227    pub const D79: &str = "D79"; // Field 71G dependency between sequence B and C
228    pub const D80: &str = "D80"; // Invalid reconciliation handling
229    pub const D81: &str = "D81"; // Invalid confirmation handling
230    pub const D82: &str = "D82"; // Invalid acknowledgment handling
231    pub const D83: &str = "D83"; // Invalid notification handling
232    pub const D84: &str = "D84"; // Invalid reporting handling
233    pub const D85: &str = "D85"; // Invalid monitoring handling
234    pub const D86: &str = "D86"; // Invalid tracking handling
235    pub const D87: &str = "D87"; // Invalid tracing handling
236    pub const D88: &str = "D88"; // Invalid audit handling
237    pub const D89: &str = "D89"; // Invalid logging handling
238    pub const D90: &str = "D90"; // Invalid archiving handling
239    pub const D91: &str = "D91"; // Invalid backup handling
240    pub const D92: &str = "D92"; // Invalid recovery handling
241    pub const D93: &str = "D93"; // Account number restrictions based on operation codes
242    pub const D94: &str = "D94"; // Invalid security handling
243    pub const D95: &str = "D95"; // Invalid encryption handling
244    pub const D96: &str = "D96"; // Invalid authentication handling
245    pub const D97: &str = "D97"; // Invalid authorization handling
246    pub const D98: &str = "D98"; // Invalid validation handling
247    pub const D99: &str = "D99"; // Invalid verification handling
248}
249
250/// E-Series: Enhanced/Field Relation Validation Error Codes
251///
252/// These errors relate to advanced validation for instruction codes, field options,
253/// and complex business rules.
254pub mod e_series {
255    pub const E01: &str = "E01"; // Instruction code restrictions (SPRI field 23E can only contain SDVA, TELB, PHOB, INTC)
256    pub const E02: &str = "E02"; // Prohibited instruction codes (SSTD/SPAY field 23E not allowed)
257    pub const E03: &str = "E03"; // Field option restrictions (53a cannot use option D with SPRI/SSTD/SPAY)
258    pub const E04: &str = "E04"; // Party identifier requirements in specific contexts
259    pub const E05: &str = "E05"; // Field option restrictions for 54a
260    pub const E06: &str = "E06"; // Multiple field dependency (if 55a present, both 53a and 54a required)
261    pub const E07: &str = "E07"; // Field option restrictions for 55a
262    pub const E08: &str = "E08"; // Invalid instruction combination
263    pub const E09: &str = "E09"; // Party identifier mandatory in option D for field 57a
264    pub const E10: &str = "E10"; // Beneficiary account mandatory for specific operation codes
265    pub const E11: &str = "E11"; // Invalid option combination
266    pub const E12: &str = "E12"; // Invalid field combination
267    pub const E13: &str = "E13"; // OUR charge handling restrictions (field 71F not allowed, 71G optional)
268    pub const E14: &str = "E14"; // Invalid charge combination
269    pub const E15: &str = "E15"; // BEN charge handling requirements (field 71F mandatory, 71G not allowed)
270    pub const E16: &str = "E16"; // Field restrictions with SPRI (56a not allowed with SPRI)
271    pub const E17: &str = "E17"; // Clearing code requirements for option C
272    pub const E18: &str = "E18"; // Account restrictions with CHQB operation code
273    pub const E19: &str = "E19"; // Invalid operation combination
274    pub const E20: &str = "E20"; // Invalid service combination
275    pub const E21: &str = "E21"; // Invalid product combination
276    pub const E22: &str = "E22"; // Invalid feature combination
277    pub const E23: &str = "E23"; // Invalid function combination
278    pub const E24: &str = "E24"; // Invalid capability combination
279    pub const E25: &str = "E25"; // Invalid method combination
280    pub const E26: &str = "E26"; // Invalid procedure combination
281    pub const E27: &str = "E27"; // Invalid process combination
282    pub const E28: &str = "E28"; // Invalid workflow combination
283    pub const E29: &str = "E29"; // Invalid sequence combination
284    pub const E30: &str = "E30"; // Invalid step combination
285    pub const E31: &str = "E31"; // Invalid phase combination
286    pub const E32: &str = "E32"; // Invalid stage combination
287    pub const E33: &str = "E33"; // Invalid state combination
288    pub const E34: &str = "E34"; // Invalid status combination
289    pub const E35: &str = "E35"; // Invalid condition combination
290    pub const E36: &str = "E36"; // Invalid criteria combination
291    pub const E37: &str = "E37"; // Invalid requirement combination
292    pub const E38: &str = "E38"; // Invalid constraint combination
293    pub const E39: &str = "E39"; // Invalid restriction combination
294    pub const E40: &str = "E40"; // Invalid limitation combination
295    pub const E41: &str = "E41"; // Invalid boundary combination
296    pub const E42: &str = "E42"; // Invalid threshold combination
297    pub const E43: &str = "E43"; // Invalid limit combination
298    pub const E44: &str = "E44"; // Instruction code dependencies on field presence
299    pub const E45: &str = "E45"; // Instruction code field dependencies on field presence
300    pub const E46: &str = "E46"; // Invalid dependency combination
301    pub const E47: &str = "E47"; // Invalid relationship combination
302    pub const E48: &str = "E48"; // Invalid association combination
303    pub const E49: &str = "E49"; // Invalid connection combination
304    pub const E50: &str = "E50"; // Invalid link combination
305    pub const E51: &str = "E51"; // Invalid reference combination
306    pub const E52: &str = "E52"; // Invalid pointer combination
307    pub const E53: &str = "E53"; // Invalid identifier combination
308    pub const E54: &str = "E54"; // Invalid key combination
309    pub const E55: &str = "E55"; // Invalid index combination
310    pub const E56: &str = "E56"; // Invalid code combination
311    pub const E57: &str = "E57"; // Invalid value combination
312    pub const E58: &str = "E58"; // Invalid data combination
313    pub const E59: &str = "E59"; // Invalid content combination
314    pub const E60: &str = "E60"; // Invalid information combination
315    pub const E61: &str = "E61"; // Invalid detail combination
316    pub const E62: &str = "E62"; // Invalid element combination
317    pub const E63: &str = "E63"; // Invalid component combination
318    pub const E64: &str = "E64"; // Invalid part combination
319    pub const E65: &str = "E65"; // Invalid section combination
320    pub const E66: &str = "E66"; // Invalid segment combination
321    pub const E67: &str = "E67"; // Invalid block combination
322    pub const E68: &str = "E68"; // Invalid group combination
323    pub const E69: &str = "E69"; // Invalid set combination
324    pub const E70: &str = "E70"; // Invalid collection combination
325    pub const E71: &str = "E71"; // Invalid array combination
326    pub const E72: &str = "E72"; // Invalid list combination
327    pub const E73: &str = "E73"; // Invalid sequence combination
328    pub const E74: &str = "E74"; // Invalid order combination
329    pub const E75: &str = "E75"; // Invalid arrangement combination
330    pub const E76: &str = "E76"; // Invalid structure combination
331    pub const E77: &str = "E77"; // Invalid format combination
332    pub const E78: &str = "E78"; // Invalid pattern combination
333    pub const E79: &str = "E79"; // Invalid template combination
334    pub const E80: &str = "E80"; // Invalid schema combination
335    pub const E81: &str = "E81"; // Invalid model combination
336    pub const E82: &str = "E82"; // Invalid design combination
337    pub const E83: &str = "E83"; // Invalid specification combination
338    pub const E84: &str = "E84"; // Invalid definition combination
339    pub const E85: &str = "E85"; // Invalid description combination
340    pub const E86: &str = "E86"; // Invalid configuration combination
341}
342
343/// G-Series: General/Field Validation Error Codes
344///
345/// The largest category covering general field validation across all MT categories,
346/// particularly prominent in Categories 2, 3, 5-9.
347pub mod g_series {
348    // Sample G-series codes - in practice, this would contain all 823 codes
349    pub const G001: &str = "G001"; // Field format violation
350    pub const G002: &str = "G002"; // Field length violation
351    pub const G003: &str = "G003"; // Field content violation
352    pub const G004: &str = "G004"; // Field pattern violation
353    pub const G005: &str = "G005"; // Field range violation
354    pub const G006: &str = "G006"; // Field type violation
355    pub const G007: &str = "G007"; // Field structure violation
356    pub const G008: &str = "G008"; // Field sequence violation
357    pub const G009: &str = "G009"; // Field order violation
358    pub const G010: &str = "G010"; // Field position violation
359    pub const G011: &str = "G011"; // Field occurrence violation
360    pub const G012: &str = "G012"; // Field repetition violation
361    pub const G013: &str = "G013"; // Field multiplicity violation
362    pub const G014: &str = "G014"; // Field cardinality violation
363    pub const G015: &str = "G015"; // Field optionality violation
364    pub const G016: &str = "G016"; // Field mandatory violation
365    pub const G017: &str = "G017"; // Field conditional violation
366    pub const G018: &str = "G018"; // Field dependency violation
367    pub const G019: &str = "G019"; // Field exclusion violation
368    pub const G020: &str = "G020"; // Field inclusion violation
369    pub const G021: &str = "G021"; // Field choice violation
370    pub const G022: &str = "G022"; // Field alternative violation
371    pub const G023: &str = "G023"; // Field option violation
372    pub const G024: &str = "G024"; // Field variant violation
373    pub const G025: &str = "G025"; // Field version violation
374    pub const G026: &str = "G026"; // Field release violation
375    pub const G027: &str = "G027"; // Field edition violation
376    pub const G028: &str = "G028"; // Field revision violation
377    pub const G029: &str = "G029"; // Field update violation
378    pub const G030: &str = "G030"; // Field modification violation
379    pub const G031: &str = "G031"; // Field change violation
380    pub const G032: &str = "G032"; // Field amendment violation
381    pub const G033: &str = "G033"; // Field correction violation
382    pub const G034: &str = "G034"; // Field adjustment violation
383    pub const G035: &str = "G035"; // Field enhancement violation
384    pub const G036: &str = "G036"; // Field improvement violation
385    pub const G037: &str = "G037"; // Field extension violation
386    pub const G038: &str = "G038"; // Field expansion violation
387    pub const G039: &str = "G039"; // Field addition violation
388    pub const G040: &str = "G040"; // Field supplementation violation
389    pub const G041: &str = "G041"; // Field completion violation
390    pub const G042: &str = "G042"; // Field finalization violation
391    pub const G043: &str = "G043"; // Field consolidation violation
392    pub const G044: &str = "G044"; // Field integration violation
393    pub const G045: &str = "G045"; // Field unification violation
394    pub const G046: &str = "G046"; // Field standardization violation
395    pub const G047: &str = "G047"; // Field normalization violation
396    pub const G048: &str = "G048"; // Field harmonization violation
397    pub const G049: &str = "G049"; // Field synchronization violation
398    pub const G050: &str = "G050"; // Field content validation
399    pub const G100: &str = "G100"; // Sequence validation
400    pub const G150: &str = "G150"; // Message validation
401    pub const G200: &str = "G200"; // Block validation
402    pub const G250: &str = "G250"; // Header validation
403    pub const G300: &str = "G300"; // Trailer validation
404    pub const G350: &str = "G350"; // Network validation
405    pub const G400: &str = "G400"; // System validation
406    pub const G450: &str = "G450"; // Service validation
407    pub const G500: &str = "G500"; // Product validation
408    pub const G550: &str = "G550"; // Feature validation
409    pub const G600: &str = "G600"; // Function validation
410    pub const G650: &str = "G650"; // Capability validation
411    pub const G700: &str = "G700"; // Method validation
412    pub const G750: &str = "G750"; // Procedure validation
413    pub const G800: &str = "G800"; // Process validation
414    // Note: In practice, this module would contain all 823 G-series codes
415    // This is a representative sample showing the naming convention
416}
417
418/// Error code lookup and metadata
419pub mod metadata {
420    use once_cell::sync::Lazy;
421    use std::collections::HashMap;
422
423    /// Error code metadata structure
424    #[derive(Debug, Clone)]
425    pub struct ErrorCodeInfo {
426        pub code: &'static str,
427        pub series: &'static str,
428        pub category: &'static str,
429        pub description: &'static str,
430        pub when_thrown: &'static str,
431        pub mt_categories: &'static [&'static str],
432    }
433
434    /// Static lookup table for error code metadata
435    pub static ERROR_CODE_METADATA: Lazy<HashMap<&'static str, ErrorCodeInfo>> = Lazy::new(|| {
436        let mut map = HashMap::new();
437
438        // T-Series metadata
439        map.insert(
440            "T08",
441            ErrorCodeInfo {
442                code: "T08",
443                series: "T",
444                category: "Format Validation",
445                description: "Invalid code in field",
446                when_thrown: "Field contains invalid enumerated value",
447                mt_categories: &["1", "2", "3", "4", "5", "6", "7", "8", "9"],
448            },
449        );
450
451        map.insert(
452            "T27",
453            ErrorCodeInfo {
454                code: "T27",
455                series: "T",
456                category: "Format Validation",
457                description: "Invalid BIC code format",
458                when_thrown: "BIC doesn't match required pattern",
459                mt_categories: &["1", "2", "3", "5"],
460            },
461        );
462
463        map.insert(
464            "T50",
465            ErrorCodeInfo {
466                code: "T50",
467                series: "T",
468                category: "Format Validation",
469                description: "Invalid date format",
470                when_thrown: "Date not in YYMMDD format",
471                mt_categories: &["1", "2", "3", "4", "5", "6", "7", "8", "9"],
472            },
473        );
474
475        // C-Series metadata
476        map.insert(
477            "C02",
478            ErrorCodeInfo {
479                code: "C02",
480                series: "C",
481                category: "Business Rules",
482                description: "Currency code mismatch",
483                when_thrown: "Related fields have different currencies",
484                mt_categories: &["1", "2", "3", "5"],
485            },
486        );
487
488        // D-Series metadata
489        map.insert(
490            "D19",
491            ErrorCodeInfo {
492                code: "D19",
493                series: "D",
494                category: "Content Validation",
495                description: "IBAN mandatory for SEPA",
496                when_thrown: "EU payment without IBAN in beneficiary field",
497                mt_categories: &["1"],
498            },
499        );
500
501        // E-Series metadata
502        map.insert(
503            "E01",
504            ErrorCodeInfo {
505                code: "E01",
506                series: "E",
507                category: "Relation Validation",
508                description: "Instruction code restrictions",
509                when_thrown: "Field 23E with SPRI can only contain SDVA, TELB, PHOB, INTC",
510                mt_categories: &["1"],
511            },
512        );
513
514        // G-Series metadata
515        map.insert(
516            "G001",
517            ErrorCodeInfo {
518                code: "G001",
519                series: "G",
520                category: "General Validation",
521                description: "Field format violation",
522                when_thrown: "Field doesn't match specified format pattern",
523                mt_categories: &["2", "3", "5", "6", "7", "8", "9"],
524            },
525        );
526
527        map
528    });
529
530    /// Get metadata for an error code
531    pub fn get_error_info(code: &str) -> Option<&'static ErrorCodeInfo> {
532        ERROR_CODE_METADATA.get(code)
533    }
534
535    /// Get all error codes for a specific series
536    pub fn get_codes_by_series(series: &str) -> Vec<&'static str> {
537        ERROR_CODE_METADATA
538            .values()
539            .filter(|info| info.series == series)
540            .map(|info| info.code)
541            .collect()
542    }
543
544    /// Get all error codes for a specific MT category
545    pub fn get_codes_by_category(category: &str) -> Vec<&'static str> {
546        ERROR_CODE_METADATA
547            .values()
548            .filter(|info| info.mt_categories.contains(&category))
549            .map(|info| info.code)
550            .collect()
551    }
552}
553
554/// Regional validation constants
555pub mod regional {
556    /// SEPA country codes requiring IBAN validation
557    pub const SEPA_COUNTRIES: &[&str] = &[
558        "AD", "AT", "BE", "BG", "BV", "CH", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GB",
559        "GF", "GI", "GP", "GR", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MQ", "MT",
560        "NL", "NO", "PL", "PM", "PT", "RE", "RO", "SE", "SI", "SJ", "SK", "SM", "TF", "VA",
561    ];
562
563    /// Check if a country code is in the SEPA region
564    pub fn is_sepa_country(country_code: &str) -> bool {
565        SEPA_COUNTRIES.contains(&country_code)
566    }
567}
568
569/// Charge code validation constants
570pub mod charges {
571    /// Valid charge codes
572    pub const CHARGE_CODES: &[&str] = &["BEN", "OUR", "SHA"];
573
574    /// Check if a charge code is valid
575    pub fn is_valid_charge_code(code: &str) -> bool {
576        CHARGE_CODES.contains(&code)
577    }
578}
579
580/// Currency validation constants  
581pub mod currencies {
582    /// Commodity currencies not allowed in payment messages
583    pub const COMMODITY_CURRENCIES: &[&str] = &["XAU", "XAG", "XPD", "XPT"];
584
585    /// Check if a currency is a commodity currency
586    pub fn is_commodity_currency(currency: &str) -> bool {
587        COMMODITY_CURRENCIES.contains(&currency)
588    }
589}