swift_mt_message/fields/
field20.rs

1use serde::{Deserialize, Serialize};
2use swift_mt_message_macros::SwiftField;
3
4///   **Field 20: Sender's Reference**
5///
6/// ## Purpose
7/// Specifies the reference assigned by the Sender to unambiguously identify the message.
8/// This reference must be unique within the sender's system and is used to link related
9/// messages and confirmations throughout the payment chain.
10///
11/// ## Format
12/// - **Swift Format**: `16x`
13/// - **Description**: Up to 16 alphanumeric characters
14/// - **Pattern**: May include letters, digits, and limited special characters
15/// - **Restrictions**: Must not start or end with `/` and must not contain `//`
16///
17/// ## Presence
18/// - **Status**: Mandatory in all MT messages containing this field
19/// - **Swift Error Codes**: T26 (invalid format), T13 (field too long)
20/// - **Referenced in Rules**: Network validation rules across multiple message types
21///
22/// ## Network Validation Rules
23/// - **Format Validation**: Must conform to 16x pattern (alphanumeric, max 16 chars)
24/// - **Content Validation**: Cannot start/end with `/` or contain consecutive slashes `//`
25/// - **Uniqueness**: Should be unique within sender's daily operations for audit purposes
26///
27/// ## Usage Rules
28/// - **Confirmations**: Must be quoted unchanged in related MT900/MT910/MT950 messages
29/// - **Cover Payments**: When using cover method, copy to field 21 of associated MT202 COV
30/// - **Audit Trail**: Used by institutions to track payment lifecycle and exceptions
31/// - **Reference Format**: Common patterns include transaction IDs, invoice numbers, or internal references
32///
33/// ## Examples
34/// ```logic
35/// :20:PAYMENT123456
36/// :20:INV2024001234
37/// :20:TXN20240719001
38/// :20:URGPAY240719
39/// ```
40///
41/// ## Related Fields
42/// - **Field 21**: Transaction Reference Number (often contains Field 20 value in cover payments)
43/// - **Field 61**: Statement Line Reference (in account statements)
44/// - **Block 3 {108}**: Message User Reference (system-level tracking)
45///
46/// ## STP Compliance
47/// Field 20 has no specific STP restrictions but must meet standard format requirements.
48/// STP processing relies on this field for automated matching and exception handling.
49///
50/// ## See Also
51/// - Swift FIN User Handbook: Message Structure and Field Specifications
52/// - MT103 Specification: Customer Credit Transfer requirements
53/// - Cover Payment Guidelines: Field 20/21 relationship rules
54#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SwiftField)]
55pub struct Field20 {
56    /// The sender's reference string (max 16 characters)
57    ///
58    /// Format: 16x - Up to 16 alphanumeric characters
59    /// Validation: No leading/trailing slashes, no consecutive slashes
60    #[component("16x")]
61    pub reference: String,
62}