mx_message/document/
camt_105_001_02_mc.rs

1// Plasmatic MX Message Parsing Library
2// https://github.com/GoPlasmatic/MXMessage
3//
4// Copyright (c) 2025 Plasmatic
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//     http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// You may obtain a copy of this library at
18// https://github.com/GoPlasmatic/MXMessage
19
20use crate::error::*;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24// AccountIdentification4Choice1: Unique identification of an account, as assigned by the account servicer, using an identification scheme.
25#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice1 {
27    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
28    pub iban: Option<String>,
29    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
30    pub othr: Option<GenericAccountIdentification11>,
31}
32
33impl AccountIdentification4Choice1 {
34    pub fn validate(&self) -> Result<(), ValidationError> {
35        if let Some(ref val) = self.iban {
36            let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
37            if !pattern.is_match(val) {
38                return Err(ValidationError::new(
39                    1005,
40                    "iban does not match the required pattern".to_string(),
41                ));
42            }
43        }
44        if let Some(ref val) = self.othr {
45            val.validate()?
46        }
47        Ok(())
48    }
49}
50
51// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountSchemeName1Choice1 {
54    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55    pub cd: Option<String>,
56    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57    pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice1 {
61    pub fn validate(&self) -> Result<(), ValidationError> {
62        if let Some(ref val) = self.cd {
63            if val.chars().count() < 1 {
64                return Err(ValidationError::new(
65                    1001,
66                    "cd is shorter than the minimum length of 1".to_string(),
67                ));
68            }
69            if val.chars().count() > 4 {
70                return Err(ValidationError::new(
71                    1002,
72                    "cd exceeds the maximum length of 4".to_string(),
73                ));
74            }
75        }
76        if let Some(ref val) = self.prtry {
77            if val.chars().count() < 1 {
78                return Err(ValidationError::new(
79                    1001,
80                    "prtry is shorter than the minimum length of 1".to_string(),
81                ));
82            }
83            if val.chars().count() > 35 {
84                return Err(ValidationError::new(
85                    1002,
86                    "prtry exceeds the maximum length of 35".to_string(),
87                ));
88            }
89            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
90            if !pattern.is_match(val) {
91                return Err(ValidationError::new(
92                    1005,
93                    "prtry does not match the required pattern".to_string(),
94                ));
95            }
96        }
97        Ok(())
98    }
99}
100
101// BranchAndFinancialInstitutionIdentification81: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
102#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
103pub struct BranchAndFinancialInstitutionIdentification81 {
104    #[serde(rename = "FinInstnId")]
105    pub fin_instn_id: FinancialInstitutionIdentification231,
106}
107
108impl BranchAndFinancialInstitutionIdentification81 {
109    pub fn validate(&self) -> Result<(), ValidationError> {
110        self.fin_instn_id.validate()?;
111        Ok(())
112    }
113}
114
115// CBPRAmount: CBPR_Amount
116#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
117pub struct CBPRAmount {
118    #[serde(rename = "@Ccy")]
119    pub ccy: String,
120    #[serde(rename = "$value")]
121    pub value: f64,
122}
123
124impl CBPRAmount {
125    pub fn validate(&self) -> Result<(), ValidationError> {
126        Ok(())
127    }
128}
129
130// CashAccount401: Specifies an alternate assumed name for the identification of the account.
131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
132pub struct CashAccount401 {
133    #[serde(rename = "Id")]
134    pub id: AccountIdentification4Choice1,
135    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
136    pub tp: Option<CashAccountType2Choice1>,
137    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
138    pub ccy: Option<String>,
139    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
140    pub nm: Option<String>,
141    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
142    pub prxy: Option<ProxyAccountIdentification11>,
143}
144
145impl CashAccount401 {
146    pub fn validate(&self) -> Result<(), ValidationError> {
147        self.id.validate()?;
148        if let Some(ref val) = self.tp {
149            val.validate()?
150        }
151        if let Some(ref val) = self.ccy {
152            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
153            if !pattern.is_match(val) {
154                return Err(ValidationError::new(
155                    1005,
156                    "ccy does not match the required pattern".to_string(),
157                ));
158            }
159        }
160        if let Some(ref val) = self.nm {
161            if val.chars().count() < 1 {
162                return Err(ValidationError::new(
163                    1001,
164                    "nm is shorter than the minimum length of 1".to_string(),
165                ));
166            }
167            if val.chars().count() > 70 {
168                return Err(ValidationError::new(
169                    1002,
170                    "nm exceeds the maximum length of 70".to_string(),
171                ));
172            }
173            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
174            if !pattern.is_match(val) {
175                return Err(ValidationError::new(
176                    1005,
177                    "nm does not match the required pattern".to_string(),
178                ));
179            }
180        }
181        if let Some(ref val) = self.prxy {
182            val.validate()?
183        }
184        Ok(())
185    }
186}
187
188// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
189#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
190pub struct CashAccountType2Choice1 {
191    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
192    pub cd: Option<String>,
193    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
194    pub prtry: Option<String>,
195}
196
197impl CashAccountType2Choice1 {
198    pub fn validate(&self) -> Result<(), ValidationError> {
199        if let Some(ref val) = self.cd {
200            if val.chars().count() < 1 {
201                return Err(ValidationError::new(
202                    1001,
203                    "cd is shorter than the minimum length of 1".to_string(),
204                ));
205            }
206            if val.chars().count() > 4 {
207                return Err(ValidationError::new(
208                    1002,
209                    "cd exceeds the maximum length of 4".to_string(),
210                ));
211            }
212        }
213        if let Some(ref val) = self.prtry {
214            if val.chars().count() < 1 {
215                return Err(ValidationError::new(
216                    1001,
217                    "prtry is shorter than the minimum length of 1".to_string(),
218                ));
219            }
220            if val.chars().count() > 35 {
221                return Err(ValidationError::new(
222                    1002,
223                    "prtry exceeds the maximum length of 35".to_string(),
224                ));
225            }
226            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
227            if !pattern.is_match(val) {
228                return Err(ValidationError::new(
229                    1005,
230                    "prtry does not match the required pattern".to_string(),
231                ));
232            }
233        }
234        Ok(())
235    }
236}
237
238// ChargeType3Choice1: Charge type, in a coded form.
239#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
240pub struct ChargeType3Choice1 {
241    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
242    pub cd: Option<String>,
243}
244
245impl ChargeType3Choice1 {
246    pub fn validate(&self) -> Result<(), ValidationError> {
247        if let Some(ref val) = self.cd {
248            if val.chars().count() < 1 {
249                return Err(ValidationError::new(
250                    1001,
251                    "cd is shorter than the minimum length of 1".to_string(),
252                ));
253            }
254            if val.chars().count() > 4 {
255                return Err(ValidationError::new(
256                    1002,
257                    "cd exceeds the maximum length of 4".to_string(),
258                ));
259            }
260        }
261        Ok(())
262    }
263}
264
265// Charges4Choice1: Charges broken down per payment transaction.
266#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
267pub struct Charges4Choice1 {
268    #[serde(rename = "PerTx", skip_serializing_if = "Option::is_none")]
269    pub per_tx: Option<ChargesPerTransaction41>,
270}
271
272impl Charges4Choice1 {
273    pub fn validate(&self) -> Result<(), ValidationError> {
274        if let Some(ref val) = self.per_tx {
275            val.validate()?
276        }
277        Ok(())
278    }
279}
280
281// ChargesBreakdown11: Specifies the type of charge.
282#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
283pub struct ChargesBreakdown11 {
284    #[serde(rename = "Amt")]
285    pub amt: CBPRAmount,
286    #[serde(rename = "CdtDbtInd")]
287    pub cdt_dbt_ind: CreditDebitCode1,
288    #[serde(rename = "Tp")]
289    pub tp: ChargeType3Choice1,
290}
291
292impl ChargesBreakdown11 {
293    pub fn validate(&self) -> Result<(), ValidationError> {
294        self.amt.validate()?;
295        self.cdt_dbt_ind.validate()?;
296        self.tp.validate()?;
297        Ok(())
298    }
299}
300
301// ChargesPaymentNotificationV02: Provides information on the charges to be paid by the charge bearer(s) related to the processing of the underlying transaction.
302#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
303pub struct ChargesPaymentNotificationV02 {
304    #[serde(rename = "GrpHdr")]
305    pub grp_hdr: GroupHeader1261,
306    #[serde(rename = "Chrgs")]
307    pub chrgs: Charges4Choice1,
308}
309
310impl ChargesPaymentNotificationV02 {
311    pub fn validate(&self) -> Result<(), ValidationError> {
312        self.grp_hdr.validate()?;
313        self.chrgs.validate()?;
314        Ok(())
315    }
316}
317
318// ChargesPerTransaction41: Itemised charges record per transaction.
319#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
320pub struct ChargesPerTransaction41 {
321    #[serde(rename = "ChrgsId")]
322    pub chrgs_id: String,
323    #[serde(rename = "Rcrd")]
324    pub rcrd: Vec<ChargesPerTransactionRecord41>,
325}
326
327impl ChargesPerTransaction41 {
328    pub fn validate(&self) -> Result<(), ValidationError> {
329        if self.chrgs_id.chars().count() < 1 {
330            return Err(ValidationError::new(
331                1001,
332                "chrgs_id is shorter than the minimum length of 1".to_string(),
333            ));
334        }
335        if self.chrgs_id.chars().count() > 16 {
336            return Err(ValidationError::new(
337                1002,
338                "chrgs_id exceeds the maximum length of 16".to_string(),
339            ));
340        }
341        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
342        if !pattern.is_match(&self.chrgs_id) {
343            return Err(ValidationError::new(
344                1005,
345                "chrgs_id does not match the required pattern".to_string(),
346            ));
347        }
348        for item in &self.rcrd {
349            item.validate()?
350        }
351        Ok(())
352    }
353}
354
355// ChargesPerTransactionRecord41: Specifies the account of the debtor agent of the initial transaction, when instructing agent is different from the charges account owner.
356#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
357pub struct ChargesPerTransactionRecord41 {
358    #[serde(rename = "RcrdId", skip_serializing_if = "Option::is_none")]
359    pub rcrd_id: Option<String>,
360    #[serde(rename = "ChrgsRqstr")]
361    pub chrgs_rqstr: BranchAndFinancialInstitutionIdentification81,
362    #[serde(rename = "UndrlygTx")]
363    pub undrlyg_tx: TransactionReferences71,
364    #[serde(rename = "TtlChrgsPerRcrd")]
365    pub ttl_chrgs_per_rcrd: TotalCharges81,
366    #[serde(rename = "ChrgsBrkdwn")]
367    pub chrgs_brkdwn: Vec<ChargesBreakdown11>,
368    #[serde(rename = "ValDt")]
369    pub val_dt: DateAndDateTime2Choice1,
370    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
371    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification81>,
372    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
373    pub dbtr_agt_acct: Option<CashAccount401>,
374}
375
376impl ChargesPerTransactionRecord41 {
377    pub fn validate(&self) -> Result<(), ValidationError> {
378        if let Some(ref val) = self.rcrd_id {
379            if val.chars().count() < 1 {
380                return Err(ValidationError::new(
381                    1001,
382                    "rcrd_id is shorter than the minimum length of 1".to_string(),
383                ));
384            }
385            if val.chars().count() > 35 {
386                return Err(ValidationError::new(
387                    1002,
388                    "rcrd_id exceeds the maximum length of 35".to_string(),
389                ));
390            }
391            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
392            if !pattern.is_match(val) {
393                return Err(ValidationError::new(
394                    1005,
395                    "rcrd_id does not match the required pattern".to_string(),
396                ));
397            }
398        }
399        self.chrgs_rqstr.validate()?;
400        self.undrlyg_tx.validate()?;
401        self.ttl_chrgs_per_rcrd.validate()?;
402        for item in &self.chrgs_brkdwn {
403            item.validate()?
404        }
405        self.val_dt.validate()?;
406        if let Some(ref val) = self.dbtr_agt {
407            val.validate()?
408        }
409        if let Some(ref val) = self.dbtr_agt_acct {
410            val.validate()?
411        }
412        Ok(())
413    }
414}
415
416// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
417#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
418pub struct ClearingSystemIdentification2Choice1 {
419    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
420    pub cd: Option<String>,
421}
422
423impl ClearingSystemIdentification2Choice1 {
424    pub fn validate(&self) -> Result<(), ValidationError> {
425        if let Some(ref val) = self.cd {
426            if val.chars().count() < 1 {
427                return Err(ValidationError::new(
428                    1001,
429                    "cd is shorter than the minimum length of 1".to_string(),
430                ));
431            }
432            if val.chars().count() > 5 {
433                return Err(ValidationError::new(
434                    1002,
435                    "cd exceeds the maximum length of 5".to_string(),
436                ));
437            }
438        }
439        Ok(())
440    }
441}
442
443// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
444#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
445pub struct ClearingSystemMemberIdentification21 {
446    #[serde(rename = "ClrSysId")]
447    pub clr_sys_id: ClearingSystemIdentification2Choice1,
448    #[serde(rename = "MmbId")]
449    pub mmb_id: String,
450}
451
452impl ClearingSystemMemberIdentification21 {
453    pub fn validate(&self) -> Result<(), ValidationError> {
454        self.clr_sys_id.validate()?;
455        if self.mmb_id.chars().count() < 1 {
456            return Err(ValidationError::new(
457                1001,
458                "mmb_id is shorter than the minimum length of 1".to_string(),
459            ));
460        }
461        if self.mmb_id.chars().count() > 28 {
462            return Err(ValidationError::new(
463                1002,
464                "mmb_id exceeds the maximum length of 28".to_string(),
465            ));
466        }
467        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
468        if !pattern.is_match(&self.mmb_id) {
469            return Err(ValidationError::new(
470                1005,
471                "mmb_id does not match the required pattern".to_string(),
472            ));
473        }
474        Ok(())
475    }
476}
477
478// CreditDebitCode__1: Operation is a decrease.
479#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
480pub enum CreditDebitCode1 {
481    #[default]
482    #[serde(rename = "DBIT")]
483    CodeDBIT,
484}
485
486impl CreditDebitCode1 {
487    pub fn validate(&self) -> Result<(), ValidationError> {
488        Ok(())
489    }
490}
491
492// DateAndDateTime2Choice1: Specified date.
493#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
494pub struct DateAndDateTime2Choice1 {
495    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
496    pub dt: Option<String>,
497}
498
499impl DateAndDateTime2Choice1 {
500    pub fn validate(&self) -> Result<(), ValidationError> {
501        Ok(())
502    }
503}
504
505// FinancialInstitutionIdentification231: Information that locates and identifies a specific address, as defined by postal services.
506#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
507pub struct FinancialInstitutionIdentification231 {
508    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
509    pub bicfi: Option<String>,
510    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
511    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
512    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
513    pub lei: Option<String>,
514    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
515    pub nm: Option<String>,
516    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
517    pub pstl_adr: Option<PostalAddress271>,
518}
519
520impl FinancialInstitutionIdentification231 {
521    pub fn validate(&self) -> Result<(), ValidationError> {
522        if let Some(ref val) = self.bicfi {
523            let pattern =
524                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
525            if !pattern.is_match(val) {
526                return Err(ValidationError::new(
527                    1005,
528                    "bicfi does not match the required pattern".to_string(),
529                ));
530            }
531        }
532        if let Some(ref val) = self.clr_sys_mmb_id {
533            val.validate()?
534        }
535        if let Some(ref val) = self.lei {
536            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
537            if !pattern.is_match(val) {
538                return Err(ValidationError::new(
539                    1005,
540                    "lei does not match the required pattern".to_string(),
541                ));
542            }
543        }
544        if let Some(ref val) = self.nm {
545            if val.chars().count() < 1 {
546                return Err(ValidationError::new(
547                    1001,
548                    "nm is shorter than the minimum length of 1".to_string(),
549                ));
550            }
551            if val.chars().count() > 140 {
552                return Err(ValidationError::new(
553                    1002,
554                    "nm exceeds the maximum length of 140".to_string(),
555                ));
556            }
557            let pattern = Regex::new(
558                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
559            )
560            .unwrap();
561            if !pattern.is_match(val) {
562                return Err(ValidationError::new(
563                    1005,
564                    "nm does not match the required pattern".to_string(),
565                ));
566            }
567        }
568        if let Some(ref val) = self.pstl_adr {
569            val.validate()?
570        }
571        Ok(())
572    }
573}
574
575// GenericAccountIdentification11: Entity that assigns the identification.
576#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
577pub struct GenericAccountIdentification11 {
578    #[serde(rename = "Id")]
579    pub id: String,
580    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
581    pub schme_nm: Option<AccountSchemeName1Choice1>,
582    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
583    pub issr: Option<String>,
584}
585
586impl GenericAccountIdentification11 {
587    pub fn validate(&self) -> Result<(), ValidationError> {
588        if self.id.chars().count() < 1 {
589            return Err(ValidationError::new(
590                1001,
591                "id is shorter than the minimum length of 1".to_string(),
592            ));
593        }
594        if self.id.chars().count() > 34 {
595            return Err(ValidationError::new(
596                1002,
597                "id exceeds the maximum length of 34".to_string(),
598            ));
599        }
600        let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
601        if !pattern.is_match(&self.id) {
602            return Err(ValidationError::new(
603                1005,
604                "id does not match the required pattern".to_string(),
605            ));
606        }
607        if let Some(ref val) = self.schme_nm {
608            val.validate()?
609        }
610        if let Some(ref val) = self.issr {
611            if val.chars().count() < 1 {
612                return Err(ValidationError::new(
613                    1001,
614                    "issr is shorter than the minimum length of 1".to_string(),
615                ));
616            }
617            if val.chars().count() > 35 {
618                return Err(ValidationError::new(
619                    1002,
620                    "issr exceeds the maximum length of 35".to_string(),
621                ));
622            }
623            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
624            if !pattern.is_match(val) {
625                return Err(ValidationError::new(
626                    1005,
627                    "issr does not match the required pattern".to_string(),
628                ));
629            }
630        }
631        Ok(())
632    }
633}
634
635// GroupHeader1261: Agent that owns the charges account.
636#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
637pub struct GroupHeader1261 {
638    #[serde(rename = "MsgId")]
639    pub msg_id: String,
640    #[serde(rename = "CreDtTm")]
641    pub cre_dt_tm: String,
642    #[serde(rename = "TtlChrgs")]
643    pub ttl_chrgs: TotalCharges71,
644    #[serde(rename = "ChrgsAcct")]
645    pub chrgs_acct: CashAccount401,
646    #[serde(rename = "ChrgsAcctOwnr", skip_serializing_if = "Option::is_none")]
647    pub chrgs_acct_ownr: Option<BranchAndFinancialInstitutionIdentification81>,
648}
649
650impl GroupHeader1261 {
651    pub fn validate(&self) -> Result<(), ValidationError> {
652        if self.msg_id.chars().count() < 1 {
653            return Err(ValidationError::new(
654                1001,
655                "msg_id is shorter than the minimum length of 1".to_string(),
656            ));
657        }
658        if self.msg_id.chars().count() > 35 {
659            return Err(ValidationError::new(
660                1002,
661                "msg_id exceeds the maximum length of 35".to_string(),
662            ));
663        }
664        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
665        if !pattern.is_match(&self.msg_id) {
666            return Err(ValidationError::new(
667                1005,
668                "msg_id does not match the required pattern".to_string(),
669            ));
670        }
671        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
672        if !pattern.is_match(&self.cre_dt_tm) {
673            return Err(ValidationError::new(
674                1005,
675                "cre_dt_tm does not match the required pattern".to_string(),
676            ));
677        }
678        self.ttl_chrgs.validate()?;
679        self.chrgs_acct.validate()?;
680        if let Some(ref val) = self.chrgs_acct_ownr {
681            val.validate()?
682        }
683        Ok(())
684    }
685}
686
687// PostalAddress271: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
688#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
689pub struct PostalAddress271 {
690    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
691    pub dept: Option<String>,
692    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
693    pub sub_dept: Option<String>,
694    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
695    pub strt_nm: Option<String>,
696    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
697    pub bldg_nb: Option<String>,
698    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
699    pub bldg_nm: Option<String>,
700    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
701    pub flr: Option<String>,
702    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
703    pub pst_bx: Option<String>,
704    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
705    pub room: Option<String>,
706    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
707    pub pst_cd: Option<String>,
708    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
709    pub twn_nm: Option<String>,
710    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
711    pub twn_lctn_nm: Option<String>,
712    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
713    pub dstrct_nm: Option<String>,
714    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
715    pub ctry_sub_dvsn: Option<String>,
716    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
717    pub ctry: Option<String>,
718    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
719    pub adr_line: Option<Vec<String>>,
720}
721
722impl PostalAddress271 {
723    pub fn validate(&self) -> Result<(), ValidationError> {
724        if let Some(ref val) = self.dept {
725            if val.chars().count() < 1 {
726                return Err(ValidationError::new(
727                    1001,
728                    "dept is shorter than the minimum length of 1".to_string(),
729                ));
730            }
731            if val.chars().count() > 70 {
732                return Err(ValidationError::new(
733                    1002,
734                    "dept exceeds the maximum length of 70".to_string(),
735                ));
736            }
737            let pattern = Regex::new(
738                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
739            )
740            .unwrap();
741            if !pattern.is_match(val) {
742                return Err(ValidationError::new(
743                    1005,
744                    "dept does not match the required pattern".to_string(),
745                ));
746            }
747        }
748        if let Some(ref val) = self.sub_dept {
749            if val.chars().count() < 1 {
750                return Err(ValidationError::new(
751                    1001,
752                    "sub_dept is shorter than the minimum length of 1".to_string(),
753                ));
754            }
755            if val.chars().count() > 70 {
756                return Err(ValidationError::new(
757                    1002,
758                    "sub_dept exceeds the maximum length of 70".to_string(),
759                ));
760            }
761            let pattern = Regex::new(
762                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
763            )
764            .unwrap();
765            if !pattern.is_match(val) {
766                return Err(ValidationError::new(
767                    1005,
768                    "sub_dept does not match the required pattern".to_string(),
769                ));
770            }
771        }
772        if let Some(ref val) = self.strt_nm {
773            if val.chars().count() < 1 {
774                return Err(ValidationError::new(
775                    1001,
776                    "strt_nm is shorter than the minimum length of 1".to_string(),
777                ));
778            }
779            if val.chars().count() > 70 {
780                return Err(ValidationError::new(
781                    1002,
782                    "strt_nm exceeds the maximum length of 70".to_string(),
783                ));
784            }
785            let pattern = Regex::new(
786                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
787            )
788            .unwrap();
789            if !pattern.is_match(val) {
790                return Err(ValidationError::new(
791                    1005,
792                    "strt_nm does not match the required pattern".to_string(),
793                ));
794            }
795        }
796        if let Some(ref val) = self.bldg_nb {
797            if val.chars().count() < 1 {
798                return Err(ValidationError::new(
799                    1001,
800                    "bldg_nb is shorter than the minimum length of 1".to_string(),
801                ));
802            }
803            if val.chars().count() > 16 {
804                return Err(ValidationError::new(
805                    1002,
806                    "bldg_nb exceeds the maximum length of 16".to_string(),
807                ));
808            }
809            let pattern = Regex::new(
810                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
811            )
812            .unwrap();
813            if !pattern.is_match(val) {
814                return Err(ValidationError::new(
815                    1005,
816                    "bldg_nb does not match the required pattern".to_string(),
817                ));
818            }
819        }
820        if let Some(ref val) = self.bldg_nm {
821            if val.chars().count() < 1 {
822                return Err(ValidationError::new(
823                    1001,
824                    "bldg_nm is shorter than the minimum length of 1".to_string(),
825                ));
826            }
827            if val.chars().count() > 35 {
828                return Err(ValidationError::new(
829                    1002,
830                    "bldg_nm exceeds the maximum length of 35".to_string(),
831                ));
832            }
833            let pattern = Regex::new(
834                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
835            )
836            .unwrap();
837            if !pattern.is_match(val) {
838                return Err(ValidationError::new(
839                    1005,
840                    "bldg_nm does not match the required pattern".to_string(),
841                ));
842            }
843        }
844        if let Some(ref val) = self.flr {
845            if val.chars().count() < 1 {
846                return Err(ValidationError::new(
847                    1001,
848                    "flr is shorter than the minimum length of 1".to_string(),
849                ));
850            }
851            if val.chars().count() > 70 {
852                return Err(ValidationError::new(
853                    1002,
854                    "flr exceeds the maximum length of 70".to_string(),
855                ));
856            }
857            let pattern = Regex::new(
858                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
859            )
860            .unwrap();
861            if !pattern.is_match(val) {
862                return Err(ValidationError::new(
863                    1005,
864                    "flr does not match the required pattern".to_string(),
865                ));
866            }
867        }
868        if let Some(ref val) = self.pst_bx {
869            if val.chars().count() < 1 {
870                return Err(ValidationError::new(
871                    1001,
872                    "pst_bx is shorter than the minimum length of 1".to_string(),
873                ));
874            }
875            if val.chars().count() > 16 {
876                return Err(ValidationError::new(
877                    1002,
878                    "pst_bx exceeds the maximum length of 16".to_string(),
879                ));
880            }
881            let pattern = Regex::new(
882                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
883            )
884            .unwrap();
885            if !pattern.is_match(val) {
886                return Err(ValidationError::new(
887                    1005,
888                    "pst_bx does not match the required pattern".to_string(),
889                ));
890            }
891        }
892        if let Some(ref val) = self.room {
893            if val.chars().count() < 1 {
894                return Err(ValidationError::new(
895                    1001,
896                    "room is shorter than the minimum length of 1".to_string(),
897                ));
898            }
899            if val.chars().count() > 70 {
900                return Err(ValidationError::new(
901                    1002,
902                    "room exceeds the maximum length of 70".to_string(),
903                ));
904            }
905            let pattern = Regex::new(
906                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
907            )
908            .unwrap();
909            if !pattern.is_match(val) {
910                return Err(ValidationError::new(
911                    1005,
912                    "room does not match the required pattern".to_string(),
913                ));
914            }
915        }
916        if let Some(ref val) = self.pst_cd {
917            if val.chars().count() < 1 {
918                return Err(ValidationError::new(
919                    1001,
920                    "pst_cd is shorter than the minimum length of 1".to_string(),
921                ));
922            }
923            if val.chars().count() > 16 {
924                return Err(ValidationError::new(
925                    1002,
926                    "pst_cd exceeds the maximum length of 16".to_string(),
927                ));
928            }
929            let pattern = Regex::new(
930                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
931            )
932            .unwrap();
933            if !pattern.is_match(val) {
934                return Err(ValidationError::new(
935                    1005,
936                    "pst_cd does not match the required pattern".to_string(),
937                ));
938            }
939        }
940        if let Some(ref val) = self.twn_nm {
941            if val.chars().count() < 1 {
942                return Err(ValidationError::new(
943                    1001,
944                    "twn_nm is shorter than the minimum length of 1".to_string(),
945                ));
946            }
947            if val.chars().count() > 35 {
948                return Err(ValidationError::new(
949                    1002,
950                    "twn_nm exceeds the maximum length of 35".to_string(),
951                ));
952            }
953            let pattern = Regex::new(
954                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
955            )
956            .unwrap();
957            if !pattern.is_match(val) {
958                return Err(ValidationError::new(
959                    1005,
960                    "twn_nm does not match the required pattern".to_string(),
961                ));
962            }
963        }
964        if let Some(ref val) = self.twn_lctn_nm {
965            if val.chars().count() < 1 {
966                return Err(ValidationError::new(
967                    1001,
968                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
969                ));
970            }
971            if val.chars().count() > 35 {
972                return Err(ValidationError::new(
973                    1002,
974                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
975                ));
976            }
977            let pattern = Regex::new(
978                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
979            )
980            .unwrap();
981            if !pattern.is_match(val) {
982                return Err(ValidationError::new(
983                    1005,
984                    "twn_lctn_nm does not match the required pattern".to_string(),
985                ));
986            }
987        }
988        if let Some(ref val) = self.dstrct_nm {
989            if val.chars().count() < 1 {
990                return Err(ValidationError::new(
991                    1001,
992                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
993                ));
994            }
995            if val.chars().count() > 35 {
996                return Err(ValidationError::new(
997                    1002,
998                    "dstrct_nm exceeds the maximum length of 35".to_string(),
999                ));
1000            }
1001            let pattern = Regex::new(
1002                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1003            )
1004            .unwrap();
1005            if !pattern.is_match(val) {
1006                return Err(ValidationError::new(
1007                    1005,
1008                    "dstrct_nm does not match the required pattern".to_string(),
1009                ));
1010            }
1011        }
1012        if let Some(ref val) = self.ctry_sub_dvsn {
1013            if val.chars().count() < 1 {
1014                return Err(ValidationError::new(
1015                    1001,
1016                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
1017                ));
1018            }
1019            if val.chars().count() > 35 {
1020                return Err(ValidationError::new(
1021                    1002,
1022                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
1023                ));
1024            }
1025            let pattern = Regex::new(
1026                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1027            )
1028            .unwrap();
1029            if !pattern.is_match(val) {
1030                return Err(ValidationError::new(
1031                    1005,
1032                    "ctry_sub_dvsn does not match the required pattern".to_string(),
1033                ));
1034            }
1035        }
1036        if let Some(ref val) = self.ctry {
1037            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1038            if !pattern.is_match(val) {
1039                return Err(ValidationError::new(
1040                    1005,
1041                    "ctry does not match the required pattern".to_string(),
1042                ));
1043            }
1044        }
1045        if let Some(ref vec) = self.adr_line {
1046            for item in vec {
1047                if item.chars().count() < 1 {
1048                    return Err(ValidationError::new(
1049                        1001,
1050                        "adr_line is shorter than the minimum length of 1".to_string(),
1051                    ));
1052                }
1053                if item.chars().count() > 70 {
1054                    return Err(ValidationError::new(
1055                        1002,
1056                        "adr_line exceeds the maximum length of 70".to_string(),
1057                    ));
1058                }
1059                let pattern = Regex::new(
1060                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1061                )
1062                .unwrap();
1063                if !pattern.is_match(&item) {
1064                    return Err(ValidationError::new(
1065                        1005,
1066                        "adr_line does not match the required pattern".to_string(),
1067                    ));
1068                }
1069            }
1070        }
1071        Ok(())
1072    }
1073}
1074
1075// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
1076#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1077pub struct ProxyAccountIdentification11 {
1078    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1079    pub tp: Option<ProxyAccountType1Choice1>,
1080    #[serde(rename = "Id")]
1081    pub id: String,
1082}
1083
1084impl ProxyAccountIdentification11 {
1085    pub fn validate(&self) -> Result<(), ValidationError> {
1086        if let Some(ref val) = self.tp {
1087            val.validate()?
1088        }
1089        if self.id.chars().count() < 1 {
1090            return Err(ValidationError::new(
1091                1001,
1092                "id is shorter than the minimum length of 1".to_string(),
1093            ));
1094        }
1095        if self.id.chars().count() > 320 {
1096            return Err(ValidationError::new(
1097                1002,
1098                "id exceeds the maximum length of 320".to_string(),
1099            ));
1100        }
1101        let pattern =
1102            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
1103                .unwrap();
1104        if !pattern.is_match(&self.id) {
1105            return Err(ValidationError::new(
1106                1005,
1107                "id does not match the required pattern".to_string(),
1108            ));
1109        }
1110        Ok(())
1111    }
1112}
1113
1114// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
1115#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1116pub struct ProxyAccountType1Choice1 {
1117    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1118    pub cd: Option<String>,
1119    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1120    pub prtry: Option<String>,
1121}
1122
1123impl ProxyAccountType1Choice1 {
1124    pub fn validate(&self) -> Result<(), ValidationError> {
1125        if let Some(ref val) = self.cd {
1126            if val.chars().count() < 1 {
1127                return Err(ValidationError::new(
1128                    1001,
1129                    "cd is shorter than the minimum length of 1".to_string(),
1130                ));
1131            }
1132            if val.chars().count() > 4 {
1133                return Err(ValidationError::new(
1134                    1002,
1135                    "cd exceeds the maximum length of 4".to_string(),
1136                ));
1137            }
1138        }
1139        if let Some(ref val) = self.prtry {
1140            if val.chars().count() < 1 {
1141                return Err(ValidationError::new(
1142                    1001,
1143                    "prtry is shorter than the minimum length of 1".to_string(),
1144                ));
1145            }
1146            if val.chars().count() > 35 {
1147                return Err(ValidationError::new(
1148                    1002,
1149                    "prtry exceeds the maximum length of 35".to_string(),
1150                ));
1151            }
1152            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1153            if !pattern.is_match(val) {
1154                return Err(ValidationError::new(
1155                    1005,
1156                    "prtry does not match the required pattern".to_string(),
1157                ));
1158            }
1159        }
1160        Ok(())
1161    }
1162}
1163
1164// TotalCharges71: Indicates whether the total charges amount is a credit or a debit amount.
1165// Usage: A zero amount is considered to be a credit.
1166#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1167pub struct TotalCharges71 {
1168    #[serde(rename = "NbOfChrgsRcrds")]
1169    pub nb_of_chrgs_rcrds: String,
1170    #[serde(rename = "TtlChrgsAmt")]
1171    pub ttl_chrgs_amt: CBPRAmount,
1172    #[serde(rename = "CdtDbtInd")]
1173    pub cdt_dbt_ind: CreditDebitCode1,
1174}
1175
1176impl TotalCharges71 {
1177    pub fn validate(&self) -> Result<(), ValidationError> {
1178        let pattern = Regex::new("[0-9]{1,15}").unwrap();
1179        if !pattern.is_match(&self.nb_of_chrgs_rcrds) {
1180            return Err(ValidationError::new(
1181                1005,
1182                "nb_of_chrgs_rcrds does not match the required pattern".to_string(),
1183            ));
1184        }
1185        self.ttl_chrgs_amt.validate()?;
1186        self.cdt_dbt_ind.validate()?;
1187        Ok(())
1188    }
1189}
1190
1191// TotalCharges81: Indicates whether the total charges amount is a credit or a debit amount.
1192// Usage: A zero amount is considered to be a credit.
1193#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1194pub struct TotalCharges81 {
1195    #[serde(rename = "NbOfChrgsBrkdwnItms")]
1196    pub nb_of_chrgs_brkdwn_itms: String,
1197    #[serde(rename = "TtlChrgsAmt")]
1198    pub ttl_chrgs_amt: CBPRAmount,
1199    #[serde(rename = "CdtDbtInd")]
1200    pub cdt_dbt_ind: CreditDebitCode1,
1201}
1202
1203impl TotalCharges81 {
1204    pub fn validate(&self) -> Result<(), ValidationError> {
1205        let pattern = Regex::new("[0-9]{1,15}").unwrap();
1206        if !pattern.is_match(&self.nb_of_chrgs_brkdwn_itms) {
1207            return Err(ValidationError::new(
1208                1005,
1209                "nb_of_chrgs_brkdwn_itms does not match the required pattern".to_string(),
1210            ));
1211        }
1212        self.ttl_chrgs_amt.validate()?;
1213        self.cdt_dbt_ind.validate()?;
1214        Ok(())
1215    }
1216}
1217
1218// TransactionReferences71: Identification of the securities transaction assigned by the processor of the instruction other than the securities account owner, the securities account servicer and the market infrastructure.
1219#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1220pub struct TransactionReferences71 {
1221    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
1222    pub msg_id: Option<String>,
1223    #[serde(rename = "MsgNmId", skip_serializing_if = "Option::is_none")]
1224    pub msg_nm_id: Option<String>,
1225    #[serde(rename = "AcctSvcrRef", skip_serializing_if = "Option::is_none")]
1226    pub acct_svcr_ref: Option<String>,
1227    #[serde(rename = "PmtInfId", skip_serializing_if = "Option::is_none")]
1228    pub pmt_inf_id: Option<String>,
1229    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
1230    pub instr_id: Option<String>,
1231    #[serde(rename = "EndToEndId", skip_serializing_if = "Option::is_none")]
1232    pub end_to_end_id: Option<String>,
1233    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
1234    pub uetr: Option<String>,
1235    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
1236    pub tx_id: Option<String>,
1237    #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
1238    pub mndt_id: Option<String>,
1239    #[serde(rename = "ChqNb", skip_serializing_if = "Option::is_none")]
1240    pub chq_nb: Option<String>,
1241    #[serde(rename = "AcctOwnrTxId", skip_serializing_if = "Option::is_none")]
1242    pub acct_ownr_tx_id: Option<String>,
1243    #[serde(rename = "AcctSvcrTxId", skip_serializing_if = "Option::is_none")]
1244    pub acct_svcr_tx_id: Option<String>,
1245    #[serde(rename = "PrcgId", skip_serializing_if = "Option::is_none")]
1246    pub prcg_id: Option<String>,
1247}
1248
1249impl TransactionReferences71 {
1250    pub fn validate(&self) -> Result<(), ValidationError> {
1251        if let Some(ref val) = self.msg_id {
1252            if val.chars().count() < 1 {
1253                return Err(ValidationError::new(
1254                    1001,
1255                    "msg_id is shorter than the minimum length of 1".to_string(),
1256                ));
1257            }
1258            if val.chars().count() > 35 {
1259                return Err(ValidationError::new(
1260                    1002,
1261                    "msg_id exceeds the maximum length of 35".to_string(),
1262                ));
1263            }
1264            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1265            if !pattern.is_match(val) {
1266                return Err(ValidationError::new(
1267                    1005,
1268                    "msg_id does not match the required pattern".to_string(),
1269                ));
1270            }
1271        }
1272        if let Some(ref val) = self.msg_nm_id {
1273            if val.chars().count() < 1 {
1274                return Err(ValidationError::new(
1275                    1001,
1276                    "msg_nm_id is shorter than the minimum length of 1".to_string(),
1277                ));
1278            }
1279            if val.chars().count() > 35 {
1280                return Err(ValidationError::new(
1281                    1002,
1282                    "msg_nm_id exceeds the maximum length of 35".to_string(),
1283                ));
1284            }
1285            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1286            if !pattern.is_match(val) {
1287                return Err(ValidationError::new(
1288                    1005,
1289                    "msg_nm_id does not match the required pattern".to_string(),
1290                ));
1291            }
1292        }
1293        if let Some(ref val) = self.acct_svcr_ref {
1294            if val.chars().count() < 1 {
1295                return Err(ValidationError::new(
1296                    1001,
1297                    "acct_svcr_ref is shorter than the minimum length of 1".to_string(),
1298                ));
1299            }
1300            if val.chars().count() > 35 {
1301                return Err(ValidationError::new(
1302                    1002,
1303                    "acct_svcr_ref exceeds the maximum length of 35".to_string(),
1304                ));
1305            }
1306            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1307            if !pattern.is_match(val) {
1308                return Err(ValidationError::new(
1309                    1005,
1310                    "acct_svcr_ref does not match the required pattern".to_string(),
1311                ));
1312            }
1313        }
1314        if let Some(ref val) = self.pmt_inf_id {
1315            if val.chars().count() < 1 {
1316                return Err(ValidationError::new(
1317                    1001,
1318                    "pmt_inf_id is shorter than the minimum length of 1".to_string(),
1319                ));
1320            }
1321            if val.chars().count() > 35 {
1322                return Err(ValidationError::new(
1323                    1002,
1324                    "pmt_inf_id exceeds the maximum length of 35".to_string(),
1325                ));
1326            }
1327            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1328            if !pattern.is_match(val) {
1329                return Err(ValidationError::new(
1330                    1005,
1331                    "pmt_inf_id does not match the required pattern".to_string(),
1332                ));
1333            }
1334        }
1335        if let Some(ref val) = self.instr_id {
1336            if val.chars().count() < 1 {
1337                return Err(ValidationError::new(
1338                    1001,
1339                    "instr_id is shorter than the minimum length of 1".to_string(),
1340                ));
1341            }
1342            if val.chars().count() > 16 {
1343                return Err(ValidationError::new(
1344                    1002,
1345                    "instr_id exceeds the maximum length of 16".to_string(),
1346                ));
1347            }
1348            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1349            if !pattern.is_match(val) {
1350                return Err(ValidationError::new(
1351                    1005,
1352                    "instr_id does not match the required pattern".to_string(),
1353                ));
1354            }
1355        }
1356        if let Some(ref val) = self.end_to_end_id {
1357            if val.chars().count() < 1 {
1358                return Err(ValidationError::new(
1359                    1001,
1360                    "end_to_end_id is shorter than the minimum length of 1".to_string(),
1361                ));
1362            }
1363            if val.chars().count() > 35 {
1364                return Err(ValidationError::new(
1365                    1002,
1366                    "end_to_end_id exceeds the maximum length of 35".to_string(),
1367                ));
1368            }
1369            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1370            if !pattern.is_match(val) {
1371                return Err(ValidationError::new(
1372                    1005,
1373                    "end_to_end_id does not match the required pattern".to_string(),
1374                ));
1375            }
1376        }
1377        if let Some(ref val) = self.uetr {
1378            let pattern =
1379                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
1380                    .unwrap();
1381            if !pattern.is_match(val) {
1382                return Err(ValidationError::new(
1383                    1005,
1384                    "uetr does not match the required pattern".to_string(),
1385                ));
1386            }
1387        }
1388        if let Some(ref val) = self.tx_id {
1389            if val.chars().count() < 1 {
1390                return Err(ValidationError::new(
1391                    1001,
1392                    "tx_id is shorter than the minimum length of 1".to_string(),
1393                ));
1394            }
1395            if val.chars().count() > 35 {
1396                return Err(ValidationError::new(
1397                    1002,
1398                    "tx_id exceeds the maximum length of 35".to_string(),
1399                ));
1400            }
1401            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1402            if !pattern.is_match(val) {
1403                return Err(ValidationError::new(
1404                    1005,
1405                    "tx_id does not match the required pattern".to_string(),
1406                ));
1407            }
1408        }
1409        if let Some(ref val) = self.mndt_id {
1410            if val.chars().count() < 1 {
1411                return Err(ValidationError::new(
1412                    1001,
1413                    "mndt_id is shorter than the minimum length of 1".to_string(),
1414                ));
1415            }
1416            if val.chars().count() > 35 {
1417                return Err(ValidationError::new(
1418                    1002,
1419                    "mndt_id exceeds the maximum length of 35".to_string(),
1420                ));
1421            }
1422            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1423            if !pattern.is_match(val) {
1424                return Err(ValidationError::new(
1425                    1005,
1426                    "mndt_id does not match the required pattern".to_string(),
1427                ));
1428            }
1429        }
1430        if let Some(ref val) = self.chq_nb {
1431            if val.chars().count() < 1 {
1432                return Err(ValidationError::new(
1433                    1001,
1434                    "chq_nb is shorter than the minimum length of 1".to_string(),
1435                ));
1436            }
1437            if val.chars().count() > 35 {
1438                return Err(ValidationError::new(
1439                    1002,
1440                    "chq_nb exceeds the maximum length of 35".to_string(),
1441                ));
1442            }
1443            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1444            if !pattern.is_match(val) {
1445                return Err(ValidationError::new(
1446                    1005,
1447                    "chq_nb does not match the required pattern".to_string(),
1448                ));
1449            }
1450        }
1451        if let Some(ref val) = self.acct_ownr_tx_id {
1452            if val.chars().count() < 1 {
1453                return Err(ValidationError::new(
1454                    1001,
1455                    "acct_ownr_tx_id is shorter than the minimum length of 1".to_string(),
1456                ));
1457            }
1458            if val.chars().count() > 35 {
1459                return Err(ValidationError::new(
1460                    1002,
1461                    "acct_ownr_tx_id exceeds the maximum length of 35".to_string(),
1462                ));
1463            }
1464            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1465            if !pattern.is_match(val) {
1466                return Err(ValidationError::new(
1467                    1005,
1468                    "acct_ownr_tx_id does not match the required pattern".to_string(),
1469                ));
1470            }
1471        }
1472        if let Some(ref val) = self.acct_svcr_tx_id {
1473            if val.chars().count() < 1 {
1474                return Err(ValidationError::new(
1475                    1001,
1476                    "acct_svcr_tx_id is shorter than the minimum length of 1".to_string(),
1477                ));
1478            }
1479            if val.chars().count() > 35 {
1480                return Err(ValidationError::new(
1481                    1002,
1482                    "acct_svcr_tx_id exceeds the maximum length of 35".to_string(),
1483                ));
1484            }
1485            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1486            if !pattern.is_match(val) {
1487                return Err(ValidationError::new(
1488                    1005,
1489                    "acct_svcr_tx_id does not match the required pattern".to_string(),
1490                ));
1491            }
1492        }
1493        if let Some(ref val) = self.prcg_id {
1494            if val.chars().count() < 1 {
1495                return Err(ValidationError::new(
1496                    1001,
1497                    "prcg_id is shorter than the minimum length of 1".to_string(),
1498                ));
1499            }
1500            if val.chars().count() > 35 {
1501                return Err(ValidationError::new(
1502                    1002,
1503                    "prcg_id exceeds the maximum length of 35".to_string(),
1504                ));
1505            }
1506            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1507            if !pattern.is_match(val) {
1508                return Err(ValidationError::new(
1509                    1005,
1510                    "prcg_id does not match the required pattern".to_string(),
1511                ));
1512            }
1513        }
1514        Ok(())
1515    }
1516}