mx_message/
common.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
20#![allow(unused_imports)]
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24#[derive(Debug)]
25pub struct ValidationError {
26    pub code: u32,
27    pub message: String,
28}
29
30impl ValidationError {
31    pub fn new(code: u32, message: String) -> Self {
32        ValidationError { code, message }
33    }
34}
35// AccountIdentification4Choice ...
36#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
37pub struct AccountIdentification4Choice {
38    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
39    pub iban: Option<String>,
40    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
41    pub othr: Option<GenericAccountIdentification1>,
42}
43
44impl AccountIdentification4Choice {
45    pub fn validate(&self) -> Result<(), ValidationError> {
46        if let Some(ref val) = self.iban {
47            let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
48            if !pattern.is_match(val) {
49                return Err(ValidationError::new(
50                    1005,
51                    "iban does not match the required pattern".to_string(),
52                ));
53            }
54        }
55        if let Some(ref val) = self.othr {
56            val.validate()?
57        }
58        Ok(())
59    }
60}
61// AccountInterest4 ...
62#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
63pub struct AccountInterest4 {
64    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
65    pub tp: Option<InterestType1Choice>,
66    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
67    pub rate: Option<Vec<Rate4>>,
68    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
69    pub fr_to_dt: Option<DateTimePeriod1>,
70    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
71    pub rsn: Option<String>,
72    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
73    pub tax: Option<TaxCharges2>,
74}
75
76impl AccountInterest4 {
77    pub fn validate(&self) -> Result<(), ValidationError> {
78        if let Some(ref val) = self.tp {
79            val.validate()?
80        }
81        if let Some(ref vec) = self.rate {
82            for item in vec {
83                item.validate()?
84            }
85        }
86        if let Some(ref val) = self.fr_to_dt {
87            val.validate()?
88        }
89        if let Some(ref val) = self.rsn {
90            if val.chars().count() < 1 {
91                return Err(ValidationError::new(
92                    1001,
93                    "rsn is shorter than the minimum length of 1".to_string(),
94                ));
95            }
96            if val.chars().count() > 35 {
97                return Err(ValidationError::new(
98                    1002,
99                    "rsn exceeds the maximum length of 35".to_string(),
100                ));
101            }
102        }
103        if let Some(ref val) = self.tax {
104            val.validate()?
105        }
106        Ok(())
107    }
108}
109// AccountSchemeName1Choice ...
110#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
111pub struct AccountSchemeName1Choice {
112    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
113    pub cd: Option<String>,
114    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
115    pub prtry: Option<String>,
116}
117
118impl AccountSchemeName1Choice {
119    pub fn validate(&self) -> Result<(), ValidationError> {
120        if let Some(ref val) = self.cd {
121            if val.chars().count() < 1 {
122                return Err(ValidationError::new(
123                    1001,
124                    "cd is shorter than the minimum length of 1".to_string(),
125                ));
126            }
127            if val.chars().count() > 4 {
128                return Err(ValidationError::new(
129                    1002,
130                    "cd exceeds the maximum length of 4".to_string(),
131                ));
132            }
133        }
134        if let Some(ref val) = self.prtry {
135            if val.chars().count() < 1 {
136                return Err(ValidationError::new(
137                    1001,
138                    "prtry is shorter than the minimum length of 1".to_string(),
139                ));
140            }
141            if val.chars().count() > 35 {
142                return Err(ValidationError::new(
143                    1002,
144                    "prtry exceeds the maximum length of 35".to_string(),
145                ));
146            }
147        }
148        Ok(())
149    }
150}
151// ActiveCurrencyAndAmount ...
152#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
153pub struct ActiveCurrencyAndAmount {
154    #[serde(rename = "@Ccy")]
155    pub ccy: String,
156    #[serde(rename = "$value")]
157    pub value: f64,
158}
159
160impl ActiveCurrencyAndAmount {
161    pub fn validate(&self) -> Result<(), ValidationError> {
162        Ok(())
163    }
164}
165// ActiveOrHistoricCurrencyAnd13DecimalAmount ...
166#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
167pub struct ActiveOrHistoricCurrencyAnd13DecimalAmount {
168    #[serde(rename = "@Ccy")]
169    pub ccy: String,
170    #[serde(rename = "$value")]
171    pub value: f64,
172}
173
174impl ActiveOrHistoricCurrencyAnd13DecimalAmount {
175    pub fn validate(&self) -> Result<(), ValidationError> {
176        Ok(())
177    }
178}
179// ActiveOrHistoricCurrencyAndAmount ...
180#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
181pub struct ActiveOrHistoricCurrencyAndAmount {
182    #[serde(rename = "@Ccy")]
183    pub ccy: String,
184    #[serde(rename = "$value")]
185    pub value: f64,
186}
187
188impl ActiveOrHistoricCurrencyAndAmount {
189    pub fn validate(&self) -> Result<(), ValidationError> {
190        Ok(())
191    }
192}
193// ActiveOrHistoricCurrencyAndAmountRange2 ...
194#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
195pub struct ActiveOrHistoricCurrencyAndAmountRange2 {
196    #[serde(rename = "Amt")]
197    pub amt: ImpliedCurrencyAmountRange1Choice,
198    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
199    pub cdt_dbt_ind: Option<CreditDebitCode>,
200    #[serde(rename = "Ccy")]
201    pub ccy: String,
202}
203
204impl ActiveOrHistoricCurrencyAndAmountRange2 {
205    pub fn validate(&self) -> Result<(), ValidationError> {
206        self.amt.validate()?;
207        if let Some(ref val) = self.cdt_dbt_ind {
208            val.validate()?
209        }
210        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
211        if !pattern.is_match(&self.ccy) {
212            return Err(ValidationError::new(
213                1005,
214                "ccy does not match the required pattern".to_string(),
215            ));
216        }
217        Ok(())
218    }
219}
220// AddressType2Code ...
221#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
222pub enum AddressType2Code {
223    #[default]
224    #[serde(rename = "ADDR")]
225    CodeADDR,
226    #[serde(rename = "PBOX")]
227    CodePBOX,
228    #[serde(rename = "HOME")]
229    CodeHOME,
230    #[serde(rename = "BIZZ")]
231    CodeBIZZ,
232    #[serde(rename = "MLTO")]
233    CodeMLTO,
234    #[serde(rename = "DLVY")]
235    CodeDLVY,
236}
237
238impl AddressType2Code {
239    pub fn validate(&self) -> Result<(), ValidationError> {
240        Ok(())
241    }
242}
243// AddressType3Choice ...
244#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
245pub struct AddressType3Choice {
246    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
247    pub cd: Option<AddressType2Code>,
248    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
249    pub prtry: Option<GenericIdentification30>,
250}
251
252impl AddressType3Choice {
253    pub fn validate(&self) -> Result<(), ValidationError> {
254        if let Some(ref val) = self.cd {
255            val.validate()?
256        }
257        if let Some(ref val) = self.prtry {
258            val.validate()?
259        }
260        Ok(())
261    }
262}
263// AmendmentInformationDetails13 ...
264#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
265pub struct AmendmentInformationDetails13 {
266    #[serde(rename = "OrgnlMndtId", skip_serializing_if = "Option::is_none")]
267    pub orgnl_mndt_id: Option<String>,
268    #[serde(rename = "OrgnlCdtrSchmeId", skip_serializing_if = "Option::is_none")]
269    pub orgnl_cdtr_schme_id: Option<PartyIdentification135>,
270    #[serde(rename = "OrgnlCdtrAgt", skip_serializing_if = "Option::is_none")]
271    pub orgnl_cdtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
272    #[serde(rename = "OrgnlCdtrAgtAcct", skip_serializing_if = "Option::is_none")]
273    pub orgnl_cdtr_agt_acct: Option<CashAccount38>,
274    #[serde(rename = "OrgnlDbtr", skip_serializing_if = "Option::is_none")]
275    pub orgnl_dbtr: Option<PartyIdentification135>,
276    #[serde(rename = "OrgnlDbtrAcct", skip_serializing_if = "Option::is_none")]
277    pub orgnl_dbtr_acct: Option<CashAccount38>,
278    #[serde(rename = "OrgnlDbtrAgt", skip_serializing_if = "Option::is_none")]
279    pub orgnl_dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
280    #[serde(rename = "OrgnlDbtrAgtAcct", skip_serializing_if = "Option::is_none")]
281    pub orgnl_dbtr_agt_acct: Option<CashAccount38>,
282    #[serde(rename = "OrgnlFnlColltnDt", skip_serializing_if = "Option::is_none")]
283    pub orgnl_fnl_colltn_dt: Option<String>,
284    #[serde(rename = "OrgnlFrqcy", skip_serializing_if = "Option::is_none")]
285    pub orgnl_frqcy: Option<Frequency36Choice>,
286    #[serde(rename = "OrgnlRsn", skip_serializing_if = "Option::is_none")]
287    pub orgnl_rsn: Option<MandateSetupReason1Choice>,
288    #[serde(rename = "OrgnlTrckgDays", skip_serializing_if = "Option::is_none")]
289    pub orgnl_trckg_days: Option<String>,
290}
291
292impl AmendmentInformationDetails13 {
293    pub fn validate(&self) -> Result<(), ValidationError> {
294        if let Some(ref val) = self.orgnl_mndt_id {
295            if val.chars().count() < 1 {
296                return Err(ValidationError::new(
297                    1001,
298                    "orgnl_mndt_id is shorter than the minimum length of 1".to_string(),
299                ));
300            }
301            if val.chars().count() > 35 {
302                return Err(ValidationError::new(
303                    1002,
304                    "orgnl_mndt_id exceeds the maximum length of 35".to_string(),
305                ));
306            }
307        }
308        if let Some(ref val) = self.orgnl_cdtr_schme_id {
309            val.validate()?
310        }
311        if let Some(ref val) = self.orgnl_cdtr_agt {
312            val.validate()?
313        }
314        if let Some(ref val) = self.orgnl_cdtr_agt_acct {
315            val.validate()?
316        }
317        if let Some(ref val) = self.orgnl_dbtr {
318            val.validate()?
319        }
320        if let Some(ref val) = self.orgnl_dbtr_acct {
321            val.validate()?
322        }
323        if let Some(ref val) = self.orgnl_dbtr_agt {
324            val.validate()?
325        }
326        if let Some(ref val) = self.orgnl_dbtr_agt_acct {
327            val.validate()?
328        }
329        if let Some(ref val) = self.orgnl_frqcy {
330            val.validate()?
331        }
332        if let Some(ref val) = self.orgnl_rsn {
333            val.validate()?
334        }
335        if let Some(ref val) = self.orgnl_trckg_days {
336            let pattern = Regex::new("[0-9]{2}").unwrap();
337            if !pattern.is_match(val) {
338                return Err(ValidationError::new(
339                    1005,
340                    "orgnl_trckg_days does not match the required pattern".to_string(),
341                ));
342            }
343        }
344        Ok(())
345    }
346}
347// AmountAndCurrencyExchange3 ...
348#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
349pub struct AmountAndCurrencyExchange3 {
350    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
351    pub instd_amt: Option<AmountAndCurrencyExchangeDetails3>,
352    #[serde(rename = "TxAmt", skip_serializing_if = "Option::is_none")]
353    pub tx_amt: Option<AmountAndCurrencyExchangeDetails3>,
354    #[serde(rename = "CntrValAmt", skip_serializing_if = "Option::is_none")]
355    pub cntr_val_amt: Option<AmountAndCurrencyExchangeDetails3>,
356    #[serde(rename = "AnncdPstngAmt", skip_serializing_if = "Option::is_none")]
357    pub anncd_pstng_amt: Option<AmountAndCurrencyExchangeDetails3>,
358    #[serde(rename = "PrtryAmt", skip_serializing_if = "Option::is_none")]
359    pub prtry_amt: Option<Vec<AmountAndCurrencyExchangeDetails4>>,
360}
361
362impl AmountAndCurrencyExchange3 {
363    pub fn validate(&self) -> Result<(), ValidationError> {
364        if let Some(ref val) = self.instd_amt {
365            val.validate()?
366        }
367        if let Some(ref val) = self.tx_amt {
368            val.validate()?
369        }
370        if let Some(ref val) = self.cntr_val_amt {
371            val.validate()?
372        }
373        if let Some(ref val) = self.anncd_pstng_amt {
374            val.validate()?
375        }
376        if let Some(ref vec) = self.prtry_amt {
377            for item in vec {
378                item.validate()?
379            }
380        }
381        Ok(())
382    }
383}
384// AmountAndCurrencyExchangeDetails3 ...
385#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
386pub struct AmountAndCurrencyExchangeDetails3 {
387    #[serde(rename = "Amt")]
388    pub amt: ActiveOrHistoricCurrencyAndAmount,
389    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
390    pub ccy_xchg: Option<CurrencyExchange5>,
391}
392
393impl AmountAndCurrencyExchangeDetails3 {
394    pub fn validate(&self) -> Result<(), ValidationError> {
395        self.amt.validate()?;
396        if let Some(ref val) = self.ccy_xchg {
397            val.validate()?
398        }
399        Ok(())
400    }
401}
402// AmountAndCurrencyExchangeDetails4 ...
403#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
404pub struct AmountAndCurrencyExchangeDetails4 {
405    #[serde(rename = "Tp")]
406    pub tp: String,
407    #[serde(rename = "Amt")]
408    pub amt: ActiveOrHistoricCurrencyAndAmount,
409    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
410    pub ccy_xchg: Option<CurrencyExchange5>,
411}
412
413impl AmountAndCurrencyExchangeDetails4 {
414    pub fn validate(&self) -> Result<(), ValidationError> {
415        if self.tp.chars().count() < 1 {
416            return Err(ValidationError::new(
417                1001,
418                "tp is shorter than the minimum length of 1".to_string(),
419            ));
420        }
421        if self.tp.chars().count() > 35 {
422            return Err(ValidationError::new(
423                1002,
424                "tp exceeds the maximum length of 35".to_string(),
425            ));
426        }
427        self.amt.validate()?;
428        if let Some(ref val) = self.ccy_xchg {
429            val.validate()?
430        }
431        Ok(())
432    }
433}
434// AmountAndDirection35 ...
435#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
436pub struct AmountAndDirection35 {
437    #[serde(rename = "Amt")]
438    pub amt: f64,
439    #[serde(rename = "CdtDbtInd")]
440    pub cdt_dbt_ind: CreditDebitCode,
441}
442
443impl AmountAndDirection35 {
444    pub fn validate(&self) -> Result<(), ValidationError> {
445        if self.amt < 0.000000 {
446            return Err(ValidationError::new(
447                1003,
448                "amt is less than the minimum value of 0.000000".to_string(),
449            ));
450        }
451        self.cdt_dbt_ind.validate()?;
452        Ok(())
453    }
454}
455// AmountRangeBoundary1 ...
456#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
457pub struct AmountRangeBoundary1 {
458    #[serde(rename = "BdryAmt")]
459    pub bdry_amt: f64,
460    #[serde(rename = "Incl")]
461    pub incl: bool,
462}
463
464impl AmountRangeBoundary1 {
465    pub fn validate(&self) -> Result<(), ValidationError> {
466        if self.bdry_amt < 0.000000 {
467            return Err(ValidationError::new(
468                1003,
469                "bdry_amt is less than the minimum value of 0.000000".to_string(),
470            ));
471        }
472        Ok(())
473    }
474}
475// AmountType4Choice ...
476#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
477pub struct AmountType4Choice {
478    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
479    pub instd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
480    #[serde(rename = "EqvtAmt", skip_serializing_if = "Option::is_none")]
481    pub eqvt_amt: Option<EquivalentAmount2>,
482}
483
484impl AmountType4Choice {
485    pub fn validate(&self) -> Result<(), ValidationError> {
486        if let Some(ref val) = self.instd_amt {
487            val.validate()?
488        }
489        if let Some(ref val) = self.eqvt_amt {
490            val.validate()?
491        }
492        Ok(())
493    }
494}
495// AttendanceContext1Code ...
496#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
497pub enum AttendanceContext1Code {
498    #[default]
499    #[serde(rename = "ATTD")]
500    CodeATTD,
501    #[serde(rename = "SATT")]
502    CodeSATT,
503    #[serde(rename = "UATT")]
504    CodeUATT,
505}
506
507impl AttendanceContext1Code {
508    pub fn validate(&self) -> Result<(), ValidationError> {
509        Ok(())
510    }
511}
512// AuthenticationEntity1Code ...
513#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
514pub enum AuthenticationEntity1Code {
515    #[default]
516    #[serde(rename = "ICCD")]
517    CodeICCD,
518    #[serde(rename = "AGNT")]
519    CodeAGNT,
520    #[serde(rename = "MERC")]
521    CodeMERC,
522}
523
524impl AuthenticationEntity1Code {
525    pub fn validate(&self) -> Result<(), ValidationError> {
526        Ok(())
527    }
528}
529// AuthenticationMethod1Code ...
530#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
531pub enum AuthenticationMethod1Code {
532    #[default]
533    #[serde(rename = "UKNW")]
534    CodeUKNW,
535    #[serde(rename = "BYPS")]
536    CodeBYPS,
537    #[serde(rename = "NPIN")]
538    CodeNPIN,
539    #[serde(rename = "FPIN")]
540    CodeFPIN,
541    #[serde(rename = "CPSG")]
542    CodeCPSG,
543    #[serde(rename = "PPSG")]
544    CodePPSG,
545    #[serde(rename = "MANU")]
546    CodeMANU,
547    #[serde(rename = "MERC")]
548    CodeMERC,
549    #[serde(rename = "SCRT")]
550    CodeSCRT,
551    #[serde(rename = "SNCT")]
552    CodeSNCT,
553    #[serde(rename = "SCNL")]
554    CodeSCNL,
555}
556
557impl AuthenticationMethod1Code {
558    pub fn validate(&self) -> Result<(), ValidationError> {
559        Ok(())
560    }
561}
562// BalanceSubType1Choice ...
563#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
564pub struct BalanceSubType1Choice {
565    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
566    pub cd: Option<String>,
567    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
568    pub prtry: Option<String>,
569}
570
571impl BalanceSubType1Choice {
572    pub fn validate(&self) -> Result<(), ValidationError> {
573        if let Some(ref val) = self.cd {
574            if val.chars().count() < 1 {
575                return Err(ValidationError::new(
576                    1001,
577                    "cd is shorter than the minimum length of 1".to_string(),
578                ));
579            }
580            if val.chars().count() > 4 {
581                return Err(ValidationError::new(
582                    1002,
583                    "cd exceeds the maximum length of 4".to_string(),
584                ));
585            }
586        }
587        if let Some(ref val) = self.prtry {
588            if val.chars().count() < 1 {
589                return Err(ValidationError::new(
590                    1001,
591                    "prtry is shorter than the minimum length of 1".to_string(),
592                ));
593            }
594            if val.chars().count() > 35 {
595                return Err(ValidationError::new(
596                    1002,
597                    "prtry exceeds the maximum length of 35".to_string(),
598                ));
599            }
600        }
601        Ok(())
602    }
603}
604// BalanceType10Choice ...
605#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
606pub struct BalanceType10Choice {
607    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
608    pub cd: Option<String>,
609    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
610    pub prtry: Option<String>,
611}
612
613impl BalanceType10Choice {
614    pub fn validate(&self) -> Result<(), ValidationError> {
615        if let Some(ref val) = self.cd {
616            if val.chars().count() < 1 {
617                return Err(ValidationError::new(
618                    1001,
619                    "cd is shorter than the minimum length of 1".to_string(),
620                ));
621            }
622            if val.chars().count() > 4 {
623                return Err(ValidationError::new(
624                    1002,
625                    "cd exceeds the maximum length of 4".to_string(),
626                ));
627            }
628        }
629        if let Some(ref val) = self.prtry {
630            if val.chars().count() < 1 {
631                return Err(ValidationError::new(
632                    1001,
633                    "prtry is shorter than the minimum length of 1".to_string(),
634                ));
635            }
636            if val.chars().count() > 35 {
637                return Err(ValidationError::new(
638                    1002,
639                    "prtry exceeds the maximum length of 35".to_string(),
640                ));
641            }
642        }
643        Ok(())
644    }
645}
646// BalanceType13 ...
647#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
648pub struct BalanceType13 {
649    #[serde(rename = "CdOrPrtry")]
650    pub cd_or_prtry: BalanceType10Choice,
651    #[serde(rename = "SubTp", skip_serializing_if = "Option::is_none")]
652    pub sub_tp: Option<BalanceSubType1Choice>,
653}
654
655impl BalanceType13 {
656    pub fn validate(&self) -> Result<(), ValidationError> {
657        self.cd_or_prtry.validate()?;
658        if let Some(ref val) = self.sub_tp {
659            val.validate()?
660        }
661        Ok(())
662    }
663}
664// BankTransactionCodeStructure4 ...
665#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
666pub struct BankTransactionCodeStructure4 {
667    #[serde(rename = "Domn", skip_serializing_if = "Option::is_none")]
668    pub domn: Option<BankTransactionCodeStructure5>,
669    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
670    pub prtry: Option<ProprietaryBankTransactionCodeStructure1>,
671}
672
673impl BankTransactionCodeStructure4 {
674    pub fn validate(&self) -> Result<(), ValidationError> {
675        if let Some(ref val) = self.domn {
676            val.validate()?
677        }
678        if let Some(ref val) = self.prtry {
679            val.validate()?
680        }
681        Ok(())
682    }
683}
684// BankTransactionCodeStructure5 ...
685#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
686pub struct BankTransactionCodeStructure5 {
687    #[serde(rename = "Cd")]
688    pub cd: String,
689    #[serde(rename = "Fmly")]
690    pub fmly: BankTransactionCodeStructure6,
691}
692
693impl BankTransactionCodeStructure5 {
694    pub fn validate(&self) -> Result<(), ValidationError> {
695        if self.cd.chars().count() < 1 {
696            return Err(ValidationError::new(
697                1001,
698                "cd is shorter than the minimum length of 1".to_string(),
699            ));
700        }
701        if self.cd.chars().count() > 4 {
702            return Err(ValidationError::new(
703                1002,
704                "cd exceeds the maximum length of 4".to_string(),
705            ));
706        }
707        self.fmly.validate()?;
708        Ok(())
709    }
710}
711// BankTransactionCodeStructure6 ...
712#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
713pub struct BankTransactionCodeStructure6 {
714    #[serde(rename = "Cd")]
715    pub cd: String,
716    #[serde(rename = "SubFmlyCd")]
717    pub sub_fmly_cd: String,
718}
719
720impl BankTransactionCodeStructure6 {
721    pub fn validate(&self) -> Result<(), ValidationError> {
722        if self.cd.chars().count() < 1 {
723            return Err(ValidationError::new(
724                1001,
725                "cd is shorter than the minimum length of 1".to_string(),
726            ));
727        }
728        if self.cd.chars().count() > 4 {
729            return Err(ValidationError::new(
730                1002,
731                "cd exceeds the maximum length of 4".to_string(),
732            ));
733        }
734        if self.sub_fmly_cd.chars().count() < 1 {
735            return Err(ValidationError::new(
736                1001,
737                "sub_fmly_cd is shorter than the minimum length of 1".to_string(),
738            ));
739        }
740        if self.sub_fmly_cd.chars().count() > 4 {
741            return Err(ValidationError::new(
742                1002,
743                "sub_fmly_cd exceeds the maximum length of 4".to_string(),
744            ));
745        }
746        Ok(())
747    }
748}
749// BatchInformation2 ...
750#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
751pub struct BatchInformation2 {
752    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
753    pub msg_id: Option<String>,
754    #[serde(rename = "PmtInfId", skip_serializing_if = "Option::is_none")]
755    pub pmt_inf_id: Option<String>,
756    #[serde(rename = "NbOfTxs", skip_serializing_if = "Option::is_none")]
757    pub nb_of_txs: Option<String>,
758    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
759    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
760    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
761    pub cdt_dbt_ind: Option<CreditDebitCode>,
762}
763
764impl BatchInformation2 {
765    pub fn validate(&self) -> Result<(), ValidationError> {
766        if let Some(ref val) = self.msg_id {
767            if val.chars().count() < 1 {
768                return Err(ValidationError::new(
769                    1001,
770                    "msg_id is shorter than the minimum length of 1".to_string(),
771                ));
772            }
773            if val.chars().count() > 35 {
774                return Err(ValidationError::new(
775                    1002,
776                    "msg_id exceeds the maximum length of 35".to_string(),
777                ));
778            }
779        }
780        if let Some(ref val) = self.pmt_inf_id {
781            if val.chars().count() < 1 {
782                return Err(ValidationError::new(
783                    1001,
784                    "pmt_inf_id is shorter than the minimum length of 1".to_string(),
785                ));
786            }
787            if val.chars().count() > 35 {
788                return Err(ValidationError::new(
789                    1002,
790                    "pmt_inf_id exceeds the maximum length of 35".to_string(),
791                ));
792            }
793        }
794        if let Some(ref val) = self.nb_of_txs {
795            let pattern = Regex::new("[0-9]{1,15}").unwrap();
796            if !pattern.is_match(val) {
797                return Err(ValidationError::new(
798                    1005,
799                    "nb_of_txs does not match the required pattern".to_string(),
800                ));
801            }
802        }
803        if let Some(ref val) = self.ttl_amt {
804            val.validate()?
805        }
806        if let Some(ref val) = self.cdt_dbt_ind {
807            val.validate()?
808        }
809        Ok(())
810    }
811}
812// BranchAndFinancialInstitutionIdentification6 ...
813#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
814pub struct BranchAndFinancialInstitutionIdentification6 {
815    #[serde(rename = "FinInstnId")]
816    pub fin_instn_id: FinancialInstitutionIdentification18,
817    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
818    pub brnch_id: Option<BranchData3>,
819}
820
821impl BranchAndFinancialInstitutionIdentification6 {
822    pub fn validate(&self) -> Result<(), ValidationError> {
823        self.fin_instn_id.validate()?;
824        if let Some(ref val) = self.brnch_id {
825            val.validate()?
826        }
827        Ok(())
828    }
829}
830// BranchData3 ...
831#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
832pub struct BranchData3 {
833    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
834    pub id: Option<String>,
835    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
836    pub lei: Option<String>,
837    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
838    pub nm: Option<String>,
839    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
840    pub pstl_adr: Option<PostalAddress24>,
841}
842
843impl BranchData3 {
844    pub fn validate(&self) -> Result<(), ValidationError> {
845        if let Some(ref val) = self.id {
846            if val.chars().count() < 1 {
847                return Err(ValidationError::new(
848                    1001,
849                    "id is shorter than the minimum length of 1".to_string(),
850                ));
851            }
852            if val.chars().count() > 35 {
853                return Err(ValidationError::new(
854                    1002,
855                    "id exceeds the maximum length of 35".to_string(),
856                ));
857            }
858        }
859        if let Some(ref val) = self.lei {
860            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
861            if !pattern.is_match(val) {
862                return Err(ValidationError::new(
863                    1005,
864                    "lei does not match the required pattern".to_string(),
865                ));
866            }
867        }
868        if let Some(ref val) = self.nm {
869            if val.chars().count() < 1 {
870                return Err(ValidationError::new(
871                    1001,
872                    "nm is shorter than the minimum length of 1".to_string(),
873                ));
874            }
875            if val.chars().count() > 140 {
876                return Err(ValidationError::new(
877                    1002,
878                    "nm exceeds the maximum length of 140".to_string(),
879                ));
880            }
881        }
882        if let Some(ref val) = self.pstl_adr {
883            val.validate()?
884        }
885        Ok(())
886    }
887}
888// CSCManagement1Code ...
889#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
890pub enum CSCManagement1Code {
891    #[default]
892    #[serde(rename = "PRST")]
893    CodePRST,
894    #[serde(rename = "BYPS")]
895    CodeBYPS,
896    #[serde(rename = "UNRD")]
897    CodeUNRD,
898    #[serde(rename = "NCSC")]
899    CodeNCSC,
900}
901
902impl CSCManagement1Code {
903    pub fn validate(&self) -> Result<(), ValidationError> {
904        Ok(())
905    }
906}
907// CardAggregated2 ...
908#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
909pub struct CardAggregated2 {
910    #[serde(rename = "AddtlSvc", skip_serializing_if = "Option::is_none")]
911    pub addtl_svc: Option<CardPaymentServiceType2Code>,
912    #[serde(rename = "TxCtgy", skip_serializing_if = "Option::is_none")]
913    pub tx_ctgy: Option<String>,
914    #[serde(rename = "SaleRcncltnId", skip_serializing_if = "Option::is_none")]
915    pub sale_rcncltn_id: Option<String>,
916    #[serde(rename = "SeqNbRg", skip_serializing_if = "Option::is_none")]
917    pub seq_nb_rg: Option<CardSequenceNumberRange1>,
918    #[serde(rename = "TxDtRg", skip_serializing_if = "Option::is_none")]
919    pub tx_dt_rg: Option<DateOrDateTimePeriod1Choice>,
920}
921
922impl CardAggregated2 {
923    pub fn validate(&self) -> Result<(), ValidationError> {
924        if let Some(ref val) = self.addtl_svc {
925            val.validate()?
926        }
927        if let Some(ref val) = self.tx_ctgy {
928            if val.chars().count() < 1 {
929                return Err(ValidationError::new(
930                    1001,
931                    "tx_ctgy is shorter than the minimum length of 1".to_string(),
932                ));
933            }
934            if val.chars().count() > 4 {
935                return Err(ValidationError::new(
936                    1002,
937                    "tx_ctgy exceeds the maximum length of 4".to_string(),
938                ));
939            }
940        }
941        if let Some(ref val) = self.sale_rcncltn_id {
942            if val.chars().count() < 1 {
943                return Err(ValidationError::new(
944                    1001,
945                    "sale_rcncltn_id is shorter than the minimum length of 1".to_string(),
946                ));
947            }
948            if val.chars().count() > 35 {
949                return Err(ValidationError::new(
950                    1002,
951                    "sale_rcncltn_id exceeds the maximum length of 35".to_string(),
952                ));
953            }
954        }
955        if let Some(ref val) = self.seq_nb_rg {
956            val.validate()?
957        }
958        if let Some(ref val) = self.tx_dt_rg {
959            val.validate()?
960        }
961        Ok(())
962    }
963}
964// CardDataReading1Code ...
965#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
966pub enum CardDataReading1Code {
967    #[default]
968    #[serde(rename = "TAGC")]
969    CodeTAGC,
970    #[serde(rename = "PHYS")]
971    CodePHYS,
972    #[serde(rename = "BRCD")]
973    CodeBRCD,
974    #[serde(rename = "MGST")]
975    CodeMGST,
976    #[serde(rename = "CICC")]
977    CodeCICC,
978    #[serde(rename = "DFLE")]
979    CodeDFLE,
980    #[serde(rename = "CTLS")]
981    CodeCTLS,
982    #[serde(rename = "ECTL")]
983    CodeECTL,
984}
985
986impl CardDataReading1Code {
987    pub fn validate(&self) -> Result<(), ValidationError> {
988        Ok(())
989    }
990}
991// CardEntry4 ...
992#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
993pub struct CardEntry4 {
994    #[serde(rename = "Card", skip_serializing_if = "Option::is_none")]
995    pub card: Option<PaymentCard4>,
996    #[serde(rename = "POI", skip_serializing_if = "Option::is_none")]
997    pub poi: Option<PointOfInteraction1>,
998    #[serde(rename = "AggtdNtry", skip_serializing_if = "Option::is_none")]
999    pub aggtd_ntry: Option<CardAggregated2>,
1000    #[serde(rename = "PrePdAcct", skip_serializing_if = "Option::is_none")]
1001    pub pre_pd_acct: Option<CashAccount38>,
1002}
1003
1004impl CardEntry4 {
1005    pub fn validate(&self) -> Result<(), ValidationError> {
1006        if let Some(ref val) = self.card {
1007            val.validate()?
1008        }
1009        if let Some(ref val) = self.poi {
1010            val.validate()?
1011        }
1012        if let Some(ref val) = self.aggtd_ntry {
1013            val.validate()?
1014        }
1015        if let Some(ref val) = self.pre_pd_acct {
1016            val.validate()?
1017        }
1018        Ok(())
1019    }
1020}
1021// CardIndividualTransaction2 ...
1022#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1023pub struct CardIndividualTransaction2 {
1024    #[serde(rename = "ICCRltdData", skip_serializing_if = "Option::is_none")]
1025    pub icc_rltd_data: Option<String>,
1026    #[serde(rename = "PmtCntxt", skip_serializing_if = "Option::is_none")]
1027    pub pmt_cntxt: Option<PaymentContext3>,
1028    #[serde(rename = "AddtlSvc", skip_serializing_if = "Option::is_none")]
1029    pub addtl_svc: Option<CardPaymentServiceType2Code>,
1030    #[serde(rename = "TxCtgy", skip_serializing_if = "Option::is_none")]
1031    pub tx_ctgy: Option<String>,
1032    #[serde(rename = "SaleRcncltnId", skip_serializing_if = "Option::is_none")]
1033    pub sale_rcncltn_id: Option<String>,
1034    #[serde(rename = "SaleRefNb", skip_serializing_if = "Option::is_none")]
1035    pub sale_ref_nb: Option<String>,
1036    #[serde(rename = "RePresntmntRsn", skip_serializing_if = "Option::is_none")]
1037    pub re_presntmnt_rsn: Option<String>,
1038    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
1039    pub seq_nb: Option<String>,
1040    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
1041    pub tx_id: Option<TransactionIdentifier1>,
1042    #[serde(rename = "Pdct", skip_serializing_if = "Option::is_none")]
1043    pub pdct: Option<Product2>,
1044    #[serde(rename = "VldtnDt", skip_serializing_if = "Option::is_none")]
1045    pub vldtn_dt: Option<String>,
1046    #[serde(rename = "VldtnSeqNb", skip_serializing_if = "Option::is_none")]
1047    pub vldtn_seq_nb: Option<String>,
1048}
1049
1050impl CardIndividualTransaction2 {
1051    pub fn validate(&self) -> Result<(), ValidationError> {
1052        if let Some(ref val) = self.icc_rltd_data {
1053            if val.chars().count() < 1 {
1054                return Err(ValidationError::new(
1055                    1001,
1056                    "icc_rltd_data is shorter than the minimum length of 1".to_string(),
1057                ));
1058            }
1059            if val.chars().count() > 1025 {
1060                return Err(ValidationError::new(
1061                    1002,
1062                    "icc_rltd_data exceeds the maximum length of 1025".to_string(),
1063                ));
1064            }
1065        }
1066        if let Some(ref val) = self.pmt_cntxt {
1067            val.validate()?
1068        }
1069        if let Some(ref val) = self.addtl_svc {
1070            val.validate()?
1071        }
1072        if let Some(ref val) = self.tx_ctgy {
1073            if val.chars().count() < 1 {
1074                return Err(ValidationError::new(
1075                    1001,
1076                    "tx_ctgy is shorter than the minimum length of 1".to_string(),
1077                ));
1078            }
1079            if val.chars().count() > 4 {
1080                return Err(ValidationError::new(
1081                    1002,
1082                    "tx_ctgy exceeds the maximum length of 4".to_string(),
1083                ));
1084            }
1085        }
1086        if let Some(ref val) = self.sale_rcncltn_id {
1087            if val.chars().count() < 1 {
1088                return Err(ValidationError::new(
1089                    1001,
1090                    "sale_rcncltn_id is shorter than the minimum length of 1".to_string(),
1091                ));
1092            }
1093            if val.chars().count() > 35 {
1094                return Err(ValidationError::new(
1095                    1002,
1096                    "sale_rcncltn_id exceeds the maximum length of 35".to_string(),
1097                ));
1098            }
1099        }
1100        if let Some(ref val) = self.sale_ref_nb {
1101            if val.chars().count() < 1 {
1102                return Err(ValidationError::new(
1103                    1001,
1104                    "sale_ref_nb is shorter than the minimum length of 1".to_string(),
1105                ));
1106            }
1107            if val.chars().count() > 35 {
1108                return Err(ValidationError::new(
1109                    1002,
1110                    "sale_ref_nb exceeds the maximum length of 35".to_string(),
1111                ));
1112            }
1113        }
1114        if let Some(ref val) = self.re_presntmnt_rsn {
1115            if val.chars().count() < 1 {
1116                return Err(ValidationError::new(
1117                    1001,
1118                    "re_presntmnt_rsn is shorter than the minimum length of 1".to_string(),
1119                ));
1120            }
1121            if val.chars().count() > 4 {
1122                return Err(ValidationError::new(
1123                    1002,
1124                    "re_presntmnt_rsn exceeds the maximum length of 4".to_string(),
1125                ));
1126            }
1127        }
1128        if let Some(ref val) = self.seq_nb {
1129            if val.chars().count() < 1 {
1130                return Err(ValidationError::new(
1131                    1001,
1132                    "seq_nb is shorter than the minimum length of 1".to_string(),
1133                ));
1134            }
1135            if val.chars().count() > 35 {
1136                return Err(ValidationError::new(
1137                    1002,
1138                    "seq_nb exceeds the maximum length of 35".to_string(),
1139                ));
1140            }
1141        }
1142        if let Some(ref val) = self.tx_id {
1143            val.validate()?
1144        }
1145        if let Some(ref val) = self.pdct {
1146            val.validate()?
1147        }
1148        if let Some(ref val) = self.vldtn_seq_nb {
1149            if val.chars().count() < 1 {
1150                return Err(ValidationError::new(
1151                    1001,
1152                    "vldtn_seq_nb is shorter than the minimum length of 1".to_string(),
1153                ));
1154            }
1155            if val.chars().count() > 35 {
1156                return Err(ValidationError::new(
1157                    1002,
1158                    "vldtn_seq_nb exceeds the maximum length of 35".to_string(),
1159                ));
1160            }
1161        }
1162        Ok(())
1163    }
1164}
1165// CardPaymentServiceType2Code ...
1166#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1167pub enum CardPaymentServiceType2Code {
1168    #[default]
1169    #[serde(rename = "AGGR")]
1170    CodeAGGR,
1171    #[serde(rename = "DCCV")]
1172    CodeDCCV,
1173    #[serde(rename = "GRTT")]
1174    CodeGRTT,
1175    #[serde(rename = "INSP")]
1176    CodeINSP,
1177    #[serde(rename = "LOYT")]
1178    CodeLOYT,
1179    #[serde(rename = "NRES")]
1180    CodeNRES,
1181    #[serde(rename = "PUCO")]
1182    CodePUCO,
1183    #[serde(rename = "RECP")]
1184    CodeRECP,
1185    #[serde(rename = "SOAF")]
1186    CodeSOAF,
1187    #[serde(rename = "UNAF")]
1188    CodeUNAF,
1189    #[serde(rename = "VCAU")]
1190    CodeVCAU,
1191}
1192
1193impl CardPaymentServiceType2Code {
1194    pub fn validate(&self) -> Result<(), ValidationError> {
1195        Ok(())
1196    }
1197}
1198// CardSecurityInformation1 ...
1199#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1200pub struct CardSecurityInformation1 {
1201    #[serde(rename = "CSCMgmt")]
1202    pub csc_mgmt: CSCManagement1Code,
1203    #[serde(rename = "CSCVal", skip_serializing_if = "Option::is_none")]
1204    pub csc_val: Option<String>,
1205}
1206
1207impl CardSecurityInformation1 {
1208    pub fn validate(&self) -> Result<(), ValidationError> {
1209        self.csc_mgmt.validate()?;
1210        if let Some(ref val) = self.csc_val {
1211            let pattern = Regex::new("[0-9]{3,4}").unwrap();
1212            if !pattern.is_match(val) {
1213                return Err(ValidationError::new(
1214                    1005,
1215                    "csc_val does not match the required pattern".to_string(),
1216                ));
1217            }
1218        }
1219        Ok(())
1220    }
1221}
1222// CardSequenceNumberRange1 ...
1223#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1224pub struct CardSequenceNumberRange1 {
1225    #[serde(rename = "FrstTx", skip_serializing_if = "Option::is_none")]
1226    pub frst_tx: Option<String>,
1227    #[serde(rename = "LastTx", skip_serializing_if = "Option::is_none")]
1228    pub last_tx: Option<String>,
1229}
1230
1231impl CardSequenceNumberRange1 {
1232    pub fn validate(&self) -> Result<(), ValidationError> {
1233        if let Some(ref val) = self.frst_tx {
1234            if val.chars().count() < 1 {
1235                return Err(ValidationError::new(
1236                    1001,
1237                    "frst_tx is shorter than the minimum length of 1".to_string(),
1238                ));
1239            }
1240            if val.chars().count() > 35 {
1241                return Err(ValidationError::new(
1242                    1002,
1243                    "frst_tx exceeds the maximum length of 35".to_string(),
1244                ));
1245            }
1246        }
1247        if let Some(ref val) = self.last_tx {
1248            if val.chars().count() < 1 {
1249                return Err(ValidationError::new(
1250                    1001,
1251                    "last_tx is shorter than the minimum length of 1".to_string(),
1252                ));
1253            }
1254            if val.chars().count() > 35 {
1255                return Err(ValidationError::new(
1256                    1002,
1257                    "last_tx exceeds the maximum length of 35".to_string(),
1258                ));
1259            }
1260        }
1261        Ok(())
1262    }
1263}
1264// CardTransaction17 ...
1265#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1266pub struct CardTransaction17 {
1267    #[serde(rename = "Card", skip_serializing_if = "Option::is_none")]
1268    pub card: Option<PaymentCard4>,
1269    #[serde(rename = "POI", skip_serializing_if = "Option::is_none")]
1270    pub poi: Option<PointOfInteraction1>,
1271    #[serde(rename = "Tx", skip_serializing_if = "Option::is_none")]
1272    pub tx: Option<CardTransaction3Choice>,
1273    #[serde(rename = "PrePdAcct", skip_serializing_if = "Option::is_none")]
1274    pub pre_pd_acct: Option<CashAccount38>,
1275}
1276
1277impl CardTransaction17 {
1278    pub fn validate(&self) -> Result<(), ValidationError> {
1279        if let Some(ref val) = self.card {
1280            val.validate()?
1281        }
1282        if let Some(ref val) = self.poi {
1283            val.validate()?
1284        }
1285        if let Some(ref val) = self.tx {
1286            val.validate()?
1287        }
1288        if let Some(ref val) = self.pre_pd_acct {
1289            val.validate()?
1290        }
1291        Ok(())
1292    }
1293}
1294// CardTransaction3Choice ...
1295#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1296pub struct CardTransaction3Choice {
1297    #[serde(rename = "Aggtd", skip_serializing_if = "Option::is_none")]
1298    pub aggtd: Option<CardAggregated2>,
1299    #[serde(rename = "Indv", skip_serializing_if = "Option::is_none")]
1300    pub indv: Option<CardIndividualTransaction2>,
1301}
1302
1303impl CardTransaction3Choice {
1304    pub fn validate(&self) -> Result<(), ValidationError> {
1305        if let Some(ref val) = self.aggtd {
1306            val.validate()?
1307        }
1308        if let Some(ref val) = self.indv {
1309            val.validate()?
1310        }
1311        Ok(())
1312    }
1313}
1314// CardholderAuthentication2 ...
1315#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1316pub struct CardholderAuthentication2 {
1317    #[serde(rename = "AuthntcnMtd")]
1318    pub authntcn_mtd: AuthenticationMethod1Code,
1319    #[serde(rename = "AuthntcnNtty")]
1320    pub authntcn_ntty: AuthenticationEntity1Code,
1321}
1322
1323impl CardholderAuthentication2 {
1324    pub fn validate(&self) -> Result<(), ValidationError> {
1325        self.authntcn_mtd.validate()?;
1326        self.authntcn_ntty.validate()?;
1327        Ok(())
1328    }
1329}
1330// CardholderVerificationCapability1Code ...
1331#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1332pub enum CardholderVerificationCapability1Code {
1333    #[default]
1334    #[serde(rename = "MNSG")]
1335    CodeMNSG,
1336    #[serde(rename = "NPIN")]
1337    CodeNPIN,
1338    #[serde(rename = "FCPN")]
1339    CodeFCPN,
1340    #[serde(rename = "FEPN")]
1341    CodeFEPN,
1342    #[serde(rename = "FDSG")]
1343    CodeFDSG,
1344    #[serde(rename = "FBIO")]
1345    CodeFBIO,
1346    #[serde(rename = "MNVR")]
1347    CodeMNVR,
1348    #[serde(rename = "FBIG")]
1349    CodeFBIG,
1350    #[serde(rename = "APKI")]
1351    CodeAPKI,
1352    #[serde(rename = "PKIS")]
1353    CodePKIS,
1354    #[serde(rename = "CHDT")]
1355    CodeCHDT,
1356    #[serde(rename = "SCEC")]
1357    CodeSCEC,
1358}
1359
1360impl CardholderVerificationCapability1Code {
1361    pub fn validate(&self) -> Result<(), ValidationError> {
1362        Ok(())
1363    }
1364}
1365// Case5 ...
1366#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1367pub struct Case5 {
1368    #[serde(rename = "Id")]
1369    pub id: String,
1370    #[serde(rename = "Cretr")]
1371    pub cretr: Party40Choice,
1372    #[serde(rename = "ReopCaseIndctn", skip_serializing_if = "Option::is_none")]
1373    pub reop_case_indctn: Option<bool>,
1374}
1375
1376impl Case5 {
1377    pub fn validate(&self) -> Result<(), ValidationError> {
1378        if self.id.chars().count() < 1 {
1379            return Err(ValidationError::new(
1380                1001,
1381                "id is shorter than the minimum length of 1".to_string(),
1382            ));
1383        }
1384        if self.id.chars().count() > 35 {
1385            return Err(ValidationError::new(
1386                1002,
1387                "id exceeds the maximum length of 35".to_string(),
1388            ));
1389        }
1390        self.cretr.validate()?;
1391        Ok(())
1392    }
1393}
1394// CaseAssignment5 ...
1395#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1396pub struct CaseAssignment5 {
1397    #[serde(rename = "Id")]
1398    pub id: String,
1399    #[serde(rename = "Assgnr")]
1400    pub assgnr: Party40Choice,
1401    #[serde(rename = "Assgne")]
1402    pub assgne: Party40Choice,
1403    #[serde(rename = "CreDtTm")]
1404    pub cre_dt_tm: String,
1405}
1406
1407impl CaseAssignment5 {
1408    pub fn validate(&self) -> Result<(), ValidationError> {
1409        if self.id.chars().count() < 1 {
1410            return Err(ValidationError::new(
1411                1001,
1412                "id is shorter than the minimum length of 1".to_string(),
1413            ));
1414        }
1415        if self.id.chars().count() > 35 {
1416            return Err(ValidationError::new(
1417                1002,
1418                "id exceeds the maximum length of 35".to_string(),
1419            ));
1420        }
1421        self.assgnr.validate()?;
1422        self.assgne.validate()?;
1423        Ok(())
1424    }
1425}
1426// CashAccount38 ...
1427#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1428pub struct CashAccount38 {
1429    #[serde(rename = "Id")]
1430    pub id: AccountIdentification4Choice,
1431    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1432    pub tp: Option<CashAccountType2Choice>,
1433    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
1434    pub ccy: Option<String>,
1435    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1436    pub nm: Option<String>,
1437    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1438    pub prxy: Option<ProxyAccountIdentification1>,
1439}
1440
1441impl CashAccount38 {
1442    pub fn validate(&self) -> Result<(), ValidationError> {
1443        self.id.validate()?;
1444        if let Some(ref val) = self.tp {
1445            val.validate()?
1446        }
1447        if let Some(ref val) = self.ccy {
1448            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1449            if !pattern.is_match(val) {
1450                return Err(ValidationError::new(
1451                    1005,
1452                    "ccy does not match the required pattern".to_string(),
1453                ));
1454            }
1455        }
1456        if let Some(ref val) = self.nm {
1457            if val.chars().count() < 1 {
1458                return Err(ValidationError::new(
1459                    1001,
1460                    "nm is shorter than the minimum length of 1".to_string(),
1461                ));
1462            }
1463            if val.chars().count() > 70 {
1464                return Err(ValidationError::new(
1465                    1002,
1466                    "nm exceeds the maximum length of 70".to_string(),
1467                ));
1468            }
1469        }
1470        if let Some(ref val) = self.prxy {
1471            val.validate()?
1472        }
1473        Ok(())
1474    }
1475}
1476// CashAccount39 ...
1477#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1478pub struct CashAccount39 {
1479    #[serde(rename = "Id")]
1480    pub id: AccountIdentification4Choice,
1481    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1482    pub tp: Option<CashAccountType2Choice>,
1483    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
1484    pub ccy: Option<String>,
1485    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1486    pub nm: Option<String>,
1487    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1488    pub prxy: Option<ProxyAccountIdentification1>,
1489    #[serde(rename = "Ownr", skip_serializing_if = "Option::is_none")]
1490    pub ownr: Option<PartyIdentification135>,
1491    #[serde(rename = "Svcr", skip_serializing_if = "Option::is_none")]
1492    pub svcr: Option<BranchAndFinancialInstitutionIdentification6>,
1493}
1494
1495impl CashAccount39 {
1496    pub fn validate(&self) -> Result<(), ValidationError> {
1497        self.id.validate()?;
1498        if let Some(ref val) = self.tp {
1499            val.validate()?
1500        }
1501        if let Some(ref val) = self.ccy {
1502            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1503            if !pattern.is_match(val) {
1504                return Err(ValidationError::new(
1505                    1005,
1506                    "ccy does not match the required pattern".to_string(),
1507                ));
1508            }
1509        }
1510        if let Some(ref val) = self.nm {
1511            if val.chars().count() < 1 {
1512                return Err(ValidationError::new(
1513                    1001,
1514                    "nm is shorter than the minimum length of 1".to_string(),
1515                ));
1516            }
1517            if val.chars().count() > 70 {
1518                return Err(ValidationError::new(
1519                    1002,
1520                    "nm exceeds the maximum length of 70".to_string(),
1521                ));
1522            }
1523        }
1524        if let Some(ref val) = self.prxy {
1525            val.validate()?
1526        }
1527        if let Some(ref val) = self.ownr {
1528            val.validate()?
1529        }
1530        if let Some(ref val) = self.svcr {
1531            val.validate()?
1532        }
1533        Ok(())
1534    }
1535}
1536// CashAccountType2Choice ...
1537#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1538pub struct CashAccountType2Choice {
1539    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1540    pub cd: Option<String>,
1541    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1542    pub prtry: Option<String>,
1543}
1544
1545impl CashAccountType2Choice {
1546    pub fn validate(&self) -> Result<(), ValidationError> {
1547        if let Some(ref val) = self.cd {
1548            if val.chars().count() < 1 {
1549                return Err(ValidationError::new(
1550                    1001,
1551                    "cd is shorter than the minimum length of 1".to_string(),
1552                ));
1553            }
1554            if val.chars().count() > 4 {
1555                return Err(ValidationError::new(
1556                    1002,
1557                    "cd exceeds the maximum length of 4".to_string(),
1558                ));
1559            }
1560        }
1561        if let Some(ref val) = self.prtry {
1562            if val.chars().count() < 1 {
1563                return Err(ValidationError::new(
1564                    1001,
1565                    "prtry is shorter than the minimum length of 1".to_string(),
1566                ));
1567            }
1568            if val.chars().count() > 35 {
1569                return Err(ValidationError::new(
1570                    1002,
1571                    "prtry exceeds the maximum length of 35".to_string(),
1572                ));
1573            }
1574        }
1575        Ok(())
1576    }
1577}
1578// CashAvailability1 ...
1579#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1580pub struct CashAvailability1 {
1581    #[serde(rename = "Dt")]
1582    pub dt: CashAvailabilityDate1Choice,
1583    #[serde(rename = "Amt")]
1584    pub amt: ActiveOrHistoricCurrencyAndAmount,
1585    #[serde(rename = "CdtDbtInd")]
1586    pub cdt_dbt_ind: CreditDebitCode,
1587}
1588
1589impl CashAvailability1 {
1590    pub fn validate(&self) -> Result<(), ValidationError> {
1591        self.dt.validate()?;
1592        self.amt.validate()?;
1593        self.cdt_dbt_ind.validate()?;
1594        Ok(())
1595    }
1596}
1597// CashAvailabilityDate1Choice ...
1598#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1599pub struct CashAvailabilityDate1Choice {
1600    #[serde(rename = "NbOfDays", skip_serializing_if = "Option::is_none")]
1601    pub nb_of_days: Option<String>,
1602    #[serde(rename = "ActlDt", skip_serializing_if = "Option::is_none")]
1603    pub actl_dt: Option<String>,
1604}
1605
1606impl CashAvailabilityDate1Choice {
1607    pub fn validate(&self) -> Result<(), ValidationError> {
1608        if let Some(ref val) = self.nb_of_days {
1609            let pattern = Regex::new("[\\+]{0,1}[0-9]{1,15}").unwrap();
1610            if !pattern.is_match(val) {
1611                return Err(ValidationError::new(
1612                    1005,
1613                    "nb_of_days does not match the required pattern".to_string(),
1614                ));
1615            }
1616        }
1617        Ok(())
1618    }
1619}
1620// CashBalance8 ...
1621#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1622pub struct CashBalance8 {
1623    #[serde(rename = "Tp")]
1624    pub tp: BalanceType13,
1625    #[serde(rename = "CdtLine", skip_serializing_if = "Option::is_none")]
1626    pub cdt_line: Option<Vec<CreditLine3>>,
1627    #[serde(rename = "Amt")]
1628    pub amt: ActiveOrHistoricCurrencyAndAmount,
1629    #[serde(rename = "CdtDbtInd")]
1630    pub cdt_dbt_ind: CreditDebitCode,
1631    #[serde(rename = "Dt")]
1632    pub dt: DateAndDateTime2Choice,
1633    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
1634    pub avlbty: Option<Vec<CashAvailability1>>,
1635}
1636
1637impl CashBalance8 {
1638    pub fn validate(&self) -> Result<(), ValidationError> {
1639        self.tp.validate()?;
1640        if let Some(ref vec) = self.cdt_line {
1641            for item in vec {
1642                item.validate()?
1643            }
1644        }
1645        self.amt.validate()?;
1646        self.cdt_dbt_ind.validate()?;
1647        self.dt.validate()?;
1648        if let Some(ref vec) = self.avlbty {
1649            for item in vec {
1650                item.validate()?
1651            }
1652        }
1653        Ok(())
1654    }
1655}
1656// CashDeposit1 ...
1657#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1658pub struct CashDeposit1 {
1659    #[serde(rename = "NoteDnmtn")]
1660    pub note_dnmtn: ActiveCurrencyAndAmount,
1661    #[serde(rename = "NbOfNotes")]
1662    pub nb_of_notes: String,
1663    #[serde(rename = "Amt")]
1664    pub amt: ActiveCurrencyAndAmount,
1665}
1666
1667impl CashDeposit1 {
1668    pub fn validate(&self) -> Result<(), ValidationError> {
1669        self.note_dnmtn.validate()?;
1670        let pattern = Regex::new("[0-9]{1,15}").unwrap();
1671        if !pattern.is_match(&self.nb_of_notes) {
1672            return Err(ValidationError::new(
1673                1005,
1674                "nb_of_notes does not match the required pattern".to_string(),
1675            ));
1676        }
1677        self.amt.validate()?;
1678        Ok(())
1679    }
1680}
1681// CategoryPurpose1Choice ...
1682#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1683pub struct CategoryPurpose1Choice {
1684    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1685    pub cd: Option<String>,
1686    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1687    pub prtry: Option<String>,
1688}
1689
1690impl CategoryPurpose1Choice {
1691    pub fn validate(&self) -> Result<(), ValidationError> {
1692        if let Some(ref val) = self.cd {
1693            if val.chars().count() < 1 {
1694                return Err(ValidationError::new(
1695                    1001,
1696                    "cd is shorter than the minimum length of 1".to_string(),
1697                ));
1698            }
1699            if val.chars().count() > 4 {
1700                return Err(ValidationError::new(
1701                    1002,
1702                    "cd exceeds the maximum length of 4".to_string(),
1703                ));
1704            }
1705        }
1706        if let Some(ref val) = self.prtry {
1707            if val.chars().count() < 1 {
1708                return Err(ValidationError::new(
1709                    1001,
1710                    "prtry is shorter than the minimum length of 1".to_string(),
1711                ));
1712            }
1713            if val.chars().count() > 35 {
1714                return Err(ValidationError::new(
1715                    1002,
1716                    "prtry exceeds the maximum length of 35".to_string(),
1717                ));
1718            }
1719        }
1720        Ok(())
1721    }
1722}
1723// ChargeBearerType1Code ...
1724#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1725pub enum ChargeBearerType1Code {
1726    #[default]
1727    #[serde(rename = "DEBT")]
1728    CodeDEBT,
1729    #[serde(rename = "CRED")]
1730    CodeCRED,
1731    #[serde(rename = "SHAR")]
1732    CodeSHAR,
1733    #[serde(rename = "SLEV")]
1734    CodeSLEV,
1735}
1736
1737impl ChargeBearerType1Code {
1738    pub fn validate(&self) -> Result<(), ValidationError> {
1739        Ok(())
1740    }
1741}
1742// ChargeType3Choice ...
1743#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1744pub struct ChargeType3Choice {
1745    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1746    pub cd: Option<String>,
1747    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1748    pub prtry: Option<GenericIdentification3>,
1749}
1750
1751impl ChargeType3Choice {
1752    pub fn validate(&self) -> Result<(), ValidationError> {
1753        if let Some(ref val) = self.cd {
1754            if val.chars().count() < 1 {
1755                return Err(ValidationError::new(
1756                    1001,
1757                    "cd is shorter than the minimum length of 1".to_string(),
1758                ));
1759            }
1760            if val.chars().count() > 4 {
1761                return Err(ValidationError::new(
1762                    1002,
1763                    "cd exceeds the maximum length of 4".to_string(),
1764                ));
1765            }
1766        }
1767        if let Some(ref val) = self.prtry {
1768            val.validate()?
1769        }
1770        Ok(())
1771    }
1772}
1773// Charges6 ...
1774#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1775pub struct Charges6 {
1776    #[serde(rename = "TtlChrgsAndTaxAmt", skip_serializing_if = "Option::is_none")]
1777    pub ttl_chrgs_and_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1778    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
1779    pub rcrd: Option<Vec<ChargesRecord3>>,
1780}
1781
1782impl Charges6 {
1783    pub fn validate(&self) -> Result<(), ValidationError> {
1784        if let Some(ref val) = self.ttl_chrgs_and_tax_amt {
1785            val.validate()?
1786        }
1787        if let Some(ref vec) = self.rcrd {
1788            for item in vec {
1789                item.validate()?
1790            }
1791        }
1792        Ok(())
1793    }
1794}
1795// Charges7 ...
1796#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1797pub struct Charges7 {
1798    #[serde(rename = "Amt")]
1799    pub amt: ActiveOrHistoricCurrencyAndAmount,
1800    #[serde(rename = "Agt")]
1801    pub agt: BranchAndFinancialInstitutionIdentification6,
1802}
1803
1804impl Charges7 {
1805    pub fn validate(&self) -> Result<(), ValidationError> {
1806        self.amt.validate()?;
1807        self.agt.validate()?;
1808        Ok(())
1809    }
1810}
1811// ChargesRecord3 ...
1812#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1813pub struct ChargesRecord3 {
1814    #[serde(rename = "Amt")]
1815    pub amt: ActiveOrHistoricCurrencyAndAmount,
1816    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1817    pub cdt_dbt_ind: Option<CreditDebitCode>,
1818    #[serde(rename = "ChrgInclInd", skip_serializing_if = "Option::is_none")]
1819    pub chrg_incl_ind: Option<bool>,
1820    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1821    pub tp: Option<ChargeType3Choice>,
1822    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
1823    pub rate: Option<f64>,
1824    #[serde(rename = "Br", skip_serializing_if = "Option::is_none")]
1825    pub br: Option<ChargeBearerType1Code>,
1826    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
1827    pub agt: Option<BranchAndFinancialInstitutionIdentification6>,
1828    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
1829    pub tax: Option<TaxCharges2>,
1830}
1831
1832impl ChargesRecord3 {
1833    pub fn validate(&self) -> Result<(), ValidationError> {
1834        self.amt.validate()?;
1835        if let Some(ref val) = self.cdt_dbt_ind {
1836            val.validate()?
1837        }
1838        if let Some(ref val) = self.tp {
1839            val.validate()?
1840        }
1841        if let Some(ref val) = self.br {
1842            val.validate()?
1843        }
1844        if let Some(ref val) = self.agt {
1845            val.validate()?
1846        }
1847        if let Some(ref val) = self.tax {
1848            val.validate()?
1849        }
1850        Ok(())
1851    }
1852}
1853// ClearingChannel2Code ...
1854#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1855pub enum ClearingChannel2Code {
1856    #[default]
1857    #[serde(rename = "RTGS")]
1858    CodeRTGS,
1859    #[serde(rename = "RTNS")]
1860    CodeRTNS,
1861    #[serde(rename = "MPNS")]
1862    CodeMPNS,
1863    #[serde(rename = "BOOK")]
1864    CodeBOOK,
1865}
1866
1867impl ClearingChannel2Code {
1868    pub fn validate(&self) -> Result<(), ValidationError> {
1869        Ok(())
1870    }
1871}
1872// ClearingSystemIdentification2Choice ...
1873#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1874pub struct ClearingSystemIdentification2Choice {
1875    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1876    pub cd: Option<String>,
1877    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1878    pub prtry: Option<String>,
1879}
1880
1881impl ClearingSystemIdentification2Choice {
1882    pub fn validate(&self) -> Result<(), ValidationError> {
1883        if let Some(ref val) = self.cd {
1884            if val.chars().count() < 1 {
1885                return Err(ValidationError::new(
1886                    1001,
1887                    "cd is shorter than the minimum length of 1".to_string(),
1888                ));
1889            }
1890            if val.chars().count() > 5 {
1891                return Err(ValidationError::new(
1892                    1002,
1893                    "cd exceeds the maximum length of 5".to_string(),
1894                ));
1895            }
1896        }
1897        if let Some(ref val) = self.prtry {
1898            if val.chars().count() < 1 {
1899                return Err(ValidationError::new(
1900                    1001,
1901                    "prtry is shorter than the minimum length of 1".to_string(),
1902                ));
1903            }
1904            if val.chars().count() > 35 {
1905                return Err(ValidationError::new(
1906                    1002,
1907                    "prtry exceeds the maximum length of 35".to_string(),
1908                ));
1909            }
1910        }
1911        Ok(())
1912    }
1913}
1914// ClearingSystemIdentification3Choice ...
1915#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1916pub struct ClearingSystemIdentification3Choice {
1917    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1918    pub cd: Option<String>,
1919    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1920    pub prtry: Option<String>,
1921}
1922
1923impl ClearingSystemIdentification3Choice {
1924    pub fn validate(&self) -> Result<(), ValidationError> {
1925        if let Some(ref val) = self.cd {
1926            if val.chars().count() < 1 {
1927                return Err(ValidationError::new(
1928                    1001,
1929                    "cd is shorter than the minimum length of 1".to_string(),
1930                ));
1931            }
1932            if val.chars().count() > 3 {
1933                return Err(ValidationError::new(
1934                    1002,
1935                    "cd exceeds the maximum length of 3".to_string(),
1936                ));
1937            }
1938        }
1939        if let Some(ref val) = self.prtry {
1940            if val.chars().count() < 1 {
1941                return Err(ValidationError::new(
1942                    1001,
1943                    "prtry is shorter than the minimum length of 1".to_string(),
1944                ));
1945            }
1946            if val.chars().count() > 35 {
1947                return Err(ValidationError::new(
1948                    1002,
1949                    "prtry exceeds the maximum length of 35".to_string(),
1950                ));
1951            }
1952        }
1953        Ok(())
1954    }
1955}
1956// ClearingSystemMemberIdentification2 ...
1957#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1958pub struct ClearingSystemMemberIdentification2 {
1959    #[serde(rename = "ClrSysId", skip_serializing_if = "Option::is_none")]
1960    pub clr_sys_id: Option<ClearingSystemIdentification2Choice>,
1961    #[serde(rename = "MmbId")]
1962    pub mmb_id: String,
1963}
1964
1965impl ClearingSystemMemberIdentification2 {
1966    pub fn validate(&self) -> Result<(), ValidationError> {
1967        if let Some(ref val) = self.clr_sys_id {
1968            val.validate()?
1969        }
1970        if self.mmb_id.chars().count() < 1 {
1971            return Err(ValidationError::new(
1972                1001,
1973                "mmb_id is shorter than the minimum length of 1".to_string(),
1974            ));
1975        }
1976        if self.mmb_id.chars().count() > 35 {
1977            return Err(ValidationError::new(
1978                1002,
1979                "mmb_id exceeds the maximum length of 35".to_string(),
1980            ));
1981        }
1982        Ok(())
1983    }
1984}
1985// Contact4 ...
1986#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1987pub struct Contact4 {
1988    #[serde(rename = "NmPrfx", skip_serializing_if = "Option::is_none")]
1989    pub nm_prfx: Option<NamePrefix2Code>,
1990    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1991    pub nm: Option<String>,
1992    #[serde(rename = "PhneNb", skip_serializing_if = "Option::is_none")]
1993    pub phne_nb: Option<String>,
1994    #[serde(rename = "MobNb", skip_serializing_if = "Option::is_none")]
1995    pub mob_nb: Option<String>,
1996    #[serde(rename = "FaxNb", skip_serializing_if = "Option::is_none")]
1997    pub fax_nb: Option<String>,
1998    #[serde(rename = "EmailAdr", skip_serializing_if = "Option::is_none")]
1999    pub email_adr: Option<String>,
2000    #[serde(rename = "EmailPurp", skip_serializing_if = "Option::is_none")]
2001    pub email_purp: Option<String>,
2002    #[serde(rename = "JobTitl", skip_serializing_if = "Option::is_none")]
2003    pub job_titl: Option<String>,
2004    #[serde(rename = "Rspnsblty", skip_serializing_if = "Option::is_none")]
2005    pub rspnsblty: Option<String>,
2006    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
2007    pub dept: Option<String>,
2008    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2009    pub othr: Option<Vec<OtherContact1>>,
2010    #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
2011    pub prefrd_mtd: Option<PreferredContactMethod1Code>,
2012}
2013
2014impl Contact4 {
2015    pub fn validate(&self) -> Result<(), ValidationError> {
2016        if let Some(ref val) = self.nm_prfx {
2017            val.validate()?
2018        }
2019        if let Some(ref val) = self.nm {
2020            if val.chars().count() < 1 {
2021                return Err(ValidationError::new(
2022                    1001,
2023                    "nm is shorter than the minimum length of 1".to_string(),
2024                ));
2025            }
2026            if val.chars().count() > 140 {
2027                return Err(ValidationError::new(
2028                    1002,
2029                    "nm exceeds the maximum length of 140".to_string(),
2030                ));
2031            }
2032        }
2033        if let Some(ref val) = self.phne_nb {
2034            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
2035            if !pattern.is_match(val) {
2036                return Err(ValidationError::new(
2037                    1005,
2038                    "phne_nb does not match the required pattern".to_string(),
2039                ));
2040            }
2041        }
2042        if let Some(ref val) = self.mob_nb {
2043            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
2044            if !pattern.is_match(val) {
2045                return Err(ValidationError::new(
2046                    1005,
2047                    "mob_nb does not match the required pattern".to_string(),
2048                ));
2049            }
2050        }
2051        if let Some(ref val) = self.fax_nb {
2052            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
2053            if !pattern.is_match(val) {
2054                return Err(ValidationError::new(
2055                    1005,
2056                    "fax_nb does not match the required pattern".to_string(),
2057                ));
2058            }
2059        }
2060        if let Some(ref val) = self.email_adr {
2061            if val.chars().count() < 1 {
2062                return Err(ValidationError::new(
2063                    1001,
2064                    "email_adr is shorter than the minimum length of 1".to_string(),
2065                ));
2066            }
2067            if val.chars().count() > 2048 {
2068                return Err(ValidationError::new(
2069                    1002,
2070                    "email_adr exceeds the maximum length of 2048".to_string(),
2071                ));
2072            }
2073        }
2074        if let Some(ref val) = self.email_purp {
2075            if val.chars().count() < 1 {
2076                return Err(ValidationError::new(
2077                    1001,
2078                    "email_purp is shorter than the minimum length of 1".to_string(),
2079                ));
2080            }
2081            if val.chars().count() > 35 {
2082                return Err(ValidationError::new(
2083                    1002,
2084                    "email_purp exceeds the maximum length of 35".to_string(),
2085                ));
2086            }
2087        }
2088        if let Some(ref val) = self.job_titl {
2089            if val.chars().count() < 1 {
2090                return Err(ValidationError::new(
2091                    1001,
2092                    "job_titl is shorter than the minimum length of 1".to_string(),
2093                ));
2094            }
2095            if val.chars().count() > 35 {
2096                return Err(ValidationError::new(
2097                    1002,
2098                    "job_titl exceeds the maximum length of 35".to_string(),
2099                ));
2100            }
2101        }
2102        if let Some(ref val) = self.rspnsblty {
2103            if val.chars().count() < 1 {
2104                return Err(ValidationError::new(
2105                    1001,
2106                    "rspnsblty is shorter than the minimum length of 1".to_string(),
2107                ));
2108            }
2109            if val.chars().count() > 35 {
2110                return Err(ValidationError::new(
2111                    1002,
2112                    "rspnsblty exceeds the maximum length of 35".to_string(),
2113                ));
2114            }
2115        }
2116        if let Some(ref val) = self.dept {
2117            if val.chars().count() < 1 {
2118                return Err(ValidationError::new(
2119                    1001,
2120                    "dept is shorter than the minimum length of 1".to_string(),
2121                ));
2122            }
2123            if val.chars().count() > 70 {
2124                return Err(ValidationError::new(
2125                    1002,
2126                    "dept exceeds the maximum length of 70".to_string(),
2127                ));
2128            }
2129        }
2130        if let Some(ref vec) = self.othr {
2131            for item in vec {
2132                item.validate()?
2133            }
2134        }
2135        if let Some(ref val) = self.prefrd_mtd {
2136            val.validate()?
2137        }
2138        Ok(())
2139    }
2140}
2141// CopyDuplicate1Code ...
2142#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2143pub enum CopyDuplicate1Code {
2144    #[default]
2145    #[serde(rename = "CODU")]
2146    CodeCODU,
2147    #[serde(rename = "COPY")]
2148    CodeCOPY,
2149    #[serde(rename = "DUPL")]
2150    CodeDUPL,
2151}
2152
2153impl CopyDuplicate1Code {
2154    pub fn validate(&self) -> Result<(), ValidationError> {
2155        Ok(())
2156    }
2157}
2158// CorporateAction9 ...
2159#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2160pub struct CorporateAction9 {
2161    #[serde(rename = "EvtTp")]
2162    pub evt_tp: String,
2163    #[serde(rename = "EvtId")]
2164    pub evt_id: String,
2165}
2166
2167impl CorporateAction9 {
2168    pub fn validate(&self) -> Result<(), ValidationError> {
2169        if self.evt_tp.chars().count() < 1 {
2170            return Err(ValidationError::new(
2171                1001,
2172                "evt_tp is shorter than the minimum length of 1".to_string(),
2173            ));
2174        }
2175        if self.evt_tp.chars().count() > 35 {
2176            return Err(ValidationError::new(
2177                1002,
2178                "evt_tp exceeds the maximum length of 35".to_string(),
2179            ));
2180        }
2181        if self.evt_id.chars().count() < 1 {
2182            return Err(ValidationError::new(
2183                1001,
2184                "evt_id is shorter than the minimum length of 1".to_string(),
2185            ));
2186        }
2187        if self.evt_id.chars().count() > 35 {
2188            return Err(ValidationError::new(
2189                1002,
2190                "evt_id exceeds the maximum length of 35".to_string(),
2191            ));
2192        }
2193        Ok(())
2194    }
2195}
2196// CreditDebitCode ...
2197#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2198pub enum CreditDebitCode {
2199    #[default]
2200    #[serde(rename = "CRDT")]
2201    CodeCRDT,
2202    #[serde(rename = "DBIT")]
2203    CodeDBIT,
2204}
2205
2206impl CreditDebitCode {
2207    pub fn validate(&self) -> Result<(), ValidationError> {
2208        Ok(())
2209    }
2210}
2211// CreditLine3 ...
2212#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2213pub struct CreditLine3 {
2214    #[serde(rename = "Incl")]
2215    pub incl: bool,
2216    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2217    pub tp: Option<CreditLineType1Choice>,
2218    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
2219    pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2220    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2221    pub dt: Option<DateAndDateTime2Choice>,
2222}
2223
2224impl CreditLine3 {
2225    pub fn validate(&self) -> Result<(), ValidationError> {
2226        if let Some(ref val) = self.tp {
2227            val.validate()?
2228        }
2229        if let Some(ref val) = self.amt {
2230            val.validate()?
2231        }
2232        if let Some(ref val) = self.dt {
2233            val.validate()?
2234        }
2235        Ok(())
2236    }
2237}
2238// CreditLineType1Choice ...
2239#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2240pub struct CreditLineType1Choice {
2241    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2242    pub cd: Option<String>,
2243    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2244    pub prtry: Option<String>,
2245}
2246
2247impl CreditLineType1Choice {
2248    pub fn validate(&self) -> Result<(), ValidationError> {
2249        if let Some(ref val) = self.cd {
2250            if val.chars().count() < 1 {
2251                return Err(ValidationError::new(
2252                    1001,
2253                    "cd is shorter than the minimum length of 1".to_string(),
2254                ));
2255            }
2256            if val.chars().count() > 4 {
2257                return Err(ValidationError::new(
2258                    1002,
2259                    "cd exceeds the maximum length of 4".to_string(),
2260                ));
2261            }
2262        }
2263        if let Some(ref val) = self.prtry {
2264            if val.chars().count() < 1 {
2265                return Err(ValidationError::new(
2266                    1001,
2267                    "prtry is shorter than the minimum length of 1".to_string(),
2268                ));
2269            }
2270            if val.chars().count() > 35 {
2271                return Err(ValidationError::new(
2272                    1002,
2273                    "prtry exceeds the maximum length of 35".to_string(),
2274                ));
2275            }
2276        }
2277        Ok(())
2278    }
2279}
2280// CreditorReferenceInformation2 ...
2281#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2282pub struct CreditorReferenceInformation2 {
2283    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2284    pub tp: Option<CreditorReferenceType2>,
2285    #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
2286    pub ref_attr: Option<String>,
2287}
2288
2289impl CreditorReferenceInformation2 {
2290    pub fn validate(&self) -> Result<(), ValidationError> {
2291        if let Some(ref val) = self.tp {
2292            val.validate()?
2293        }
2294        if let Some(ref val) = self.ref_attr {
2295            if val.chars().count() < 1 {
2296                return Err(ValidationError::new(
2297                    1001,
2298                    "ref_attr is shorter than the minimum length of 1".to_string(),
2299                ));
2300            }
2301            if val.chars().count() > 35 {
2302                return Err(ValidationError::new(
2303                    1002,
2304                    "ref_attr exceeds the maximum length of 35".to_string(),
2305                ));
2306            }
2307        }
2308        Ok(())
2309    }
2310}
2311// CreditorReferenceType1Choice ...
2312#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2313pub struct CreditorReferenceType1Choice {
2314    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2315    pub cd: Option<DocumentType3Code>,
2316    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2317    pub prtry: Option<String>,
2318}
2319
2320impl CreditorReferenceType1Choice {
2321    pub fn validate(&self) -> Result<(), ValidationError> {
2322        if let Some(ref val) = self.cd {
2323            val.validate()?
2324        }
2325        if let Some(ref val) = self.prtry {
2326            if val.chars().count() < 1 {
2327                return Err(ValidationError::new(
2328                    1001,
2329                    "prtry is shorter than the minimum length of 1".to_string(),
2330                ));
2331            }
2332            if val.chars().count() > 35 {
2333                return Err(ValidationError::new(
2334                    1002,
2335                    "prtry exceeds the maximum length of 35".to_string(),
2336                ));
2337            }
2338        }
2339        Ok(())
2340    }
2341}
2342// CreditorReferenceType2 ...
2343#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2344pub struct CreditorReferenceType2 {
2345    #[serde(rename = "CdOrPrtry")]
2346    pub cd_or_prtry: CreditorReferenceType1Choice,
2347    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2348    pub issr: Option<String>,
2349}
2350
2351impl CreditorReferenceType2 {
2352    pub fn validate(&self) -> Result<(), ValidationError> {
2353        self.cd_or_prtry.validate()?;
2354        if let Some(ref val) = self.issr {
2355            if val.chars().count() < 1 {
2356                return Err(ValidationError::new(
2357                    1001,
2358                    "issr is shorter than the minimum length of 1".to_string(),
2359                ));
2360            }
2361            if val.chars().count() > 35 {
2362                return Err(ValidationError::new(
2363                    1002,
2364                    "issr exceeds the maximum length of 35".to_string(),
2365                ));
2366            }
2367        }
2368        Ok(())
2369    }
2370}
2371// CurrencyExchange5 ...
2372#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2373pub struct CurrencyExchange5 {
2374    #[serde(rename = "SrcCcy")]
2375    pub src_ccy: String,
2376    #[serde(rename = "TrgtCcy", skip_serializing_if = "Option::is_none")]
2377    pub trgt_ccy: Option<String>,
2378    #[serde(rename = "UnitCcy", skip_serializing_if = "Option::is_none")]
2379    pub unit_ccy: Option<String>,
2380    #[serde(rename = "XchgRate")]
2381    pub xchg_rate: f64,
2382    #[serde(rename = "CtrctId", skip_serializing_if = "Option::is_none")]
2383    pub ctrct_id: Option<String>,
2384    #[serde(rename = "QtnDt", skip_serializing_if = "Option::is_none")]
2385    pub qtn_dt: Option<String>,
2386}
2387
2388impl CurrencyExchange5 {
2389    pub fn validate(&self) -> Result<(), ValidationError> {
2390        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2391        if !pattern.is_match(&self.src_ccy) {
2392            return Err(ValidationError::new(
2393                1005,
2394                "src_ccy does not match the required pattern".to_string(),
2395            ));
2396        }
2397        if let Some(ref val) = self.trgt_ccy {
2398            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2399            if !pattern.is_match(val) {
2400                return Err(ValidationError::new(
2401                    1005,
2402                    "trgt_ccy does not match the required pattern".to_string(),
2403                ));
2404            }
2405        }
2406        if let Some(ref val) = self.unit_ccy {
2407            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2408            if !pattern.is_match(val) {
2409                return Err(ValidationError::new(
2410                    1005,
2411                    "unit_ccy does not match the required pattern".to_string(),
2412                ));
2413            }
2414        }
2415        if let Some(ref val) = self.ctrct_id {
2416            if val.chars().count() < 1 {
2417                return Err(ValidationError::new(
2418                    1001,
2419                    "ctrct_id is shorter than the minimum length of 1".to_string(),
2420                ));
2421            }
2422            if val.chars().count() > 35 {
2423                return Err(ValidationError::new(
2424                    1002,
2425                    "ctrct_id exceeds the maximum length of 35".to_string(),
2426                ));
2427            }
2428        }
2429        Ok(())
2430    }
2431}
2432// DateAndDateTime2Choice ...
2433#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2434pub struct DateAndDateTime2Choice {
2435    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2436    pub dt: Option<String>,
2437    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
2438    pub dt_tm: Option<String>,
2439}
2440
2441impl DateAndDateTime2Choice {
2442    pub fn validate(&self) -> Result<(), ValidationError> {
2443        Ok(())
2444    }
2445}
2446// DateAndPlaceOfBirth1 ...
2447#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2448pub struct DateAndPlaceOfBirth1 {
2449    #[serde(rename = "BirthDt")]
2450    pub birth_dt: String,
2451    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
2452    pub prvc_of_birth: Option<String>,
2453    #[serde(rename = "CityOfBirth")]
2454    pub city_of_birth: String,
2455    #[serde(rename = "CtryOfBirth")]
2456    pub ctry_of_birth: String,
2457}
2458
2459impl DateAndPlaceOfBirth1 {
2460    pub fn validate(&self) -> Result<(), ValidationError> {
2461        if let Some(ref val) = self.prvc_of_birth {
2462            if val.chars().count() < 1 {
2463                return Err(ValidationError::new(
2464                    1001,
2465                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
2466                ));
2467            }
2468            if val.chars().count() > 35 {
2469                return Err(ValidationError::new(
2470                    1002,
2471                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
2472                ));
2473            }
2474        }
2475        if self.city_of_birth.chars().count() < 1 {
2476            return Err(ValidationError::new(
2477                1001,
2478                "city_of_birth is shorter than the minimum length of 1".to_string(),
2479            ));
2480        }
2481        if self.city_of_birth.chars().count() > 35 {
2482            return Err(ValidationError::new(
2483                1002,
2484                "city_of_birth exceeds the maximum length of 35".to_string(),
2485            ));
2486        }
2487        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2488        if !pattern.is_match(&self.ctry_of_birth) {
2489            return Err(ValidationError::new(
2490                1005,
2491                "ctry_of_birth does not match the required pattern".to_string(),
2492            ));
2493        }
2494        Ok(())
2495    }
2496}
2497// DateOrDateTimePeriod1Choice ...
2498#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2499pub struct DateOrDateTimePeriod1Choice {
2500    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2501    pub dt: Option<DatePeriod2>,
2502    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
2503    pub dt_tm: Option<DateTimePeriod1>,
2504}
2505
2506impl DateOrDateTimePeriod1Choice {
2507    pub fn validate(&self) -> Result<(), ValidationError> {
2508        if let Some(ref val) = self.dt {
2509            val.validate()?
2510        }
2511        if let Some(ref val) = self.dt_tm {
2512            val.validate()?
2513        }
2514        Ok(())
2515    }
2516}
2517// DatePeriod2 ...
2518#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2519pub struct DatePeriod2 {
2520    #[serde(rename = "FrDt")]
2521    pub fr_dt: String,
2522    #[serde(rename = "ToDt")]
2523    pub to_dt: String,
2524}
2525
2526impl DatePeriod2 {
2527    pub fn validate(&self) -> Result<(), ValidationError> {
2528        Ok(())
2529    }
2530}
2531// DateTimePeriod1 ...
2532#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2533pub struct DateTimePeriod1 {
2534    #[serde(rename = "FrDtTm")]
2535    pub fr_dt_tm: String,
2536    #[serde(rename = "ToDtTm")]
2537    pub to_dt_tm: String,
2538}
2539
2540impl DateTimePeriod1 {
2541    pub fn validate(&self) -> Result<(), ValidationError> {
2542        Ok(())
2543    }
2544}
2545// DiscountAmountAndType1 ...
2546#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2547pub struct DiscountAmountAndType1 {
2548    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2549    pub tp: Option<DiscountAmountType1Choice>,
2550    #[serde(rename = "Amt")]
2551    pub amt: ActiveOrHistoricCurrencyAndAmount,
2552}
2553
2554impl DiscountAmountAndType1 {
2555    pub fn validate(&self) -> Result<(), ValidationError> {
2556        if let Some(ref val) = self.tp {
2557            val.validate()?
2558        }
2559        self.amt.validate()?;
2560        Ok(())
2561    }
2562}
2563// DiscountAmountType1Choice ...
2564#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2565pub struct DiscountAmountType1Choice {
2566    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2567    pub cd: Option<String>,
2568    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2569    pub prtry: Option<String>,
2570}
2571
2572impl DiscountAmountType1Choice {
2573    pub fn validate(&self) -> Result<(), ValidationError> {
2574        if let Some(ref val) = self.cd {
2575            if val.chars().count() < 1 {
2576                return Err(ValidationError::new(
2577                    1001,
2578                    "cd is shorter than the minimum length of 1".to_string(),
2579                ));
2580            }
2581            if val.chars().count() > 4 {
2582                return Err(ValidationError::new(
2583                    1002,
2584                    "cd exceeds the maximum length of 4".to_string(),
2585                ));
2586            }
2587        }
2588        if let Some(ref val) = self.prtry {
2589            if val.chars().count() < 1 {
2590                return Err(ValidationError::new(
2591                    1001,
2592                    "prtry is shorter than the minimum length of 1".to_string(),
2593                ));
2594            }
2595            if val.chars().count() > 35 {
2596                return Err(ValidationError::new(
2597                    1002,
2598                    "prtry exceeds the maximum length of 35".to_string(),
2599                ));
2600            }
2601        }
2602        Ok(())
2603    }
2604}
2605// DisplayCapabilities1 ...
2606#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2607pub struct DisplayCapabilities1 {
2608    #[serde(rename = "DispTp")]
2609    pub disp_tp: UserInterface2Code,
2610    #[serde(rename = "NbOfLines")]
2611    pub nb_of_lines: String,
2612    #[serde(rename = "LineWidth")]
2613    pub line_width: String,
2614}
2615
2616impl DisplayCapabilities1 {
2617    pub fn validate(&self) -> Result<(), ValidationError> {
2618        self.disp_tp.validate()?;
2619        let pattern = Regex::new("[0-9]{1,3}").unwrap();
2620        if !pattern.is_match(&self.nb_of_lines) {
2621            return Err(ValidationError::new(
2622                1005,
2623                "nb_of_lines does not match the required pattern".to_string(),
2624            ));
2625        }
2626        let pattern = Regex::new("[0-9]{1,3}").unwrap();
2627        if !pattern.is_match(&self.line_width) {
2628            return Err(ValidationError::new(
2629                1005,
2630                "line_width does not match the required pattern".to_string(),
2631            ));
2632        }
2633        Ok(())
2634    }
2635}
2636// DocumentAdjustment1 ...
2637#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2638pub struct DocumentAdjustment1 {
2639    #[serde(rename = "Amt")]
2640    pub amt: ActiveOrHistoricCurrencyAndAmount,
2641    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
2642    pub cdt_dbt_ind: Option<CreditDebitCode>,
2643    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
2644    pub rsn: Option<String>,
2645    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
2646    pub addtl_inf: Option<String>,
2647}
2648
2649impl DocumentAdjustment1 {
2650    pub fn validate(&self) -> Result<(), ValidationError> {
2651        self.amt.validate()?;
2652        if let Some(ref val) = self.cdt_dbt_ind {
2653            val.validate()?
2654        }
2655        if let Some(ref val) = self.rsn {
2656            if val.chars().count() < 1 {
2657                return Err(ValidationError::new(
2658                    1001,
2659                    "rsn is shorter than the minimum length of 1".to_string(),
2660                ));
2661            }
2662            if val.chars().count() > 4 {
2663                return Err(ValidationError::new(
2664                    1002,
2665                    "rsn exceeds the maximum length of 4".to_string(),
2666                ));
2667            }
2668        }
2669        if let Some(ref val) = self.addtl_inf {
2670            if val.chars().count() < 1 {
2671                return Err(ValidationError::new(
2672                    1001,
2673                    "addtl_inf is shorter than the minimum length of 1".to_string(),
2674                ));
2675            }
2676            if val.chars().count() > 140 {
2677                return Err(ValidationError::new(
2678                    1002,
2679                    "addtl_inf exceeds the maximum length of 140".to_string(),
2680                ));
2681            }
2682        }
2683        Ok(())
2684    }
2685}
2686// DocumentLineIdentification1 ...
2687#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2688pub struct DocumentLineIdentification1 {
2689    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2690    pub tp: Option<DocumentLineType1>,
2691    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
2692    pub nb: Option<String>,
2693    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
2694    pub rltd_dt: Option<String>,
2695}
2696
2697impl DocumentLineIdentification1 {
2698    pub fn validate(&self) -> Result<(), ValidationError> {
2699        if let Some(ref val) = self.tp {
2700            val.validate()?
2701        }
2702        if let Some(ref val) = self.nb {
2703            if val.chars().count() < 1 {
2704                return Err(ValidationError::new(
2705                    1001,
2706                    "nb is shorter than the minimum length of 1".to_string(),
2707                ));
2708            }
2709            if val.chars().count() > 35 {
2710                return Err(ValidationError::new(
2711                    1002,
2712                    "nb exceeds the maximum length of 35".to_string(),
2713                ));
2714            }
2715        }
2716        Ok(())
2717    }
2718}
2719// DocumentLineInformation1 ...
2720#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2721pub struct DocumentLineInformation1 {
2722    #[serde(rename = "Id")]
2723    pub id: Vec<DocumentLineIdentification1>,
2724    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
2725    pub desc: Option<String>,
2726    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
2727    pub amt: Option<RemittanceAmount3>,
2728}
2729
2730impl DocumentLineInformation1 {
2731    pub fn validate(&self) -> Result<(), ValidationError> {
2732        for item in &self.id {
2733            item.validate()?
2734        }
2735        if let Some(ref val) = self.desc {
2736            if val.chars().count() < 1 {
2737                return Err(ValidationError::new(
2738                    1001,
2739                    "desc is shorter than the minimum length of 1".to_string(),
2740                ));
2741            }
2742            if val.chars().count() > 2048 {
2743                return Err(ValidationError::new(
2744                    1002,
2745                    "desc exceeds the maximum length of 2048".to_string(),
2746                ));
2747            }
2748        }
2749        if let Some(ref val) = self.amt {
2750            val.validate()?
2751        }
2752        Ok(())
2753    }
2754}
2755// DocumentLineType1 ...
2756#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2757pub struct DocumentLineType1 {
2758    #[serde(rename = "CdOrPrtry")]
2759    pub cd_or_prtry: DocumentLineType1Choice,
2760    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2761    pub issr: Option<String>,
2762}
2763
2764impl DocumentLineType1 {
2765    pub fn validate(&self) -> Result<(), ValidationError> {
2766        self.cd_or_prtry.validate()?;
2767        if let Some(ref val) = self.issr {
2768            if val.chars().count() < 1 {
2769                return Err(ValidationError::new(
2770                    1001,
2771                    "issr is shorter than the minimum length of 1".to_string(),
2772                ));
2773            }
2774            if val.chars().count() > 35 {
2775                return Err(ValidationError::new(
2776                    1002,
2777                    "issr exceeds the maximum length of 35".to_string(),
2778                ));
2779            }
2780        }
2781        Ok(())
2782    }
2783}
2784// DocumentLineType1Choice ...
2785#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2786pub struct DocumentLineType1Choice {
2787    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2788    pub cd: Option<String>,
2789    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2790    pub prtry: Option<String>,
2791}
2792
2793impl DocumentLineType1Choice {
2794    pub fn validate(&self) -> Result<(), ValidationError> {
2795        if let Some(ref val) = self.cd {
2796            if val.chars().count() < 1 {
2797                return Err(ValidationError::new(
2798                    1001,
2799                    "cd is shorter than the minimum length of 1".to_string(),
2800                ));
2801            }
2802            if val.chars().count() > 4 {
2803                return Err(ValidationError::new(
2804                    1002,
2805                    "cd exceeds the maximum length of 4".to_string(),
2806                ));
2807            }
2808        }
2809        if let Some(ref val) = self.prtry {
2810            if val.chars().count() < 1 {
2811                return Err(ValidationError::new(
2812                    1001,
2813                    "prtry is shorter than the minimum length of 1".to_string(),
2814                ));
2815            }
2816            if val.chars().count() > 35 {
2817                return Err(ValidationError::new(
2818                    1002,
2819                    "prtry exceeds the maximum length of 35".to_string(),
2820                ));
2821            }
2822        }
2823        Ok(())
2824    }
2825}
2826// DocumentType3Code ...
2827#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2828pub enum DocumentType3Code {
2829    #[default]
2830    #[serde(rename = "RADM")]
2831    CodeRADM,
2832    #[serde(rename = "RPIN")]
2833    CodeRPIN,
2834    #[serde(rename = "FXDR")]
2835    CodeFXDR,
2836    #[serde(rename = "DISP")]
2837    CodeDISP,
2838    #[serde(rename = "PUOR")]
2839    CodePUOR,
2840    #[serde(rename = "SCOR")]
2841    CodeSCOR,
2842}
2843
2844impl DocumentType3Code {
2845    pub fn validate(&self) -> Result<(), ValidationError> {
2846        Ok(())
2847    }
2848}
2849// DocumentType6Code ...
2850#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2851pub enum DocumentType6Code {
2852    #[default]
2853    #[serde(rename = "MSIN")]
2854    CodeMSIN,
2855    #[serde(rename = "CNFA")]
2856    CodeCNFA,
2857    #[serde(rename = "DNFA")]
2858    CodeDNFA,
2859    #[serde(rename = "CINV")]
2860    CodeCINV,
2861    #[serde(rename = "CREN")]
2862    CodeCREN,
2863    #[serde(rename = "DEBN")]
2864    CodeDEBN,
2865    #[serde(rename = "HIRI")]
2866    CodeHIRI,
2867    #[serde(rename = "SBIN")]
2868    CodeSBIN,
2869    #[serde(rename = "CMCN")]
2870    CodeCMCN,
2871    #[serde(rename = "SOAC")]
2872    CodeSOAC,
2873    #[serde(rename = "DISP")]
2874    CodeDISP,
2875    #[serde(rename = "BOLD")]
2876    CodeBOLD,
2877    #[serde(rename = "VCHR")]
2878    CodeVCHR,
2879    #[serde(rename = "AROI")]
2880    CodeAROI,
2881    #[serde(rename = "TSUT")]
2882    CodeTSUT,
2883    #[serde(rename = "PUOR")]
2884    CodePUOR,
2885}
2886
2887impl DocumentType6Code {
2888    pub fn validate(&self) -> Result<(), ValidationError> {
2889        Ok(())
2890    }
2891}
2892// EntryDetails9 ...
2893#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2894pub struct EntryDetails9 {
2895    #[serde(rename = "Btch", skip_serializing_if = "Option::is_none")]
2896    pub btch: Option<BatchInformation2>,
2897    #[serde(rename = "TxDtls", skip_serializing_if = "Option::is_none")]
2898    pub tx_dtls: Option<Vec<EntryTransaction10>>,
2899}
2900
2901impl EntryDetails9 {
2902    pub fn validate(&self) -> Result<(), ValidationError> {
2903        if let Some(ref val) = self.btch {
2904            val.validate()?
2905        }
2906        if let Some(ref vec) = self.tx_dtls {
2907            for item in vec {
2908                item.validate()?
2909            }
2910        }
2911        Ok(())
2912    }
2913}
2914// EntryStatus1Choice ...
2915#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2916pub struct EntryStatus1Choice {
2917    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2918    pub cd: Option<String>,
2919    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2920    pub prtry: Option<String>,
2921}
2922
2923impl EntryStatus1Choice {
2924    pub fn validate(&self) -> Result<(), ValidationError> {
2925        if let Some(ref val) = self.cd {
2926            if val.chars().count() < 1 {
2927                return Err(ValidationError::new(
2928                    1001,
2929                    "cd is shorter than the minimum length of 1".to_string(),
2930                ));
2931            }
2932            if val.chars().count() > 4 {
2933                return Err(ValidationError::new(
2934                    1002,
2935                    "cd exceeds the maximum length of 4".to_string(),
2936                ));
2937            }
2938        }
2939        if let Some(ref val) = self.prtry {
2940            if val.chars().count() < 1 {
2941                return Err(ValidationError::new(
2942                    1001,
2943                    "prtry is shorter than the minimum length of 1".to_string(),
2944                ));
2945            }
2946            if val.chars().count() > 35 {
2947                return Err(ValidationError::new(
2948                    1002,
2949                    "prtry exceeds the maximum length of 35".to_string(),
2950                ));
2951            }
2952        }
2953        Ok(())
2954    }
2955}
2956// EntryTransaction10 ...
2957#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2958pub struct EntryTransaction10 {
2959    #[serde(rename = "Refs", skip_serializing_if = "Option::is_none")]
2960    pub refs: Option<TransactionReferences6>,
2961    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
2962    pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2963    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
2964    pub cdt_dbt_ind: Option<CreditDebitCode>,
2965    #[serde(rename = "AmtDtls", skip_serializing_if = "Option::is_none")]
2966    pub amt_dtls: Option<AmountAndCurrencyExchange3>,
2967    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
2968    pub avlbty: Option<Vec<CashAvailability1>>,
2969    #[serde(rename = "BkTxCd", skip_serializing_if = "Option::is_none")]
2970    pub bk_tx_cd: Option<BankTransactionCodeStructure4>,
2971    #[serde(rename = "Chrgs", skip_serializing_if = "Option::is_none")]
2972    pub chrgs: Option<Charges6>,
2973    #[serde(rename = "Intrst", skip_serializing_if = "Option::is_none")]
2974    pub intrst: Option<TransactionInterest4>,
2975    #[serde(rename = "RltdPties", skip_serializing_if = "Option::is_none")]
2976    pub rltd_pties: Option<TransactionParties6>,
2977    #[serde(rename = "RltdAgts", skip_serializing_if = "Option::is_none")]
2978    pub rltd_agts: Option<TransactionAgents5>,
2979    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2980    pub lcl_instrm: Option<LocalInstrument2Choice>,
2981    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
2982    pub purp: Option<Purpose2Choice>,
2983    #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
2984    pub rltd_rmt_inf: Option<Vec<RemittanceLocation7>>,
2985    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
2986    pub rmt_inf: Option<RemittanceInformation16>,
2987    #[serde(rename = "RltdDts", skip_serializing_if = "Option::is_none")]
2988    pub rltd_dts: Option<TransactionDates3>,
2989    #[serde(rename = "RltdPric", skip_serializing_if = "Option::is_none")]
2990    pub rltd_pric: Option<TransactionPrice4Choice>,
2991    #[serde(rename = "RltdQties", skip_serializing_if = "Option::is_none")]
2992    pub rltd_qties: Option<Vec<TransactionQuantities3Choice>>,
2993    #[serde(rename = "FinInstrmId", skip_serializing_if = "Option::is_none")]
2994    pub fin_instrm_id: Option<SecurityIdentification19>,
2995    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
2996    pub tax: Option<TaxInformation8>,
2997    #[serde(rename = "RtrInf", skip_serializing_if = "Option::is_none")]
2998    pub rtr_inf: Option<PaymentReturnReason5>,
2999    #[serde(rename = "CorpActn", skip_serializing_if = "Option::is_none")]
3000    pub corp_actn: Option<CorporateAction9>,
3001    #[serde(rename = "SfkpgAcct", skip_serializing_if = "Option::is_none")]
3002    pub sfkpg_acct: Option<SecuritiesAccount19>,
3003    #[serde(rename = "CshDpst", skip_serializing_if = "Option::is_none")]
3004    pub csh_dpst: Option<Vec<CashDeposit1>>,
3005    #[serde(rename = "CardTx", skip_serializing_if = "Option::is_none")]
3006    pub card_tx: Option<CardTransaction17>,
3007    #[serde(rename = "AddtlTxInf", skip_serializing_if = "Option::is_none")]
3008    pub addtl_tx_inf: Option<String>,
3009    #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
3010    pub splmtry_data: Option<Vec<SupplementaryData1>>,
3011}
3012
3013impl EntryTransaction10 {
3014    pub fn validate(&self) -> Result<(), ValidationError> {
3015        if let Some(ref val) = self.refs {
3016            val.validate()?
3017        }
3018        if let Some(ref val) = self.amt {
3019            val.validate()?
3020        }
3021        if let Some(ref val) = self.cdt_dbt_ind {
3022            val.validate()?
3023        }
3024        if let Some(ref val) = self.amt_dtls {
3025            val.validate()?
3026        }
3027        if let Some(ref vec) = self.avlbty {
3028            for item in vec {
3029                item.validate()?
3030            }
3031        }
3032        if let Some(ref val) = self.bk_tx_cd {
3033            val.validate()?
3034        }
3035        if let Some(ref val) = self.chrgs {
3036            val.validate()?
3037        }
3038        if let Some(ref val) = self.intrst {
3039            val.validate()?
3040        }
3041        if let Some(ref val) = self.rltd_pties {
3042            val.validate()?
3043        }
3044        if let Some(ref val) = self.rltd_agts {
3045            val.validate()?
3046        }
3047        if let Some(ref val) = self.lcl_instrm {
3048            val.validate()?
3049        }
3050        if let Some(ref val) = self.purp {
3051            val.validate()?
3052        }
3053        if let Some(ref vec) = self.rltd_rmt_inf {
3054            for item in vec {
3055                item.validate()?
3056            }
3057        }
3058        if let Some(ref val) = self.rmt_inf {
3059            val.validate()?
3060        }
3061        if let Some(ref val) = self.rltd_dts {
3062            val.validate()?
3063        }
3064        if let Some(ref val) = self.rltd_pric {
3065            val.validate()?
3066        }
3067        if let Some(ref vec) = self.rltd_qties {
3068            for item in vec {
3069                item.validate()?
3070            }
3071        }
3072        if let Some(ref val) = self.fin_instrm_id {
3073            val.validate()?
3074        }
3075        if let Some(ref val) = self.tax {
3076            val.validate()?
3077        }
3078        if let Some(ref val) = self.rtr_inf {
3079            val.validate()?
3080        }
3081        if let Some(ref val) = self.corp_actn {
3082            val.validate()?
3083        }
3084        if let Some(ref val) = self.sfkpg_acct {
3085            val.validate()?
3086        }
3087        if let Some(ref vec) = self.csh_dpst {
3088            for item in vec {
3089                item.validate()?
3090            }
3091        }
3092        if let Some(ref val) = self.card_tx {
3093            val.validate()?
3094        }
3095        if let Some(ref val) = self.addtl_tx_inf {
3096            if val.chars().count() < 1 {
3097                return Err(ValidationError::new(
3098                    1001,
3099                    "addtl_tx_inf is shorter than the minimum length of 1".to_string(),
3100                ));
3101            }
3102            if val.chars().count() > 500 {
3103                return Err(ValidationError::new(
3104                    1002,
3105                    "addtl_tx_inf exceeds the maximum length of 500".to_string(),
3106                ));
3107            }
3108        }
3109        if let Some(ref vec) = self.splmtry_data {
3110            for item in vec {
3111                item.validate()?
3112            }
3113        }
3114        Ok(())
3115    }
3116}
3117// EquivalentAmount2 ...
3118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3119pub struct EquivalentAmount2 {
3120    #[serde(rename = "Amt")]
3121    pub amt: ActiveOrHistoricCurrencyAndAmount,
3122    #[serde(rename = "CcyOfTrf")]
3123    pub ccy_of_trf: String,
3124}
3125
3126impl EquivalentAmount2 {
3127    pub fn validate(&self) -> Result<(), ValidationError> {
3128        self.amt.validate()?;
3129        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
3130        if !pattern.is_match(&self.ccy_of_trf) {
3131            return Err(ValidationError::new(
3132                1005,
3133                "ccy_of_trf does not match the required pattern".to_string(),
3134            ));
3135        }
3136        Ok(())
3137    }
3138}
3139// FinancialIdentificationSchemeName1Choice ...
3140#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3141pub struct FinancialIdentificationSchemeName1Choice {
3142    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3143    pub cd: Option<String>,
3144    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3145    pub prtry: Option<String>,
3146}
3147
3148impl FinancialIdentificationSchemeName1Choice {
3149    pub fn validate(&self) -> Result<(), ValidationError> {
3150        if let Some(ref val) = self.cd {
3151            if val.chars().count() < 1 {
3152                return Err(ValidationError::new(
3153                    1001,
3154                    "cd is shorter than the minimum length of 1".to_string(),
3155                ));
3156            }
3157            if val.chars().count() > 4 {
3158                return Err(ValidationError::new(
3159                    1002,
3160                    "cd exceeds the maximum length of 4".to_string(),
3161                ));
3162            }
3163        }
3164        if let Some(ref val) = self.prtry {
3165            if val.chars().count() < 1 {
3166                return Err(ValidationError::new(
3167                    1001,
3168                    "prtry is shorter than the minimum length of 1".to_string(),
3169                ));
3170            }
3171            if val.chars().count() > 35 {
3172                return Err(ValidationError::new(
3173                    1002,
3174                    "prtry exceeds the maximum length of 35".to_string(),
3175                ));
3176            }
3177        }
3178        Ok(())
3179    }
3180}
3181// FinancialInstitutionIdentification18 ...
3182#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3183pub struct FinancialInstitutionIdentification18 {
3184    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
3185    pub bicfi: Option<String>,
3186    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
3187    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification2>,
3188    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
3189    pub lei: Option<String>,
3190    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3191    pub nm: Option<String>,
3192    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3193    pub pstl_adr: Option<PostalAddress24>,
3194    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3195    pub othr: Option<GenericFinancialIdentification1>,
3196}
3197
3198impl FinancialInstitutionIdentification18 {
3199    pub fn validate(&self) -> Result<(), ValidationError> {
3200        if let Some(ref val) = self.bicfi {
3201            let pattern =
3202                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
3203            if !pattern.is_match(val) {
3204                return Err(ValidationError::new(
3205                    1005,
3206                    "bicfi does not match the required pattern".to_string(),
3207                ));
3208            }
3209        }
3210        if let Some(ref val) = self.clr_sys_mmb_id {
3211            val.validate()?
3212        }
3213        if let Some(ref val) = self.lei {
3214            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
3215            if !pattern.is_match(val) {
3216                return Err(ValidationError::new(
3217                    1005,
3218                    "lei does not match the required pattern".to_string(),
3219                ));
3220            }
3221        }
3222        if let Some(ref val) = self.nm {
3223            if val.chars().count() < 1 {
3224                return Err(ValidationError::new(
3225                    1001,
3226                    "nm is shorter than the minimum length of 1".to_string(),
3227                ));
3228            }
3229            if val.chars().count() > 140 {
3230                return Err(ValidationError::new(
3231                    1002,
3232                    "nm exceeds the maximum length of 140".to_string(),
3233                ));
3234            }
3235        }
3236        if let Some(ref val) = self.pstl_adr {
3237            val.validate()?
3238        }
3239        if let Some(ref val) = self.othr {
3240            val.validate()?
3241        }
3242        Ok(())
3243    }
3244}
3245// FinancialInstrumentQuantity1Choice ...
3246#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3247pub struct FinancialInstrumentQuantity1Choice {
3248    #[serde(rename = "Unit", skip_serializing_if = "Option::is_none")]
3249    pub unit: Option<f64>,
3250    #[serde(rename = "FaceAmt", skip_serializing_if = "Option::is_none")]
3251    pub face_amt: Option<f64>,
3252    #[serde(rename = "AmtsdVal", skip_serializing_if = "Option::is_none")]
3253    pub amtsd_val: Option<f64>,
3254}
3255
3256impl FinancialInstrumentQuantity1Choice {
3257    pub fn validate(&self) -> Result<(), ValidationError> {
3258        if let Some(ref val) = self.face_amt {
3259            if *val < 0.000000 {
3260                return Err(ValidationError::new(
3261                    1003,
3262                    "face_amt is less than the minimum value of 0.000000".to_string(),
3263                ));
3264            }
3265        }
3266        if let Some(ref val) = self.amtsd_val {
3267            if *val < 0.000000 {
3268                return Err(ValidationError::new(
3269                    1003,
3270                    "amtsd_val is less than the minimum value of 0.000000".to_string(),
3271                ));
3272            }
3273        }
3274        Ok(())
3275    }
3276}
3277// Frequency36Choice ...
3278#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3279pub struct Frequency36Choice {
3280    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3281    pub tp: Option<Frequency6Code>,
3282    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
3283    pub prd: Option<FrequencyPeriod1>,
3284    #[serde(rename = "PtInTm", skip_serializing_if = "Option::is_none")]
3285    pub pt_in_tm: Option<FrequencyAndMoment1>,
3286}
3287
3288impl Frequency36Choice {
3289    pub fn validate(&self) -> Result<(), ValidationError> {
3290        if let Some(ref val) = self.tp {
3291            val.validate()?
3292        }
3293        if let Some(ref val) = self.prd {
3294            val.validate()?
3295        }
3296        if let Some(ref val) = self.pt_in_tm {
3297            val.validate()?
3298        }
3299        Ok(())
3300    }
3301}
3302// Frequency6Code ...
3303#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3304pub enum Frequency6Code {
3305    #[default]
3306    #[serde(rename = "YEAR")]
3307    CodeYEAR,
3308    #[serde(rename = "MNTH")]
3309    CodeMNTH,
3310    #[serde(rename = "QURT")]
3311    CodeQURT,
3312    #[serde(rename = "MIAN")]
3313    CodeMIAN,
3314    #[serde(rename = "WEEK")]
3315    CodeWEEK,
3316    #[serde(rename = "DAIL")]
3317    CodeDAIL,
3318    #[serde(rename = "ADHO")]
3319    CodeADHO,
3320    #[serde(rename = "INDA")]
3321    CodeINDA,
3322    #[serde(rename = "FRTN")]
3323    CodeFRTN,
3324}
3325
3326impl Frequency6Code {
3327    pub fn validate(&self) -> Result<(), ValidationError> {
3328        Ok(())
3329    }
3330}
3331// FrequencyAndMoment1 ...
3332#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3333pub struct FrequencyAndMoment1 {
3334    #[serde(rename = "Tp")]
3335    pub tp: Frequency6Code,
3336    #[serde(rename = "PtInTm")]
3337    pub pt_in_tm: String,
3338}
3339
3340impl FrequencyAndMoment1 {
3341    pub fn validate(&self) -> Result<(), ValidationError> {
3342        self.tp.validate()?;
3343        let pattern = Regex::new("[0-9]{2}").unwrap();
3344        if !pattern.is_match(&self.pt_in_tm) {
3345            return Err(ValidationError::new(
3346                1005,
3347                "pt_in_tm does not match the required pattern".to_string(),
3348            ));
3349        }
3350        Ok(())
3351    }
3352}
3353// FrequencyPeriod1 ...
3354#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3355pub struct FrequencyPeriod1 {
3356    #[serde(rename = "Tp")]
3357    pub tp: Frequency6Code,
3358    #[serde(rename = "CntPerPrd")]
3359    pub cnt_per_prd: f64,
3360}
3361
3362impl FrequencyPeriod1 {
3363    pub fn validate(&self) -> Result<(), ValidationError> {
3364        self.tp.validate()?;
3365        Ok(())
3366    }
3367}
3368// FromToAmountRange1 ...
3369#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3370pub struct FromToAmountRange1 {
3371    #[serde(rename = "FrAmt")]
3372    pub fr_amt: AmountRangeBoundary1,
3373    #[serde(rename = "ToAmt")]
3374    pub to_amt: AmountRangeBoundary1,
3375}
3376
3377impl FromToAmountRange1 {
3378    pub fn validate(&self) -> Result<(), ValidationError> {
3379        self.fr_amt.validate()?;
3380        self.to_amt.validate()?;
3381        Ok(())
3382    }
3383}
3384// Garnishment3 ...
3385#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3386pub struct Garnishment3 {
3387    #[serde(rename = "Tp")]
3388    pub tp: GarnishmentType1,
3389    #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
3390    pub grnshee: Option<PartyIdentification135>,
3391    #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
3392    pub grnshmt_admstr: Option<PartyIdentification135>,
3393    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3394    pub ref_nb: Option<String>,
3395    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3396    pub dt: Option<String>,
3397    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3398    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3399    #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
3400    pub fmly_mdcl_insrnc_ind: Option<bool>,
3401    #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
3402    pub mplyee_termntn_ind: Option<bool>,
3403}
3404
3405impl Garnishment3 {
3406    pub fn validate(&self) -> Result<(), ValidationError> {
3407        self.tp.validate()?;
3408        if let Some(ref val) = self.grnshee {
3409            val.validate()?
3410        }
3411        if let Some(ref val) = self.grnshmt_admstr {
3412            val.validate()?
3413        }
3414        if let Some(ref val) = self.ref_nb {
3415            if val.chars().count() < 1 {
3416                return Err(ValidationError::new(
3417                    1001,
3418                    "ref_nb is shorter than the minimum length of 1".to_string(),
3419                ));
3420            }
3421            if val.chars().count() > 140 {
3422                return Err(ValidationError::new(
3423                    1002,
3424                    "ref_nb exceeds the maximum length of 140".to_string(),
3425                ));
3426            }
3427        }
3428        if let Some(ref val) = self.rmtd_amt {
3429            val.validate()?
3430        }
3431        Ok(())
3432    }
3433}
3434// GarnishmentType1 ...
3435#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3436pub struct GarnishmentType1 {
3437    #[serde(rename = "CdOrPrtry")]
3438    pub cd_or_prtry: GarnishmentType1Choice,
3439    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3440    pub issr: Option<String>,
3441}
3442
3443impl GarnishmentType1 {
3444    pub fn validate(&self) -> Result<(), ValidationError> {
3445        self.cd_or_prtry.validate()?;
3446        if let Some(ref val) = self.issr {
3447            if val.chars().count() < 1 {
3448                return Err(ValidationError::new(
3449                    1001,
3450                    "issr is shorter than the minimum length of 1".to_string(),
3451                ));
3452            }
3453            if val.chars().count() > 35 {
3454                return Err(ValidationError::new(
3455                    1002,
3456                    "issr exceeds the maximum length of 35".to_string(),
3457                ));
3458            }
3459        }
3460        Ok(())
3461    }
3462}
3463// GarnishmentType1Choice ...
3464#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3465pub struct GarnishmentType1Choice {
3466    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3467    pub cd: Option<String>,
3468    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3469    pub prtry: Option<String>,
3470}
3471
3472impl GarnishmentType1Choice {
3473    pub fn validate(&self) -> Result<(), ValidationError> {
3474        if let Some(ref val) = self.cd {
3475            if val.chars().count() < 1 {
3476                return Err(ValidationError::new(
3477                    1001,
3478                    "cd is shorter than the minimum length of 1".to_string(),
3479                ));
3480            }
3481            if val.chars().count() > 4 {
3482                return Err(ValidationError::new(
3483                    1002,
3484                    "cd exceeds the maximum length of 4".to_string(),
3485                ));
3486            }
3487        }
3488        if let Some(ref val) = self.prtry {
3489            if val.chars().count() < 1 {
3490                return Err(ValidationError::new(
3491                    1001,
3492                    "prtry is shorter than the minimum length of 1".to_string(),
3493                ));
3494            }
3495            if val.chars().count() > 35 {
3496                return Err(ValidationError::new(
3497                    1002,
3498                    "prtry exceeds the maximum length of 35".to_string(),
3499                ));
3500            }
3501        }
3502        Ok(())
3503    }
3504}
3505// GenericAccountIdentification1 ...
3506#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3507pub struct GenericAccountIdentification1 {
3508    #[serde(rename = "Id")]
3509    pub id: String,
3510    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3511    pub schme_nm: Option<AccountSchemeName1Choice>,
3512    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3513    pub issr: Option<String>,
3514}
3515
3516impl GenericAccountIdentification1 {
3517    pub fn validate(&self) -> Result<(), ValidationError> {
3518        if self.id.chars().count() < 1 {
3519            return Err(ValidationError::new(
3520                1001,
3521                "id is shorter than the minimum length of 1".to_string(),
3522            ));
3523        }
3524        if self.id.chars().count() > 34 {
3525            return Err(ValidationError::new(
3526                1002,
3527                "id exceeds the maximum length of 34".to_string(),
3528            ));
3529        }
3530        if let Some(ref val) = self.schme_nm {
3531            val.validate()?
3532        }
3533        if let Some(ref val) = self.issr {
3534            if val.chars().count() < 1 {
3535                return Err(ValidationError::new(
3536                    1001,
3537                    "issr is shorter than the minimum length of 1".to_string(),
3538                ));
3539            }
3540            if val.chars().count() > 35 {
3541                return Err(ValidationError::new(
3542                    1002,
3543                    "issr exceeds the maximum length of 35".to_string(),
3544                ));
3545            }
3546        }
3547        Ok(())
3548    }
3549}
3550// GenericFinancialIdentification1 ...
3551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3552pub struct GenericFinancialIdentification1 {
3553    #[serde(rename = "Id")]
3554    pub id: String,
3555    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3556    pub schme_nm: Option<FinancialIdentificationSchemeName1Choice>,
3557    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3558    pub issr: Option<String>,
3559}
3560
3561impl GenericFinancialIdentification1 {
3562    pub fn validate(&self) -> Result<(), ValidationError> {
3563        if self.id.chars().count() < 1 {
3564            return Err(ValidationError::new(
3565                1001,
3566                "id is shorter than the minimum length of 1".to_string(),
3567            ));
3568        }
3569        if self.id.chars().count() > 35 {
3570            return Err(ValidationError::new(
3571                1002,
3572                "id exceeds the maximum length of 35".to_string(),
3573            ));
3574        }
3575        if let Some(ref val) = self.schme_nm {
3576            val.validate()?
3577        }
3578        if let Some(ref val) = self.issr {
3579            if val.chars().count() < 1 {
3580                return Err(ValidationError::new(
3581                    1001,
3582                    "issr is shorter than the minimum length of 1".to_string(),
3583                ));
3584            }
3585            if val.chars().count() > 35 {
3586                return Err(ValidationError::new(
3587                    1002,
3588                    "issr exceeds the maximum length of 35".to_string(),
3589                ));
3590            }
3591        }
3592        Ok(())
3593    }
3594}
3595// GenericIdentification1 ...
3596#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3597pub struct GenericIdentification1 {
3598    #[serde(rename = "Id")]
3599    pub id: String,
3600    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3601    pub schme_nm: Option<String>,
3602    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3603    pub issr: Option<String>,
3604}
3605
3606impl GenericIdentification1 {
3607    pub fn validate(&self) -> Result<(), ValidationError> {
3608        if self.id.chars().count() < 1 {
3609            return Err(ValidationError::new(
3610                1001,
3611                "id is shorter than the minimum length of 1".to_string(),
3612            ));
3613        }
3614        if self.id.chars().count() > 35 {
3615            return Err(ValidationError::new(
3616                1002,
3617                "id exceeds the maximum length of 35".to_string(),
3618            ));
3619        }
3620        if let Some(ref val) = self.schme_nm {
3621            if val.chars().count() < 1 {
3622                return Err(ValidationError::new(
3623                    1001,
3624                    "schme_nm is shorter than the minimum length of 1".to_string(),
3625                ));
3626            }
3627            if val.chars().count() > 35 {
3628                return Err(ValidationError::new(
3629                    1002,
3630                    "schme_nm exceeds the maximum length of 35".to_string(),
3631                ));
3632            }
3633        }
3634        if let Some(ref val) = self.issr {
3635            if val.chars().count() < 1 {
3636                return Err(ValidationError::new(
3637                    1001,
3638                    "issr is shorter than the minimum length of 1".to_string(),
3639                ));
3640            }
3641            if val.chars().count() > 35 {
3642                return Err(ValidationError::new(
3643                    1002,
3644                    "issr exceeds the maximum length of 35".to_string(),
3645                ));
3646            }
3647        }
3648        Ok(())
3649    }
3650}
3651// GenericIdentification3 ...
3652#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3653pub struct GenericIdentification3 {
3654    #[serde(rename = "Id")]
3655    pub id: String,
3656    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3657    pub issr: Option<String>,
3658}
3659
3660impl GenericIdentification3 {
3661    pub fn validate(&self) -> Result<(), ValidationError> {
3662        if self.id.chars().count() < 1 {
3663            return Err(ValidationError::new(
3664                1001,
3665                "id is shorter than the minimum length of 1".to_string(),
3666            ));
3667        }
3668        if self.id.chars().count() > 35 {
3669            return Err(ValidationError::new(
3670                1002,
3671                "id exceeds the maximum length of 35".to_string(),
3672            ));
3673        }
3674        if let Some(ref val) = self.issr {
3675            if val.chars().count() < 1 {
3676                return Err(ValidationError::new(
3677                    1001,
3678                    "issr is shorter than the minimum length of 1".to_string(),
3679                ));
3680            }
3681            if val.chars().count() > 35 {
3682                return Err(ValidationError::new(
3683                    1002,
3684                    "issr exceeds the maximum length of 35".to_string(),
3685                ));
3686            }
3687        }
3688        Ok(())
3689    }
3690}
3691// GenericIdentification30 ...
3692#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3693pub struct GenericIdentification30 {
3694    #[serde(rename = "Id")]
3695    pub id: String,
3696    #[serde(rename = "Issr")]
3697    pub issr: String,
3698    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3699    pub schme_nm: Option<String>,
3700}
3701
3702impl GenericIdentification30 {
3703    pub fn validate(&self) -> Result<(), ValidationError> {
3704        let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
3705        if !pattern.is_match(&self.id) {
3706            return Err(ValidationError::new(
3707                1005,
3708                "id does not match the required pattern".to_string(),
3709            ));
3710        }
3711        if self.issr.chars().count() < 1 {
3712            return Err(ValidationError::new(
3713                1001,
3714                "issr is shorter than the minimum length of 1".to_string(),
3715            ));
3716        }
3717        if self.issr.chars().count() > 35 {
3718            return Err(ValidationError::new(
3719                1002,
3720                "issr exceeds the maximum length of 35".to_string(),
3721            ));
3722        }
3723        if let Some(ref val) = self.schme_nm {
3724            if val.chars().count() < 1 {
3725                return Err(ValidationError::new(
3726                    1001,
3727                    "schme_nm is shorter than the minimum length of 1".to_string(),
3728                ));
3729            }
3730            if val.chars().count() > 35 {
3731                return Err(ValidationError::new(
3732                    1002,
3733                    "schme_nm exceeds the maximum length of 35".to_string(),
3734                ));
3735            }
3736        }
3737        Ok(())
3738    }
3739}
3740// GenericIdentification32 ...
3741#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3742pub struct GenericIdentification32 {
3743    #[serde(rename = "Id")]
3744    pub id: String,
3745    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3746    pub tp: Option<PartyType3Code>,
3747    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3748    pub issr: Option<PartyType4Code>,
3749    #[serde(rename = "ShrtNm", skip_serializing_if = "Option::is_none")]
3750    pub shrt_nm: Option<String>,
3751}
3752
3753impl GenericIdentification32 {
3754    pub fn validate(&self) -> Result<(), ValidationError> {
3755        if self.id.chars().count() < 1 {
3756            return Err(ValidationError::new(
3757                1001,
3758                "id is shorter than the minimum length of 1".to_string(),
3759            ));
3760        }
3761        if self.id.chars().count() > 35 {
3762            return Err(ValidationError::new(
3763                1002,
3764                "id exceeds the maximum length of 35".to_string(),
3765            ));
3766        }
3767        if let Some(ref val) = self.tp {
3768            val.validate()?
3769        }
3770        if let Some(ref val) = self.issr {
3771            val.validate()?
3772        }
3773        if let Some(ref val) = self.shrt_nm {
3774            if val.chars().count() < 1 {
3775                return Err(ValidationError::new(
3776                    1001,
3777                    "shrt_nm is shorter than the minimum length of 1".to_string(),
3778                ));
3779            }
3780            if val.chars().count() > 35 {
3781                return Err(ValidationError::new(
3782                    1002,
3783                    "shrt_nm exceeds the maximum length of 35".to_string(),
3784                ));
3785            }
3786        }
3787        Ok(())
3788    }
3789}
3790// GenericOrganisationIdentification1 ...
3791#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3792pub struct GenericOrganisationIdentification1 {
3793    #[serde(rename = "Id")]
3794    pub id: String,
3795    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3796    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
3797    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3798    pub issr: Option<String>,
3799}
3800
3801impl GenericOrganisationIdentification1 {
3802    pub fn validate(&self) -> Result<(), ValidationError> {
3803        if self.id.chars().count() < 1 {
3804            return Err(ValidationError::new(
3805                1001,
3806                "id is shorter than the minimum length of 1".to_string(),
3807            ));
3808        }
3809        if self.id.chars().count() > 35 {
3810            return Err(ValidationError::new(
3811                1002,
3812                "id exceeds the maximum length of 35".to_string(),
3813            ));
3814        }
3815        if let Some(ref val) = self.schme_nm {
3816            val.validate()?
3817        }
3818        if let Some(ref val) = self.issr {
3819            if val.chars().count() < 1 {
3820                return Err(ValidationError::new(
3821                    1001,
3822                    "issr is shorter than the minimum length of 1".to_string(),
3823                ));
3824            }
3825            if val.chars().count() > 35 {
3826                return Err(ValidationError::new(
3827                    1002,
3828                    "issr exceeds the maximum length of 35".to_string(),
3829                ));
3830            }
3831        }
3832        Ok(())
3833    }
3834}
3835// GenericPersonIdentification1 ...
3836#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3837pub struct GenericPersonIdentification1 {
3838    #[serde(rename = "Id")]
3839    pub id: String,
3840    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
3841    pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
3842    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3843    pub issr: Option<String>,
3844}
3845
3846impl GenericPersonIdentification1 {
3847    pub fn validate(&self) -> Result<(), ValidationError> {
3848        if self.id.chars().count() < 1 {
3849            return Err(ValidationError::new(
3850                1001,
3851                "id is shorter than the minimum length of 1".to_string(),
3852            ));
3853        }
3854        if self.id.chars().count() > 35 {
3855            return Err(ValidationError::new(
3856                1002,
3857                "id exceeds the maximum length of 35".to_string(),
3858            ));
3859        }
3860        if let Some(ref val) = self.schme_nm {
3861            val.validate()?
3862        }
3863        if let Some(ref val) = self.issr {
3864            if val.chars().count() < 1 {
3865                return Err(ValidationError::new(
3866                    1001,
3867                    "issr is shorter than the minimum length of 1".to_string(),
3868                ));
3869            }
3870            if val.chars().count() > 35 {
3871                return Err(ValidationError::new(
3872                    1002,
3873                    "issr exceeds the maximum length of 35".to_string(),
3874                ));
3875            }
3876        }
3877        Ok(())
3878    }
3879}
3880// GroupHeader81 ...
3881#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3882pub struct GroupHeader81 {
3883    #[serde(rename = "MsgId")]
3884    pub msg_id: String,
3885    #[serde(rename = "CreDtTm")]
3886    pub cre_dt_tm: String,
3887    #[serde(rename = "MsgRcpt", skip_serializing_if = "Option::is_none")]
3888    pub msg_rcpt: Option<PartyIdentification135>,
3889    #[serde(rename = "MsgPgntn", skip_serializing_if = "Option::is_none")]
3890    pub msg_pgntn: Option<Pagination1>,
3891    #[serde(rename = "OrgnlBizQry", skip_serializing_if = "Option::is_none")]
3892    pub orgnl_biz_qry: Option<OriginalBusinessQuery1>,
3893    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
3894    pub addtl_inf: Option<String>,
3895}
3896
3897impl GroupHeader81 {
3898    pub fn validate(&self) -> Result<(), ValidationError> {
3899        if self.msg_id.chars().count() < 1 {
3900            return Err(ValidationError::new(
3901                1001,
3902                "msg_id is shorter than the minimum length of 1".to_string(),
3903            ));
3904        }
3905        if self.msg_id.chars().count() > 35 {
3906            return Err(ValidationError::new(
3907                1002,
3908                "msg_id exceeds the maximum length of 35".to_string(),
3909            ));
3910        }
3911        if let Some(ref val) = self.msg_rcpt {
3912            val.validate()?
3913        }
3914        if let Some(ref val) = self.msg_pgntn {
3915            val.validate()?
3916        }
3917        if let Some(ref val) = self.orgnl_biz_qry {
3918            val.validate()?
3919        }
3920        if let Some(ref val) = self.addtl_inf {
3921            if val.chars().count() < 1 {
3922                return Err(ValidationError::new(
3923                    1001,
3924                    "addtl_inf is shorter than the minimum length of 1".to_string(),
3925                ));
3926            }
3927            if val.chars().count() > 500 {
3928                return Err(ValidationError::new(
3929                    1002,
3930                    "addtl_inf exceeds the maximum length of 500".to_string(),
3931                ));
3932            }
3933        }
3934        Ok(())
3935    }
3936}
3937// GroupHeader93 ...
3938#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3939pub struct GroupHeader93 {
3940    #[serde(rename = "MsgId")]
3941    pub msg_id: String,
3942    #[serde(rename = "CreDtTm")]
3943    pub cre_dt_tm: String,
3944    #[serde(rename = "BtchBookg", skip_serializing_if = "Option::is_none")]
3945    pub btch_bookg: Option<bool>,
3946    #[serde(rename = "NbOfTxs")]
3947    pub nb_of_txs: String,
3948    #[serde(rename = "CtrlSum", skip_serializing_if = "Option::is_none")]
3949    pub ctrl_sum: Option<f64>,
3950    #[serde(rename = "TtlIntrBkSttlmAmt", skip_serializing_if = "Option::is_none")]
3951    pub ttl_intr_bk_sttlm_amt: Option<ActiveCurrencyAndAmount>,
3952    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
3953    pub intr_bk_sttlm_dt: Option<String>,
3954    #[serde(rename = "SttlmInf")]
3955    pub sttlm_inf: SettlementInstruction7,
3956    #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
3957    pub pmt_tp_inf: Option<PaymentTypeInformation28>,
3958    #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
3959    pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3960    #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
3961    pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3962}
3963
3964impl GroupHeader93 {
3965    pub fn validate(&self) -> Result<(), ValidationError> {
3966        if self.msg_id.chars().count() < 1 {
3967            return Err(ValidationError::new(
3968                1001,
3969                "msg_id is shorter than the minimum length of 1".to_string(),
3970            ));
3971        }
3972        if self.msg_id.chars().count() > 35 {
3973            return Err(ValidationError::new(
3974                1002,
3975                "msg_id exceeds the maximum length of 35".to_string(),
3976            ));
3977        }
3978        let pattern = Regex::new("[0-9]{1,15}").unwrap();
3979        if !pattern.is_match(&self.nb_of_txs) {
3980            return Err(ValidationError::new(
3981                1005,
3982                "nb_of_txs does not match the required pattern".to_string(),
3983            ));
3984        }
3985        if let Some(ref val) = self.ttl_intr_bk_sttlm_amt {
3986            val.validate()?
3987        }
3988        self.sttlm_inf.validate()?;
3989        if let Some(ref val) = self.pmt_tp_inf {
3990            val.validate()?
3991        }
3992        if let Some(ref val) = self.instg_agt {
3993            val.validate()?
3994        }
3995        if let Some(ref val) = self.instd_agt {
3996            val.validate()?
3997        }
3998        Ok(())
3999    }
4000}
4001// IdentificationSource3Choice ...
4002#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4003pub struct IdentificationSource3Choice {
4004    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4005    pub cd: Option<String>,
4006    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4007    pub prtry: Option<String>,
4008}
4009
4010impl IdentificationSource3Choice {
4011    pub fn validate(&self) -> Result<(), ValidationError> {
4012        if let Some(ref val) = self.cd {
4013            if val.chars().count() < 1 {
4014                return Err(ValidationError::new(
4015                    1001,
4016                    "cd is shorter than the minimum length of 1".to_string(),
4017                ));
4018            }
4019            if val.chars().count() > 4 {
4020                return Err(ValidationError::new(
4021                    1002,
4022                    "cd exceeds the maximum length of 4".to_string(),
4023                ));
4024            }
4025        }
4026        if let Some(ref val) = self.prtry {
4027            if val.chars().count() < 1 {
4028                return Err(ValidationError::new(
4029                    1001,
4030                    "prtry is shorter than the minimum length of 1".to_string(),
4031                ));
4032            }
4033            if val.chars().count() > 35 {
4034                return Err(ValidationError::new(
4035                    1002,
4036                    "prtry exceeds the maximum length of 35".to_string(),
4037                ));
4038            }
4039        }
4040        Ok(())
4041    }
4042}
4043// ImpliedCurrencyAmountRange1Choice ...
4044#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4045pub struct ImpliedCurrencyAmountRange1Choice {
4046    #[serde(rename = "FrAmt", skip_serializing_if = "Option::is_none")]
4047    pub fr_amt: Option<AmountRangeBoundary1>,
4048    #[serde(rename = "ToAmt", skip_serializing_if = "Option::is_none")]
4049    pub to_amt: Option<AmountRangeBoundary1>,
4050    #[serde(rename = "FrToAmt", skip_serializing_if = "Option::is_none")]
4051    pub fr_to_amt: Option<FromToAmountRange1>,
4052    #[serde(rename = "EQAmt", skip_serializing_if = "Option::is_none")]
4053    pub eq_amt: Option<f64>,
4054    #[serde(rename = "NEQAmt", skip_serializing_if = "Option::is_none")]
4055    pub neq_amt: Option<f64>,
4056}
4057
4058impl ImpliedCurrencyAmountRange1Choice {
4059    pub fn validate(&self) -> Result<(), ValidationError> {
4060        if let Some(ref val) = self.fr_amt {
4061            val.validate()?
4062        }
4063        if let Some(ref val) = self.to_amt {
4064            val.validate()?
4065        }
4066        if let Some(ref val) = self.fr_to_amt {
4067            val.validate()?
4068        }
4069        if let Some(ref val) = self.eq_amt {
4070            if *val < 0.000000 {
4071                return Err(ValidationError::new(
4072                    1003,
4073                    "eq_amt is less than the minimum value of 0.000000".to_string(),
4074                ));
4075            }
4076        }
4077        if let Some(ref val) = self.neq_amt {
4078            if *val < 0.000000 {
4079                return Err(ValidationError::new(
4080                    1003,
4081                    "neq_amt is less than the minimum value of 0.000000".to_string(),
4082                ));
4083            }
4084        }
4085        Ok(())
4086    }
4087}
4088// Instruction3Code ...
4089#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4090pub enum Instruction3Code {
4091    #[default]
4092    #[serde(rename = "CHQB")]
4093    CodeCHQB,
4094    #[serde(rename = "HOLD")]
4095    CodeHOLD,
4096    #[serde(rename = "PHOB")]
4097    CodePHOB,
4098    #[serde(rename = "TELB")]
4099    CodeTELB,
4100}
4101
4102impl Instruction3Code {
4103    pub fn validate(&self) -> Result<(), ValidationError> {
4104        Ok(())
4105    }
4106}
4107// Instruction4Code ...
4108#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4109pub enum Instruction4Code {
4110    #[default]
4111    #[serde(rename = "PHOA")]
4112    CodePHOA,
4113    #[serde(rename = "TELA")]
4114    CodeTELA,
4115}
4116
4117impl Instruction4Code {
4118    pub fn validate(&self) -> Result<(), ValidationError> {
4119        Ok(())
4120    }
4121}
4122// InstructionForCreditorAgent1 ...
4123#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4124pub struct InstructionForCreditorAgent1 {
4125    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4126    pub cd: Option<Instruction3Code>,
4127    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
4128    pub instr_inf: Option<String>,
4129}
4130
4131impl InstructionForCreditorAgent1 {
4132    pub fn validate(&self) -> Result<(), ValidationError> {
4133        if let Some(ref val) = self.cd {
4134            val.validate()?
4135        }
4136        if let Some(ref val) = self.instr_inf {
4137            if val.chars().count() < 1 {
4138                return Err(ValidationError::new(
4139                    1001,
4140                    "instr_inf is shorter than the minimum length of 1".to_string(),
4141                ));
4142            }
4143            if val.chars().count() > 140 {
4144                return Err(ValidationError::new(
4145                    1002,
4146                    "instr_inf exceeds the maximum length of 140".to_string(),
4147                ));
4148            }
4149        }
4150        Ok(())
4151    }
4152}
4153// InstructionForNextAgent1 ...
4154#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4155pub struct InstructionForNextAgent1 {
4156    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4157    pub cd: Option<Instruction4Code>,
4158    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
4159    pub instr_inf: Option<String>,
4160}
4161
4162impl InstructionForNextAgent1 {
4163    pub fn validate(&self) -> Result<(), ValidationError> {
4164        if let Some(ref val) = self.cd {
4165            val.validate()?
4166        }
4167        if let Some(ref val) = self.instr_inf {
4168            if val.chars().count() < 1 {
4169                return Err(ValidationError::new(
4170                    1001,
4171                    "instr_inf is shorter than the minimum length of 1".to_string(),
4172                ));
4173            }
4174            if val.chars().count() > 140 {
4175                return Err(ValidationError::new(
4176                    1002,
4177                    "instr_inf exceeds the maximum length of 140".to_string(),
4178                ));
4179            }
4180        }
4181        Ok(())
4182    }
4183}
4184// InterestRecord2 ...
4185#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4186pub struct InterestRecord2 {
4187    #[serde(rename = "Amt")]
4188    pub amt: ActiveOrHistoricCurrencyAndAmount,
4189    #[serde(rename = "CdtDbtInd")]
4190    pub cdt_dbt_ind: CreditDebitCode,
4191    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4192    pub tp: Option<InterestType1Choice>,
4193    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
4194    pub rate: Option<Rate4>,
4195    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
4196    pub fr_to_dt: Option<DateTimePeriod1>,
4197    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
4198    pub rsn: Option<String>,
4199    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
4200    pub tax: Option<TaxCharges2>,
4201}
4202
4203impl InterestRecord2 {
4204    pub fn validate(&self) -> Result<(), ValidationError> {
4205        self.amt.validate()?;
4206        self.cdt_dbt_ind.validate()?;
4207        if let Some(ref val) = self.tp {
4208            val.validate()?
4209        }
4210        if let Some(ref val) = self.rate {
4211            val.validate()?
4212        }
4213        if let Some(ref val) = self.fr_to_dt {
4214            val.validate()?
4215        }
4216        if let Some(ref val) = self.rsn {
4217            if val.chars().count() < 1 {
4218                return Err(ValidationError::new(
4219                    1001,
4220                    "rsn is shorter than the minimum length of 1".to_string(),
4221                ));
4222            }
4223            if val.chars().count() > 35 {
4224                return Err(ValidationError::new(
4225                    1002,
4226                    "rsn exceeds the maximum length of 35".to_string(),
4227                ));
4228            }
4229        }
4230        if let Some(ref val) = self.tax {
4231            val.validate()?
4232        }
4233        Ok(())
4234    }
4235}
4236// InterestType1Choice ...
4237#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4238pub struct InterestType1Choice {
4239    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4240    pub cd: Option<InterestType1Code>,
4241    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4242    pub prtry: Option<String>,
4243}
4244
4245impl InterestType1Choice {
4246    pub fn validate(&self) -> Result<(), ValidationError> {
4247        if let Some(ref val) = self.cd {
4248            val.validate()?
4249        }
4250        if let Some(ref val) = self.prtry {
4251            if val.chars().count() < 1 {
4252                return Err(ValidationError::new(
4253                    1001,
4254                    "prtry is shorter than the minimum length of 1".to_string(),
4255                ));
4256            }
4257            if val.chars().count() > 35 {
4258                return Err(ValidationError::new(
4259                    1002,
4260                    "prtry exceeds the maximum length of 35".to_string(),
4261                ));
4262            }
4263        }
4264        Ok(())
4265    }
4266}
4267// InterestType1Code ...
4268#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4269pub enum InterestType1Code {
4270    #[default]
4271    #[serde(rename = "INDY")]
4272    CodeINDY,
4273    #[serde(rename = "OVRN")]
4274    CodeOVRN,
4275}
4276
4277impl InterestType1Code {
4278    pub fn validate(&self) -> Result<(), ValidationError> {
4279        Ok(())
4280    }
4281}
4282// LocalInstrument2Choice ...
4283#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4284pub struct LocalInstrument2Choice {
4285    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4286    pub cd: Option<String>,
4287    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4288    pub prtry: Option<String>,
4289}
4290
4291impl LocalInstrument2Choice {
4292    pub fn validate(&self) -> Result<(), ValidationError> {
4293        if let Some(ref val) = self.cd {
4294            if val.chars().count() < 1 {
4295                return Err(ValidationError::new(
4296                    1001,
4297                    "cd is shorter than the minimum length of 1".to_string(),
4298                ));
4299            }
4300            if val.chars().count() > 35 {
4301                return Err(ValidationError::new(
4302                    1002,
4303                    "cd exceeds the maximum length of 35".to_string(),
4304                ));
4305            }
4306        }
4307        if let Some(ref val) = self.prtry {
4308            if val.chars().count() < 1 {
4309                return Err(ValidationError::new(
4310                    1001,
4311                    "prtry is shorter than the minimum length of 1".to_string(),
4312                ));
4313            }
4314            if val.chars().count() > 35 {
4315                return Err(ValidationError::new(
4316                    1002,
4317                    "prtry exceeds the maximum length of 35".to_string(),
4318                ));
4319            }
4320        }
4321        Ok(())
4322    }
4323}
4324// MandateRelatedInformation14 ...
4325#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4326pub struct MandateRelatedInformation14 {
4327    #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
4328    pub mndt_id: Option<String>,
4329    #[serde(rename = "DtOfSgntr", skip_serializing_if = "Option::is_none")]
4330    pub dt_of_sgntr: Option<String>,
4331    #[serde(rename = "AmdmntInd", skip_serializing_if = "Option::is_none")]
4332    pub amdmnt_ind: Option<bool>,
4333    #[serde(rename = "AmdmntInfDtls", skip_serializing_if = "Option::is_none")]
4334    pub amdmnt_inf_dtls: Option<AmendmentInformationDetails13>,
4335    #[serde(rename = "ElctrncSgntr", skip_serializing_if = "Option::is_none")]
4336    pub elctrnc_sgntr: Option<String>,
4337    #[serde(rename = "FrstColltnDt", skip_serializing_if = "Option::is_none")]
4338    pub frst_colltn_dt: Option<String>,
4339    #[serde(rename = "FnlColltnDt", skip_serializing_if = "Option::is_none")]
4340    pub fnl_colltn_dt: Option<String>,
4341    #[serde(rename = "Frqcy", skip_serializing_if = "Option::is_none")]
4342    pub frqcy: Option<Frequency36Choice>,
4343    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
4344    pub rsn: Option<MandateSetupReason1Choice>,
4345    #[serde(rename = "TrckgDays", skip_serializing_if = "Option::is_none")]
4346    pub trckg_days: Option<String>,
4347}
4348
4349impl MandateRelatedInformation14 {
4350    pub fn validate(&self) -> Result<(), ValidationError> {
4351        if let Some(ref val) = self.mndt_id {
4352            if val.chars().count() < 1 {
4353                return Err(ValidationError::new(
4354                    1001,
4355                    "mndt_id is shorter than the minimum length of 1".to_string(),
4356                ));
4357            }
4358            if val.chars().count() > 35 {
4359                return Err(ValidationError::new(
4360                    1002,
4361                    "mndt_id exceeds the maximum length of 35".to_string(),
4362                ));
4363            }
4364        }
4365        if let Some(ref val) = self.amdmnt_inf_dtls {
4366            val.validate()?
4367        }
4368        if let Some(ref val) = self.elctrnc_sgntr {
4369            if val.chars().count() < 1 {
4370                return Err(ValidationError::new(
4371                    1001,
4372                    "elctrnc_sgntr is shorter than the minimum length of 1".to_string(),
4373                ));
4374            }
4375            if val.chars().count() > 1025 {
4376                return Err(ValidationError::new(
4377                    1002,
4378                    "elctrnc_sgntr exceeds the maximum length of 1025".to_string(),
4379                ));
4380            }
4381        }
4382        if let Some(ref val) = self.frqcy {
4383            val.validate()?
4384        }
4385        if let Some(ref val) = self.rsn {
4386            val.validate()?
4387        }
4388        if let Some(ref val) = self.trckg_days {
4389            let pattern = Regex::new("[0-9]{2}").unwrap();
4390            if !pattern.is_match(val) {
4391                return Err(ValidationError::new(
4392                    1005,
4393                    "trckg_days does not match the required pattern".to_string(),
4394                ));
4395            }
4396        }
4397        Ok(())
4398    }
4399}
4400// MandateSetupReason1Choice ...
4401#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4402pub struct MandateSetupReason1Choice {
4403    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4404    pub cd: Option<String>,
4405    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4406    pub prtry: Option<String>,
4407}
4408
4409impl MandateSetupReason1Choice {
4410    pub fn validate(&self) -> Result<(), ValidationError> {
4411        if let Some(ref val) = self.cd {
4412            if val.chars().count() < 1 {
4413                return Err(ValidationError::new(
4414                    1001,
4415                    "cd is shorter than the minimum length of 1".to_string(),
4416                ));
4417            }
4418            if val.chars().count() > 4 {
4419                return Err(ValidationError::new(
4420                    1002,
4421                    "cd exceeds the maximum length of 4".to_string(),
4422                ));
4423            }
4424        }
4425        if let Some(ref val) = self.prtry {
4426            if val.chars().count() < 1 {
4427                return Err(ValidationError::new(
4428                    1001,
4429                    "prtry is shorter than the minimum length of 1".to_string(),
4430                ));
4431            }
4432            if val.chars().count() > 70 {
4433                return Err(ValidationError::new(
4434                    1002,
4435                    "prtry exceeds the maximum length of 70".to_string(),
4436                ));
4437            }
4438        }
4439        Ok(())
4440    }
4441}
4442// MessageIdentification2 ...
4443#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4444pub struct MessageIdentification2 {
4445    #[serde(rename = "MsgNmId", skip_serializing_if = "Option::is_none")]
4446    pub msg_nm_id: Option<String>,
4447    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
4448    pub msg_id: Option<String>,
4449}
4450
4451impl MessageIdentification2 {
4452    pub fn validate(&self) -> Result<(), ValidationError> {
4453        if let Some(ref val) = self.msg_nm_id {
4454            if val.chars().count() < 1 {
4455                return Err(ValidationError::new(
4456                    1001,
4457                    "msg_nm_id is shorter than the minimum length of 1".to_string(),
4458                ));
4459            }
4460            if val.chars().count() > 35 {
4461                return Err(ValidationError::new(
4462                    1002,
4463                    "msg_nm_id exceeds the maximum length of 35".to_string(),
4464                ));
4465            }
4466        }
4467        if let Some(ref val) = self.msg_id {
4468            if val.chars().count() < 1 {
4469                return Err(ValidationError::new(
4470                    1001,
4471                    "msg_id is shorter than the minimum length of 1".to_string(),
4472                ));
4473            }
4474            if val.chars().count() > 35 {
4475                return Err(ValidationError::new(
4476                    1002,
4477                    "msg_id exceeds the maximum length of 35".to_string(),
4478                ));
4479            }
4480        }
4481        Ok(())
4482    }
4483}
4484// NameAndAddress16 ...
4485#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4486pub struct NameAndAddress16 {
4487    #[serde(rename = "Nm")]
4488    pub nm: String,
4489    #[serde(rename = "Adr")]
4490    pub adr: PostalAddress24,
4491}
4492
4493impl NameAndAddress16 {
4494    pub fn validate(&self) -> Result<(), ValidationError> {
4495        if self.nm.chars().count() < 1 {
4496            return Err(ValidationError::new(
4497                1001,
4498                "nm is shorter than the minimum length of 1".to_string(),
4499            ));
4500        }
4501        if self.nm.chars().count() > 140 {
4502            return Err(ValidationError::new(
4503                1002,
4504                "nm exceeds the maximum length of 140".to_string(),
4505            ));
4506        }
4507        self.adr.validate()?;
4508        Ok(())
4509    }
4510}
4511// NamePrefix2Code ...
4512#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4513pub enum NamePrefix2Code {
4514    #[default]
4515    #[serde(rename = "DOCT")]
4516    CodeDOCT,
4517    #[serde(rename = "MADM")]
4518    CodeMADM,
4519    #[serde(rename = "MISS")]
4520    CodeMISS,
4521    #[serde(rename = "MIST")]
4522    CodeMIST,
4523    #[serde(rename = "MIKS")]
4524    CodeMIKS,
4525}
4526
4527impl NamePrefix2Code {
4528    pub fn validate(&self) -> Result<(), ValidationError> {
4529        Ok(())
4530    }
4531}
4532// NumberAndSumOfTransactions1 ...
4533#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4534pub struct NumberAndSumOfTransactions1 {
4535    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
4536    pub nb_of_ntries: Option<String>,
4537    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
4538    pub sum: Option<f64>,
4539}
4540
4541impl NumberAndSumOfTransactions1 {
4542    pub fn validate(&self) -> Result<(), ValidationError> {
4543        if let Some(ref val) = self.nb_of_ntries {
4544            let pattern = Regex::new("[0-9]{1,15}").unwrap();
4545            if !pattern.is_match(val) {
4546                return Err(ValidationError::new(
4547                    1005,
4548                    "nb_of_ntries does not match the required pattern".to_string(),
4549                ));
4550            }
4551        }
4552        Ok(())
4553    }
4554}
4555// NumberAndSumOfTransactions4 ...
4556#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4557pub struct NumberAndSumOfTransactions4 {
4558    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
4559    pub nb_of_ntries: Option<String>,
4560    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
4561    pub sum: Option<f64>,
4562    #[serde(rename = "TtlNetNtry", skip_serializing_if = "Option::is_none")]
4563    pub ttl_net_ntry: Option<AmountAndDirection35>,
4564}
4565
4566impl NumberAndSumOfTransactions4 {
4567    pub fn validate(&self) -> Result<(), ValidationError> {
4568        if let Some(ref val) = self.nb_of_ntries {
4569            let pattern = Regex::new("[0-9]{1,15}").unwrap();
4570            if !pattern.is_match(val) {
4571                return Err(ValidationError::new(
4572                    1005,
4573                    "nb_of_ntries does not match the required pattern".to_string(),
4574                ));
4575            }
4576        }
4577        if let Some(ref val) = self.ttl_net_ntry {
4578            val.validate()?
4579        }
4580        Ok(())
4581    }
4582}
4583// OnLineCapability1Code ...
4584#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4585pub enum OnLineCapability1Code {
4586    #[default]
4587    #[serde(rename = "OFLN")]
4588    CodeOFLN,
4589    #[serde(rename = "ONLN")]
4590    CodeONLN,
4591    #[serde(rename = "SMON")]
4592    CodeSMON,
4593}
4594
4595impl OnLineCapability1Code {
4596    pub fn validate(&self) -> Result<(), ValidationError> {
4597        Ok(())
4598    }
4599}
4600// OrganisationIdentification29 ...
4601#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4602pub struct OrganisationIdentification29 {
4603    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
4604    pub any_bic: Option<String>,
4605    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
4606    pub lei: Option<String>,
4607    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
4608    pub othr: Option<Vec<GenericOrganisationIdentification1>>,
4609}
4610
4611impl OrganisationIdentification29 {
4612    pub fn validate(&self) -> Result<(), ValidationError> {
4613        if let Some(ref val) = self.any_bic {
4614            let pattern =
4615                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
4616            if !pattern.is_match(val) {
4617                return Err(ValidationError::new(
4618                    1005,
4619                    "any_bic does not match the required pattern".to_string(),
4620                ));
4621            }
4622        }
4623        if let Some(ref val) = self.lei {
4624            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
4625            if !pattern.is_match(val) {
4626                return Err(ValidationError::new(
4627                    1005,
4628                    "lei does not match the required pattern".to_string(),
4629                ));
4630            }
4631        }
4632        if let Some(ref vec) = self.othr {
4633            for item in vec {
4634                item.validate()?
4635            }
4636        }
4637        Ok(())
4638    }
4639}
4640// OrganisationIdentificationSchemeName1Choice ...
4641#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4642pub struct OrganisationIdentificationSchemeName1Choice {
4643    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4644    pub cd: Option<String>,
4645    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4646    pub prtry: Option<String>,
4647}
4648
4649impl OrganisationIdentificationSchemeName1Choice {
4650    pub fn validate(&self) -> Result<(), ValidationError> {
4651        if let Some(ref val) = self.cd {
4652            if val.chars().count() < 1 {
4653                return Err(ValidationError::new(
4654                    1001,
4655                    "cd is shorter than the minimum length of 1".to_string(),
4656                ));
4657            }
4658            if val.chars().count() > 4 {
4659                return Err(ValidationError::new(
4660                    1002,
4661                    "cd exceeds the maximum length of 4".to_string(),
4662                ));
4663            }
4664        }
4665        if let Some(ref val) = self.prtry {
4666            if val.chars().count() < 1 {
4667                return Err(ValidationError::new(
4668                    1001,
4669                    "prtry is shorter than the minimum length of 1".to_string(),
4670                ));
4671            }
4672            if val.chars().count() > 35 {
4673                return Err(ValidationError::new(
4674                    1002,
4675                    "prtry exceeds the maximum length of 35".to_string(),
4676                ));
4677            }
4678        }
4679        Ok(())
4680    }
4681}
4682// OriginalAndCurrentQuantities1 ...
4683#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4684pub struct OriginalAndCurrentQuantities1 {
4685    #[serde(rename = "FaceAmt")]
4686    pub face_amt: f64,
4687    #[serde(rename = "AmtsdVal")]
4688    pub amtsd_val: f64,
4689}
4690
4691impl OriginalAndCurrentQuantities1 {
4692    pub fn validate(&self) -> Result<(), ValidationError> {
4693        Ok(())
4694    }
4695}
4696// OriginalBusinessQuery1 ...
4697#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4698pub struct OriginalBusinessQuery1 {
4699    #[serde(rename = "MsgId")]
4700    pub msg_id: String,
4701    #[serde(rename = "MsgNmId", skip_serializing_if = "Option::is_none")]
4702    pub msg_nm_id: Option<String>,
4703    #[serde(rename = "CreDtTm", skip_serializing_if = "Option::is_none")]
4704    pub cre_dt_tm: Option<String>,
4705}
4706
4707impl OriginalBusinessQuery1 {
4708    pub fn validate(&self) -> Result<(), ValidationError> {
4709        if self.msg_id.chars().count() < 1 {
4710            return Err(ValidationError::new(
4711                1001,
4712                "msg_id is shorter than the minimum length of 1".to_string(),
4713            ));
4714        }
4715        if self.msg_id.chars().count() > 35 {
4716            return Err(ValidationError::new(
4717                1002,
4718                "msg_id exceeds the maximum length of 35".to_string(),
4719            ));
4720        }
4721        if let Some(ref val) = self.msg_nm_id {
4722            if val.chars().count() < 1 {
4723                return Err(ValidationError::new(
4724                    1001,
4725                    "msg_nm_id is shorter than the minimum length of 1".to_string(),
4726                ));
4727            }
4728            if val.chars().count() > 35 {
4729                return Err(ValidationError::new(
4730                    1002,
4731                    "msg_nm_id exceeds the maximum length of 35".to_string(),
4732                ));
4733            }
4734        }
4735        Ok(())
4736    }
4737}
4738// OriginalGroupInformation29 ...
4739#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4740pub struct OriginalGroupInformation29 {
4741    #[serde(rename = "OrgnlMsgId")]
4742    pub orgnl_msg_id: String,
4743    #[serde(rename = "OrgnlMsgNmId")]
4744    pub orgnl_msg_nm_id: String,
4745    #[serde(rename = "OrgnlCreDtTm", skip_serializing_if = "Option::is_none")]
4746    pub orgnl_cre_dt_tm: Option<String>,
4747}
4748
4749impl OriginalGroupInformation29 {
4750    pub fn validate(&self) -> Result<(), ValidationError> {
4751        if self.orgnl_msg_id.chars().count() < 1 {
4752            return Err(ValidationError::new(
4753                1001,
4754                "orgnl_msg_id is shorter than the minimum length of 1".to_string(),
4755            ));
4756        }
4757        if self.orgnl_msg_id.chars().count() > 35 {
4758            return Err(ValidationError::new(
4759                1002,
4760                "orgnl_msg_id exceeds the maximum length of 35".to_string(),
4761            ));
4762        }
4763        if self.orgnl_msg_nm_id.chars().count() < 1 {
4764            return Err(ValidationError::new(
4765                1001,
4766                "orgnl_msg_nm_id is shorter than the minimum length of 1".to_string(),
4767            ));
4768        }
4769        if self.orgnl_msg_nm_id.chars().count() > 35 {
4770            return Err(ValidationError::new(
4771                1002,
4772                "orgnl_msg_nm_id exceeds the maximum length of 35".to_string(),
4773            ));
4774        }
4775        Ok(())
4776    }
4777}
4778// OriginalTransactionReference28 ...
4779#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4780pub struct OriginalTransactionReference28 {
4781    #[serde(rename = "IntrBkSttlmAmt", skip_serializing_if = "Option::is_none")]
4782    pub intr_bk_sttlm_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4783    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
4784    pub amt: Option<AmountType4Choice>,
4785    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
4786    pub intr_bk_sttlm_dt: Option<String>,
4787    #[serde(rename = "ReqdColltnDt", skip_serializing_if = "Option::is_none")]
4788    pub reqd_colltn_dt: Option<String>,
4789    #[serde(rename = "ReqdExctnDt", skip_serializing_if = "Option::is_none")]
4790    pub reqd_exctn_dt: Option<DateAndDateTime2Choice>,
4791    #[serde(rename = "CdtrSchmeId", skip_serializing_if = "Option::is_none")]
4792    pub cdtr_schme_id: Option<PartyIdentification135>,
4793    #[serde(rename = "SttlmInf", skip_serializing_if = "Option::is_none")]
4794    pub sttlm_inf: Option<SettlementInstruction7>,
4795    #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
4796    pub pmt_tp_inf: Option<PaymentTypeInformation27>,
4797    #[serde(rename = "PmtMtd", skip_serializing_if = "Option::is_none")]
4798    pub pmt_mtd: Option<PaymentMethod4Code>,
4799    #[serde(rename = "MndtRltdInf", skip_serializing_if = "Option::is_none")]
4800    pub mndt_rltd_inf: Option<MandateRelatedInformation14>,
4801    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
4802    pub rmt_inf: Option<RemittanceInformation16>,
4803    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
4804    pub ultmt_dbtr: Option<Party40Choice>,
4805    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
4806    pub dbtr: Option<Party40Choice>,
4807    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
4808    pub dbtr_acct: Option<CashAccount38>,
4809    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
4810    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
4811    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
4812    pub dbtr_agt_acct: Option<CashAccount38>,
4813    #[serde(rename = "CdtrAgt", skip_serializing_if = "Option::is_none")]
4814    pub cdtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
4815    #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
4816    pub cdtr_agt_acct: Option<CashAccount38>,
4817    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
4818    pub cdtr: Option<Party40Choice>,
4819    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
4820    pub cdtr_acct: Option<CashAccount38>,
4821    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
4822    pub ultmt_cdtr: Option<Party40Choice>,
4823    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
4824    pub purp: Option<Purpose2Choice>,
4825}
4826
4827impl OriginalTransactionReference28 {
4828    pub fn validate(&self) -> Result<(), ValidationError> {
4829        if let Some(ref val) = self.intr_bk_sttlm_amt {
4830            val.validate()?
4831        }
4832        if let Some(ref val) = self.amt {
4833            val.validate()?
4834        }
4835        if let Some(ref val) = self.reqd_exctn_dt {
4836            val.validate()?
4837        }
4838        if let Some(ref val) = self.cdtr_schme_id {
4839            val.validate()?
4840        }
4841        if let Some(ref val) = self.sttlm_inf {
4842            val.validate()?
4843        }
4844        if let Some(ref val) = self.pmt_tp_inf {
4845            val.validate()?
4846        }
4847        if let Some(ref val) = self.pmt_mtd {
4848            val.validate()?
4849        }
4850        if let Some(ref val) = self.mndt_rltd_inf {
4851            val.validate()?
4852        }
4853        if let Some(ref val) = self.rmt_inf {
4854            val.validate()?
4855        }
4856        if let Some(ref val) = self.ultmt_dbtr {
4857            val.validate()?
4858        }
4859        if let Some(ref val) = self.dbtr {
4860            val.validate()?
4861        }
4862        if let Some(ref val) = self.dbtr_acct {
4863            val.validate()?
4864        }
4865        if let Some(ref val) = self.dbtr_agt {
4866            val.validate()?
4867        }
4868        if let Some(ref val) = self.dbtr_agt_acct {
4869            val.validate()?
4870        }
4871        if let Some(ref val) = self.cdtr_agt {
4872            val.validate()?
4873        }
4874        if let Some(ref val) = self.cdtr_agt_acct {
4875            val.validate()?
4876        }
4877        if let Some(ref val) = self.cdtr {
4878            val.validate()?
4879        }
4880        if let Some(ref val) = self.cdtr_acct {
4881            val.validate()?
4882        }
4883        if let Some(ref val) = self.ultmt_cdtr {
4884            val.validate()?
4885        }
4886        if let Some(ref val) = self.purp {
4887            val.validate()?
4888        }
4889        Ok(())
4890    }
4891}
4892// OtherContact1 ...
4893#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4894pub struct OtherContact1 {
4895    #[serde(rename = "ChanlTp")]
4896    pub chanl_tp: String,
4897    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
4898    pub id: Option<String>,
4899}
4900
4901impl OtherContact1 {
4902    pub fn validate(&self) -> Result<(), ValidationError> {
4903        if self.chanl_tp.chars().count() < 1 {
4904            return Err(ValidationError::new(
4905                1001,
4906                "chanl_tp is shorter than the minimum length of 1".to_string(),
4907            ));
4908        }
4909        if self.chanl_tp.chars().count() > 4 {
4910            return Err(ValidationError::new(
4911                1002,
4912                "chanl_tp exceeds the maximum length of 4".to_string(),
4913            ));
4914        }
4915        if let Some(ref val) = self.id {
4916            if val.chars().count() < 1 {
4917                return Err(ValidationError::new(
4918                    1001,
4919                    "id is shorter than the minimum length of 1".to_string(),
4920                ));
4921            }
4922            if val.chars().count() > 128 {
4923                return Err(ValidationError::new(
4924                    1002,
4925                    "id exceeds the maximum length of 128".to_string(),
4926                ));
4927            }
4928        }
4929        Ok(())
4930    }
4931}
4932// OtherIdentification1 ...
4933#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4934pub struct OtherIdentification1 {
4935    #[serde(rename = "Id")]
4936    pub id: String,
4937    #[serde(rename = "Sfx", skip_serializing_if = "Option::is_none")]
4938    pub sfx: Option<String>,
4939    #[serde(rename = "Tp")]
4940    pub tp: IdentificationSource3Choice,
4941}
4942
4943impl OtherIdentification1 {
4944    pub fn validate(&self) -> Result<(), ValidationError> {
4945        if self.id.chars().count() < 1 {
4946            return Err(ValidationError::new(
4947                1001,
4948                "id is shorter than the minimum length of 1".to_string(),
4949            ));
4950        }
4951        if self.id.chars().count() > 35 {
4952            return Err(ValidationError::new(
4953                1002,
4954                "id exceeds the maximum length of 35".to_string(),
4955            ));
4956        }
4957        if let Some(ref val) = self.sfx {
4958            if val.chars().count() < 1 {
4959                return Err(ValidationError::new(
4960                    1001,
4961                    "sfx is shorter than the minimum length of 1".to_string(),
4962                ));
4963            }
4964            if val.chars().count() > 16 {
4965                return Err(ValidationError::new(
4966                    1002,
4967                    "sfx exceeds the maximum length of 16".to_string(),
4968                ));
4969            }
4970        }
4971        self.tp.validate()?;
4972        Ok(())
4973    }
4974}
4975// POIComponentType1Code ...
4976#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4977pub enum POIComponentType1Code {
4978    #[default]
4979    #[serde(rename = "SOFT")]
4980    CodeSOFT,
4981    #[serde(rename = "EMVK")]
4982    CodeEMVK,
4983    #[serde(rename = "EMVO")]
4984    CodeEMVO,
4985    #[serde(rename = "MRIT")]
4986    CodeMRIT,
4987    #[serde(rename = "CHIT")]
4988    CodeCHIT,
4989    #[serde(rename = "SECM")]
4990    CodeSECM,
4991    #[serde(rename = "PEDV")]
4992    CodePEDV,
4993}
4994
4995impl POIComponentType1Code {
4996    pub fn validate(&self) -> Result<(), ValidationError> {
4997        Ok(())
4998    }
4999}
5000// Pagination1 ...
5001#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5002pub struct Pagination1 {
5003    #[serde(rename = "PgNb")]
5004    pub pg_nb: String,
5005    #[serde(rename = "LastPgInd")]
5006    pub last_pg_ind: bool,
5007}
5008
5009impl Pagination1 {
5010    pub fn validate(&self) -> Result<(), ValidationError> {
5011        let pattern = Regex::new("[0-9]{1,5}").unwrap();
5012        if !pattern.is_match(&self.pg_nb) {
5013            return Err(ValidationError::new(
5014                1005,
5015                "pg_nb does not match the required pattern".to_string(),
5016            ));
5017        }
5018        Ok(())
5019    }
5020}
5021// Party38Choice ...
5022#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5023pub struct Party38Choice {
5024    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
5025    pub org_id: Option<OrganisationIdentification29>,
5026    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
5027    pub prvt_id: Option<PersonIdentification13>,
5028}
5029
5030impl Party38Choice {
5031    pub fn validate(&self) -> Result<(), ValidationError> {
5032        if let Some(ref val) = self.org_id {
5033            val.validate()?
5034        }
5035        if let Some(ref val) = self.prvt_id {
5036            val.validate()?
5037        }
5038        Ok(())
5039    }
5040}
5041// Party40Choice ...
5042#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5043pub struct Party40Choice {
5044    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
5045    pub pty: Option<PartyIdentification135>,
5046    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
5047    pub agt: Option<BranchAndFinancialInstitutionIdentification6>,
5048}
5049
5050impl Party40Choice {
5051    pub fn validate(&self) -> Result<(), ValidationError> {
5052        if let Some(ref val) = self.pty {
5053            val.validate()?
5054        }
5055        if let Some(ref val) = self.agt {
5056            val.validate()?
5057        }
5058        Ok(())
5059    }
5060}
5061// PartyIdentification135 ...
5062#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5063pub struct PartyIdentification135 {
5064    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
5065    pub nm: Option<String>,
5066    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
5067    pub pstl_adr: Option<PostalAddress24>,
5068    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
5069    pub id: Option<Party38Choice>,
5070    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
5071    pub ctry_of_res: Option<String>,
5072    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
5073    pub ctct_dtls: Option<Contact4>,
5074}
5075
5076impl PartyIdentification135 {
5077    pub fn validate(&self) -> Result<(), ValidationError> {
5078        if let Some(ref val) = self.nm {
5079            if val.chars().count() < 1 {
5080                return Err(ValidationError::new(
5081                    1001,
5082                    "nm is shorter than the minimum length of 1".to_string(),
5083                ));
5084            }
5085            if val.chars().count() > 140 {
5086                return Err(ValidationError::new(
5087                    1002,
5088                    "nm exceeds the maximum length of 140".to_string(),
5089                ));
5090            }
5091        }
5092        if let Some(ref val) = self.pstl_adr {
5093            val.validate()?
5094        }
5095        if let Some(ref val) = self.id {
5096            val.validate()?
5097        }
5098        if let Some(ref val) = self.ctry_of_res {
5099            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5100            if !pattern.is_match(val) {
5101                return Err(ValidationError::new(
5102                    1005,
5103                    "ctry_of_res does not match the required pattern".to_string(),
5104                ));
5105            }
5106        }
5107        if let Some(ref val) = self.ctct_dtls {
5108            val.validate()?
5109        }
5110        Ok(())
5111    }
5112}
5113// PartyType3Code ...
5114#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5115pub enum PartyType3Code {
5116    #[default]
5117    #[serde(rename = "OPOI")]
5118    CodeOPOI,
5119    #[serde(rename = "MERC")]
5120    CodeMERC,
5121    #[serde(rename = "ACCP")]
5122    CodeACCP,
5123    #[serde(rename = "ITAG")]
5124    CodeITAG,
5125    #[serde(rename = "ACQR")]
5126    CodeACQR,
5127    #[serde(rename = "CISS")]
5128    CodeCISS,
5129    #[serde(rename = "DLIS")]
5130    CodeDLIS,
5131}
5132
5133impl PartyType3Code {
5134    pub fn validate(&self) -> Result<(), ValidationError> {
5135        Ok(())
5136    }
5137}
5138// PartyType4Code ...
5139#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5140pub enum PartyType4Code {
5141    #[default]
5142    #[serde(rename = "MERC")]
5143    CodeMERC,
5144    #[serde(rename = "ACCP")]
5145    CodeACCP,
5146    #[serde(rename = "ITAG")]
5147    CodeITAG,
5148    #[serde(rename = "ACQR")]
5149    CodeACQR,
5150    #[serde(rename = "CISS")]
5151    CodeCISS,
5152    #[serde(rename = "TAXH")]
5153    CodeTAXH,
5154}
5155
5156impl PartyType4Code {
5157    pub fn validate(&self) -> Result<(), ValidationError> {
5158        Ok(())
5159    }
5160}
5161// PaymentCard4 ...
5162#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5163pub struct PaymentCard4 {
5164    #[serde(rename = "PlainCardData", skip_serializing_if = "Option::is_none")]
5165    pub plain_card_data: Option<PlainCardData1>,
5166    #[serde(rename = "CardCtryCd", skip_serializing_if = "Option::is_none")]
5167    pub card_ctry_cd: Option<String>,
5168    #[serde(rename = "CardBrnd", skip_serializing_if = "Option::is_none")]
5169    pub card_brnd: Option<GenericIdentification1>,
5170    #[serde(rename = "AddtlCardData", skip_serializing_if = "Option::is_none")]
5171    pub addtl_card_data: Option<String>,
5172}
5173
5174impl PaymentCard4 {
5175    pub fn validate(&self) -> Result<(), ValidationError> {
5176        if let Some(ref val) = self.plain_card_data {
5177            val.validate()?
5178        }
5179        if let Some(ref val) = self.card_ctry_cd {
5180            let pattern = Regex::new("[0-9]{3}").unwrap();
5181            if !pattern.is_match(val) {
5182                return Err(ValidationError::new(
5183                    1005,
5184                    "card_ctry_cd does not match the required pattern".to_string(),
5185                ));
5186            }
5187        }
5188        if let Some(ref val) = self.card_brnd {
5189            val.validate()?
5190        }
5191        if let Some(ref val) = self.addtl_card_data {
5192            if val.chars().count() < 1 {
5193                return Err(ValidationError::new(
5194                    1001,
5195                    "addtl_card_data is shorter than the minimum length of 1".to_string(),
5196                ));
5197            }
5198            if val.chars().count() > 70 {
5199                return Err(ValidationError::new(
5200                    1002,
5201                    "addtl_card_data exceeds the maximum length of 70".to_string(),
5202                ));
5203            }
5204        }
5205        Ok(())
5206    }
5207}
5208// PaymentContext3 ...
5209#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5210pub struct PaymentContext3 {
5211    #[serde(rename = "CardPres", skip_serializing_if = "Option::is_none")]
5212    pub card_pres: Option<bool>,
5213    #[serde(rename = "CrdhldrPres", skip_serializing_if = "Option::is_none")]
5214    pub crdhldr_pres: Option<bool>,
5215    #[serde(rename = "OnLineCntxt", skip_serializing_if = "Option::is_none")]
5216    pub on_line_cntxt: Option<bool>,
5217    #[serde(rename = "AttndncCntxt", skip_serializing_if = "Option::is_none")]
5218    pub attndnc_cntxt: Option<AttendanceContext1Code>,
5219    #[serde(rename = "TxEnvt", skip_serializing_if = "Option::is_none")]
5220    pub tx_envt: Option<TransactionEnvironment1Code>,
5221    #[serde(rename = "TxChanl", skip_serializing_if = "Option::is_none")]
5222    pub tx_chanl: Option<TransactionChannel1Code>,
5223    #[serde(rename = "AttndntMsgCpbl", skip_serializing_if = "Option::is_none")]
5224    pub attndnt_msg_cpbl: Option<bool>,
5225    #[serde(rename = "AttndntLang", skip_serializing_if = "Option::is_none")]
5226    pub attndnt_lang: Option<String>,
5227    #[serde(rename = "CardDataNtryMd")]
5228    pub card_data_ntry_md: CardDataReading1Code,
5229    #[serde(rename = "FllbckInd", skip_serializing_if = "Option::is_none")]
5230    pub fllbck_ind: Option<bool>,
5231    #[serde(rename = "AuthntcnMtd", skip_serializing_if = "Option::is_none")]
5232    pub authntcn_mtd: Option<CardholderAuthentication2>,
5233}
5234
5235impl PaymentContext3 {
5236    pub fn validate(&self) -> Result<(), ValidationError> {
5237        if let Some(ref val) = self.attndnc_cntxt {
5238            val.validate()?
5239        }
5240        if let Some(ref val) = self.tx_envt {
5241            val.validate()?
5242        }
5243        if let Some(ref val) = self.tx_chanl {
5244            val.validate()?
5245        }
5246        if let Some(ref val) = self.attndnt_lang {
5247            let pattern = Regex::new("[a-z]{2,2}").unwrap();
5248            if !pattern.is_match(val) {
5249                return Err(ValidationError::new(
5250                    1005,
5251                    "attndnt_lang does not match the required pattern".to_string(),
5252                ));
5253            }
5254        }
5255        self.card_data_ntry_md.validate()?;
5256        if let Some(ref val) = self.authntcn_mtd {
5257            val.validate()?
5258        }
5259        Ok(())
5260    }
5261}
5262// PaymentIdentification7 ...
5263#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5264pub struct PaymentIdentification7 {
5265    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
5266    pub instr_id: Option<String>,
5267    #[serde(rename = "EndToEndId")]
5268    pub end_to_end_id: String,
5269    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
5270    pub tx_id: Option<String>,
5271    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
5272    pub uetr: Option<String>,
5273    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
5274    pub clr_sys_ref: Option<String>,
5275}
5276
5277impl PaymentIdentification7 {
5278    pub fn validate(&self) -> Result<(), ValidationError> {
5279        if let Some(ref val) = self.instr_id {
5280            if val.chars().count() < 1 {
5281                return Err(ValidationError::new(
5282                    1001,
5283                    "instr_id is shorter than the minimum length of 1".to_string(),
5284                ));
5285            }
5286            if val.chars().count() > 35 {
5287                return Err(ValidationError::new(
5288                    1002,
5289                    "instr_id exceeds the maximum length of 35".to_string(),
5290                ));
5291            }
5292        }
5293        if self.end_to_end_id.chars().count() < 1 {
5294            return Err(ValidationError::new(
5295                1001,
5296                "end_to_end_id is shorter than the minimum length of 1".to_string(),
5297            ));
5298        }
5299        if self.end_to_end_id.chars().count() > 35 {
5300            return Err(ValidationError::new(
5301                1002,
5302                "end_to_end_id exceeds the maximum length of 35".to_string(),
5303            ));
5304        }
5305        if let Some(ref val) = self.tx_id {
5306            if val.chars().count() < 1 {
5307                return Err(ValidationError::new(
5308                    1001,
5309                    "tx_id is shorter than the minimum length of 1".to_string(),
5310                ));
5311            }
5312            if val.chars().count() > 35 {
5313                return Err(ValidationError::new(
5314                    1002,
5315                    "tx_id exceeds the maximum length of 35".to_string(),
5316                ));
5317            }
5318        }
5319        if let Some(ref val) = self.uetr {
5320            let pattern =
5321                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
5322                    .unwrap();
5323            if !pattern.is_match(val) {
5324                return Err(ValidationError::new(
5325                    1005,
5326                    "uetr does not match the required pattern".to_string(),
5327                ));
5328            }
5329        }
5330        if let Some(ref val) = self.clr_sys_ref {
5331            if val.chars().count() < 1 {
5332                return Err(ValidationError::new(
5333                    1001,
5334                    "clr_sys_ref is shorter than the minimum length of 1".to_string(),
5335                ));
5336            }
5337            if val.chars().count() > 35 {
5338                return Err(ValidationError::new(
5339                    1002,
5340                    "clr_sys_ref exceeds the maximum length of 35".to_string(),
5341                ));
5342            }
5343        }
5344        Ok(())
5345    }
5346}
5347// PaymentMethod4Code ...
5348#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5349pub enum PaymentMethod4Code {
5350    #[default]
5351    #[serde(rename = "CHK")]
5352    CodeCHK,
5353    #[serde(rename = "TRF")]
5354    CodeTRF,
5355    #[serde(rename = "DD")]
5356    CodeDD,
5357    #[serde(rename = "TRA")]
5358    CodeTRA,
5359}
5360
5361impl PaymentMethod4Code {
5362    pub fn validate(&self) -> Result<(), ValidationError> {
5363        Ok(())
5364    }
5365}
5366// PaymentReturnReason5 ...
5367#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5368pub struct PaymentReturnReason5 {
5369    #[serde(rename = "OrgnlBkTxCd", skip_serializing_if = "Option::is_none")]
5370    pub orgnl_bk_tx_cd: Option<BankTransactionCodeStructure4>,
5371    #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
5372    pub orgtr: Option<PartyIdentification135>,
5373    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
5374    pub rsn: Option<ReturnReason5Choice>,
5375    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
5376    pub addtl_inf: Option<Vec<String>>,
5377}
5378
5379impl PaymentReturnReason5 {
5380    pub fn validate(&self) -> Result<(), ValidationError> {
5381        if let Some(ref val) = self.orgnl_bk_tx_cd {
5382            val.validate()?
5383        }
5384        if let Some(ref val) = self.orgtr {
5385            val.validate()?
5386        }
5387        if let Some(ref val) = self.rsn {
5388            val.validate()?
5389        }
5390        if let Some(ref vec) = self.addtl_inf {
5391            for item in vec {
5392                if item.chars().count() < 1 {
5393                    return Err(ValidationError::new(
5394                        1001,
5395                        "addtl_inf is shorter than the minimum length of 1".to_string(),
5396                    ));
5397                }
5398                if item.chars().count() > 105 {
5399                    return Err(ValidationError::new(
5400                        1002,
5401                        "addtl_inf exceeds the maximum length of 105".to_string(),
5402                    ));
5403                }
5404            }
5405        }
5406        Ok(())
5407    }
5408}
5409// PaymentTypeInformation27 ...
5410#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5411pub struct PaymentTypeInformation27 {
5412    #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
5413    pub instr_prty: Option<Priority2Code>,
5414    #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
5415    pub clr_chanl: Option<ClearingChannel2Code>,
5416    #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
5417    pub svc_lvl: Option<Vec<ServiceLevel8Choice>>,
5418    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
5419    pub lcl_instrm: Option<LocalInstrument2Choice>,
5420    #[serde(rename = "SeqTp", skip_serializing_if = "Option::is_none")]
5421    pub seq_tp: Option<SequenceType3Code>,
5422    #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
5423    pub ctgy_purp: Option<CategoryPurpose1Choice>,
5424}
5425
5426impl PaymentTypeInformation27 {
5427    pub fn validate(&self) -> Result<(), ValidationError> {
5428        if let Some(ref val) = self.instr_prty {
5429            val.validate()?
5430        }
5431        if let Some(ref val) = self.clr_chanl {
5432            val.validate()?
5433        }
5434        if let Some(ref vec) = self.svc_lvl {
5435            for item in vec {
5436                item.validate()?
5437            }
5438        }
5439        if let Some(ref val) = self.lcl_instrm {
5440            val.validate()?
5441        }
5442        if let Some(ref val) = self.seq_tp {
5443            val.validate()?
5444        }
5445        if let Some(ref val) = self.ctgy_purp {
5446            val.validate()?
5447        }
5448        Ok(())
5449    }
5450}
5451// PaymentTypeInformation28 ...
5452#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5453pub struct PaymentTypeInformation28 {
5454    #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
5455    pub instr_prty: Option<Priority2Code>,
5456    #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
5457    pub clr_chanl: Option<ClearingChannel2Code>,
5458    #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
5459    pub svc_lvl: Option<Vec<ServiceLevel8Choice>>,
5460    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
5461    pub lcl_instrm: Option<LocalInstrument2Choice>,
5462    #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
5463    pub ctgy_purp: Option<CategoryPurpose1Choice>,
5464}
5465
5466impl PaymentTypeInformation28 {
5467    pub fn validate(&self) -> Result<(), ValidationError> {
5468        if let Some(ref val) = self.instr_prty {
5469            val.validate()?
5470        }
5471        if let Some(ref val) = self.clr_chanl {
5472            val.validate()?
5473        }
5474        if let Some(ref vec) = self.svc_lvl {
5475            for item in vec {
5476                item.validate()?
5477            }
5478        }
5479        if let Some(ref val) = self.lcl_instrm {
5480            val.validate()?
5481        }
5482        if let Some(ref val) = self.ctgy_purp {
5483            val.validate()?
5484        }
5485        Ok(())
5486    }
5487}
5488// PersonIdentification13 ...
5489#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5490pub struct PersonIdentification13 {
5491    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
5492    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
5493    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
5494    pub othr: Option<Vec<GenericPersonIdentification1>>,
5495}
5496
5497impl PersonIdentification13 {
5498    pub fn validate(&self) -> Result<(), ValidationError> {
5499        if let Some(ref val) = self.dt_and_plc_of_birth {
5500            val.validate()?
5501        }
5502        if let Some(ref vec) = self.othr {
5503            for item in vec {
5504                item.validate()?
5505            }
5506        }
5507        Ok(())
5508    }
5509}
5510// PersonIdentificationSchemeName1Choice ...
5511#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5512pub struct PersonIdentificationSchemeName1Choice {
5513    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
5514    pub cd: Option<String>,
5515    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
5516    pub prtry: Option<String>,
5517}
5518
5519impl PersonIdentificationSchemeName1Choice {
5520    pub fn validate(&self) -> Result<(), ValidationError> {
5521        if let Some(ref val) = self.cd {
5522            if val.chars().count() < 1 {
5523                return Err(ValidationError::new(
5524                    1001,
5525                    "cd is shorter than the minimum length of 1".to_string(),
5526                ));
5527            }
5528            if val.chars().count() > 4 {
5529                return Err(ValidationError::new(
5530                    1002,
5531                    "cd exceeds the maximum length of 4".to_string(),
5532                ));
5533            }
5534        }
5535        if let Some(ref val) = self.prtry {
5536            if val.chars().count() < 1 {
5537                return Err(ValidationError::new(
5538                    1001,
5539                    "prtry is shorter than the minimum length of 1".to_string(),
5540                ));
5541            }
5542            if val.chars().count() > 35 {
5543                return Err(ValidationError::new(
5544                    1002,
5545                    "prtry exceeds the maximum length of 35".to_string(),
5546                ));
5547            }
5548        }
5549        Ok(())
5550    }
5551}
5552// PlainCardData1 ...
5553#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5554pub struct PlainCardData1 {
5555    #[serde(rename = "PAN")]
5556    pub pan: String,
5557    #[serde(rename = "CardSeqNb", skip_serializing_if = "Option::is_none")]
5558    pub card_seq_nb: Option<String>,
5559    #[serde(rename = "FctvDt", skip_serializing_if = "Option::is_none")]
5560    pub fctv_dt: Option<String>,
5561    #[serde(rename = "XpryDt")]
5562    pub xpry_dt: String,
5563    #[serde(rename = "SvcCd", skip_serializing_if = "Option::is_none")]
5564    pub svc_cd: Option<String>,
5565    #[serde(rename = "TrckData", skip_serializing_if = "Option::is_none")]
5566    pub trck_data: Option<Vec<TrackData1>>,
5567    #[serde(rename = "CardSctyCd", skip_serializing_if = "Option::is_none")]
5568    pub card_scty_cd: Option<CardSecurityInformation1>,
5569}
5570
5571impl PlainCardData1 {
5572    pub fn validate(&self) -> Result<(), ValidationError> {
5573        let pattern = Regex::new("[0-9]{8,28}").unwrap();
5574        if !pattern.is_match(&self.pan) {
5575            return Err(ValidationError::new(
5576                1005,
5577                "pan does not match the required pattern".to_string(),
5578            ));
5579        }
5580        if let Some(ref val) = self.card_seq_nb {
5581            let pattern = Regex::new("[0-9]{2,3}").unwrap();
5582            if !pattern.is_match(val) {
5583                return Err(ValidationError::new(
5584                    1005,
5585                    "card_seq_nb does not match the required pattern".to_string(),
5586                ));
5587            }
5588        }
5589        if let Some(ref val) = self.svc_cd {
5590            let pattern = Regex::new("[0-9]{3}").unwrap();
5591            if !pattern.is_match(val) {
5592                return Err(ValidationError::new(
5593                    1005,
5594                    "svc_cd does not match the required pattern".to_string(),
5595                ));
5596            }
5597        }
5598        if let Some(ref vec) = self.trck_data {
5599            for item in vec {
5600                item.validate()?
5601            }
5602        }
5603        if let Some(ref val) = self.card_scty_cd {
5604            val.validate()?
5605        }
5606        Ok(())
5607    }
5608}
5609// PointOfInteraction1 ...
5610#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5611pub struct PointOfInteraction1 {
5612    #[serde(rename = "Id")]
5613    pub id: GenericIdentification32,
5614    #[serde(rename = "SysNm", skip_serializing_if = "Option::is_none")]
5615    pub sys_nm: Option<String>,
5616    #[serde(rename = "GrpId", skip_serializing_if = "Option::is_none")]
5617    pub grp_id: Option<String>,
5618    #[serde(rename = "Cpblties", skip_serializing_if = "Option::is_none")]
5619    pub cpblties: Option<PointOfInteractionCapabilities1>,
5620    #[serde(rename = "Cmpnt", skip_serializing_if = "Option::is_none")]
5621    pub cmpnt: Option<Vec<PointOfInteractionComponent1>>,
5622}
5623
5624impl PointOfInteraction1 {
5625    pub fn validate(&self) -> Result<(), ValidationError> {
5626        self.id.validate()?;
5627        if let Some(ref val) = self.sys_nm {
5628            if val.chars().count() < 1 {
5629                return Err(ValidationError::new(
5630                    1001,
5631                    "sys_nm is shorter than the minimum length of 1".to_string(),
5632                ));
5633            }
5634            if val.chars().count() > 70 {
5635                return Err(ValidationError::new(
5636                    1002,
5637                    "sys_nm exceeds the maximum length of 70".to_string(),
5638                ));
5639            }
5640        }
5641        if let Some(ref val) = self.grp_id {
5642            if val.chars().count() < 1 {
5643                return Err(ValidationError::new(
5644                    1001,
5645                    "grp_id is shorter than the minimum length of 1".to_string(),
5646                ));
5647            }
5648            if val.chars().count() > 35 {
5649                return Err(ValidationError::new(
5650                    1002,
5651                    "grp_id exceeds the maximum length of 35".to_string(),
5652                ));
5653            }
5654        }
5655        if let Some(ref val) = self.cpblties {
5656            val.validate()?
5657        }
5658        if let Some(ref vec) = self.cmpnt {
5659            for item in vec {
5660                item.validate()?
5661            }
5662        }
5663        Ok(())
5664    }
5665}
5666// PointOfInteractionCapabilities1 ...
5667#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5668pub struct PointOfInteractionCapabilities1 {
5669    #[serde(rename = "CardRdngCpblties", skip_serializing_if = "Option::is_none")]
5670    pub card_rdng_cpblties: Option<Vec<CardDataReading1Code>>,
5671    #[serde(
5672        rename = "CrdhldrVrfctnCpblties",
5673        skip_serializing_if = "Option::is_none"
5674    )]
5675    pub crdhldr_vrfctn_cpblties: Option<Vec<CardholderVerificationCapability1Code>>,
5676    #[serde(rename = "OnLineCpblties", skip_serializing_if = "Option::is_none")]
5677    pub on_line_cpblties: Option<OnLineCapability1Code>,
5678    #[serde(rename = "DispCpblties", skip_serializing_if = "Option::is_none")]
5679    pub disp_cpblties: Option<Vec<DisplayCapabilities1>>,
5680    #[serde(rename = "PrtLineWidth", skip_serializing_if = "Option::is_none")]
5681    pub prt_line_width: Option<String>,
5682}
5683
5684impl PointOfInteractionCapabilities1 {
5685    pub fn validate(&self) -> Result<(), ValidationError> {
5686        if let Some(ref vec) = self.card_rdng_cpblties {
5687            for item in vec {
5688                item.validate()?
5689            }
5690        }
5691        if let Some(ref vec) = self.crdhldr_vrfctn_cpblties {
5692            for item in vec {
5693                item.validate()?
5694            }
5695        }
5696        if let Some(ref val) = self.on_line_cpblties {
5697            val.validate()?
5698        }
5699        if let Some(ref vec) = self.disp_cpblties {
5700            for item in vec {
5701                item.validate()?
5702            }
5703        }
5704        if let Some(ref val) = self.prt_line_width {
5705            let pattern = Regex::new("[0-9]{1,3}").unwrap();
5706            if !pattern.is_match(val) {
5707                return Err(ValidationError::new(
5708                    1005,
5709                    "prt_line_width does not match the required pattern".to_string(),
5710                ));
5711            }
5712        }
5713        Ok(())
5714    }
5715}
5716// PointOfInteractionComponent1 ...
5717#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5718pub struct PointOfInteractionComponent1 {
5719    #[serde(rename = "POICmpntTp")]
5720    pub poi_cmpnt_tp: POIComponentType1Code,
5721    #[serde(rename = "ManfctrId", skip_serializing_if = "Option::is_none")]
5722    pub manfctr_id: Option<String>,
5723    #[serde(rename = "Mdl", skip_serializing_if = "Option::is_none")]
5724    pub mdl: Option<String>,
5725    #[serde(rename = "VrsnNb", skip_serializing_if = "Option::is_none")]
5726    pub vrsn_nb: Option<String>,
5727    #[serde(rename = "SrlNb", skip_serializing_if = "Option::is_none")]
5728    pub srl_nb: Option<String>,
5729    #[serde(rename = "ApprvlNb", skip_serializing_if = "Option::is_none")]
5730    pub apprvl_nb: Option<Vec<String>>,
5731}
5732
5733impl PointOfInteractionComponent1 {
5734    pub fn validate(&self) -> Result<(), ValidationError> {
5735        self.poi_cmpnt_tp.validate()?;
5736        if let Some(ref val) = self.manfctr_id {
5737            if val.chars().count() < 1 {
5738                return Err(ValidationError::new(
5739                    1001,
5740                    "manfctr_id is shorter than the minimum length of 1".to_string(),
5741                ));
5742            }
5743            if val.chars().count() > 35 {
5744                return Err(ValidationError::new(
5745                    1002,
5746                    "manfctr_id exceeds the maximum length of 35".to_string(),
5747                ));
5748            }
5749        }
5750        if let Some(ref val) = self.mdl {
5751            if val.chars().count() < 1 {
5752                return Err(ValidationError::new(
5753                    1001,
5754                    "mdl is shorter than the minimum length of 1".to_string(),
5755                ));
5756            }
5757            if val.chars().count() > 35 {
5758                return Err(ValidationError::new(
5759                    1002,
5760                    "mdl exceeds the maximum length of 35".to_string(),
5761                ));
5762            }
5763        }
5764        if let Some(ref val) = self.vrsn_nb {
5765            if val.chars().count() < 1 {
5766                return Err(ValidationError::new(
5767                    1001,
5768                    "vrsn_nb is shorter than the minimum length of 1".to_string(),
5769                ));
5770            }
5771            if val.chars().count() > 16 {
5772                return Err(ValidationError::new(
5773                    1002,
5774                    "vrsn_nb exceeds the maximum length of 16".to_string(),
5775                ));
5776            }
5777        }
5778        if let Some(ref val) = self.srl_nb {
5779            if val.chars().count() < 1 {
5780                return Err(ValidationError::new(
5781                    1001,
5782                    "srl_nb is shorter than the minimum length of 1".to_string(),
5783                ));
5784            }
5785            if val.chars().count() > 35 {
5786                return Err(ValidationError::new(
5787                    1002,
5788                    "srl_nb exceeds the maximum length of 35".to_string(),
5789                ));
5790            }
5791        }
5792        if let Some(ref vec) = self.apprvl_nb {
5793            for item in vec {
5794                if item.chars().count() < 1 {
5795                    return Err(ValidationError::new(
5796                        1001,
5797                        "apprvl_nb is shorter than the minimum length of 1".to_string(),
5798                    ));
5799                }
5800                if item.chars().count() > 70 {
5801                    return Err(ValidationError::new(
5802                        1002,
5803                        "apprvl_nb exceeds the maximum length of 70".to_string(),
5804                    ));
5805                }
5806            }
5807        }
5808        Ok(())
5809    }
5810}
5811// PostalAddress24 ...
5812#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5813pub struct PostalAddress24 {
5814    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
5815    pub adr_tp: Option<AddressType3Choice>,
5816    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
5817    pub dept: Option<String>,
5818    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
5819    pub sub_dept: Option<String>,
5820    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
5821    pub strt_nm: Option<String>,
5822    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
5823    pub bldg_nb: Option<String>,
5824    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
5825    pub bldg_nm: Option<String>,
5826    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
5827    pub flr: Option<String>,
5828    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
5829    pub pst_bx: Option<String>,
5830    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
5831    pub room: Option<String>,
5832    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
5833    pub pst_cd: Option<String>,
5834    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
5835    pub twn_nm: Option<String>,
5836    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
5837    pub twn_lctn_nm: Option<String>,
5838    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
5839    pub dstrct_nm: Option<String>,
5840    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
5841    pub ctry_sub_dvsn: Option<String>,
5842    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
5843    pub ctry: Option<String>,
5844    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
5845    pub adr_line: Option<Vec<String>>,
5846}
5847
5848impl PostalAddress24 {
5849    pub fn validate(&self) -> Result<(), ValidationError> {
5850        if let Some(ref val) = self.adr_tp {
5851            val.validate()?
5852        }
5853        if let Some(ref val) = self.dept {
5854            if val.chars().count() < 1 {
5855                return Err(ValidationError::new(
5856                    1001,
5857                    "dept is shorter than the minimum length of 1".to_string(),
5858                ));
5859            }
5860            if val.chars().count() > 70 {
5861                return Err(ValidationError::new(
5862                    1002,
5863                    "dept exceeds the maximum length of 70".to_string(),
5864                ));
5865            }
5866        }
5867        if let Some(ref val) = self.sub_dept {
5868            if val.chars().count() < 1 {
5869                return Err(ValidationError::new(
5870                    1001,
5871                    "sub_dept is shorter than the minimum length of 1".to_string(),
5872                ));
5873            }
5874            if val.chars().count() > 70 {
5875                return Err(ValidationError::new(
5876                    1002,
5877                    "sub_dept exceeds the maximum length of 70".to_string(),
5878                ));
5879            }
5880        }
5881        if let Some(ref val) = self.strt_nm {
5882            if val.chars().count() < 1 {
5883                return Err(ValidationError::new(
5884                    1001,
5885                    "strt_nm is shorter than the minimum length of 1".to_string(),
5886                ));
5887            }
5888            if val.chars().count() > 70 {
5889                return Err(ValidationError::new(
5890                    1002,
5891                    "strt_nm exceeds the maximum length of 70".to_string(),
5892                ));
5893            }
5894        }
5895        if let Some(ref val) = self.bldg_nb {
5896            if val.chars().count() < 1 {
5897                return Err(ValidationError::new(
5898                    1001,
5899                    "bldg_nb is shorter than the minimum length of 1".to_string(),
5900                ));
5901            }
5902            if val.chars().count() > 16 {
5903                return Err(ValidationError::new(
5904                    1002,
5905                    "bldg_nb exceeds the maximum length of 16".to_string(),
5906                ));
5907            }
5908        }
5909        if let Some(ref val) = self.bldg_nm {
5910            if val.chars().count() < 1 {
5911                return Err(ValidationError::new(
5912                    1001,
5913                    "bldg_nm is shorter than the minimum length of 1".to_string(),
5914                ));
5915            }
5916            if val.chars().count() > 35 {
5917                return Err(ValidationError::new(
5918                    1002,
5919                    "bldg_nm exceeds the maximum length of 35".to_string(),
5920                ));
5921            }
5922        }
5923        if let Some(ref val) = self.flr {
5924            if val.chars().count() < 1 {
5925                return Err(ValidationError::new(
5926                    1001,
5927                    "flr is shorter than the minimum length of 1".to_string(),
5928                ));
5929            }
5930            if val.chars().count() > 70 {
5931                return Err(ValidationError::new(
5932                    1002,
5933                    "flr exceeds the maximum length of 70".to_string(),
5934                ));
5935            }
5936        }
5937        if let Some(ref val) = self.pst_bx {
5938            if val.chars().count() < 1 {
5939                return Err(ValidationError::new(
5940                    1001,
5941                    "pst_bx is shorter than the minimum length of 1".to_string(),
5942                ));
5943            }
5944            if val.chars().count() > 16 {
5945                return Err(ValidationError::new(
5946                    1002,
5947                    "pst_bx exceeds the maximum length of 16".to_string(),
5948                ));
5949            }
5950        }
5951        if let Some(ref val) = self.room {
5952            if val.chars().count() < 1 {
5953                return Err(ValidationError::new(
5954                    1001,
5955                    "room is shorter than the minimum length of 1".to_string(),
5956                ));
5957            }
5958            if val.chars().count() > 70 {
5959                return Err(ValidationError::new(
5960                    1002,
5961                    "room exceeds the maximum length of 70".to_string(),
5962                ));
5963            }
5964        }
5965        if let Some(ref val) = self.pst_cd {
5966            if val.chars().count() < 1 {
5967                return Err(ValidationError::new(
5968                    1001,
5969                    "pst_cd is shorter than the minimum length of 1".to_string(),
5970                ));
5971            }
5972            if val.chars().count() > 16 {
5973                return Err(ValidationError::new(
5974                    1002,
5975                    "pst_cd exceeds the maximum length of 16".to_string(),
5976                ));
5977            }
5978        }
5979        if let Some(ref val) = self.twn_nm {
5980            if val.chars().count() < 1 {
5981                return Err(ValidationError::new(
5982                    1001,
5983                    "twn_nm is shorter than the minimum length of 1".to_string(),
5984                ));
5985            }
5986            if val.chars().count() > 35 {
5987                return Err(ValidationError::new(
5988                    1002,
5989                    "twn_nm exceeds the maximum length of 35".to_string(),
5990                ));
5991            }
5992        }
5993        if let Some(ref val) = self.twn_lctn_nm {
5994            if val.chars().count() < 1 {
5995                return Err(ValidationError::new(
5996                    1001,
5997                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
5998                ));
5999            }
6000            if val.chars().count() > 35 {
6001                return Err(ValidationError::new(
6002                    1002,
6003                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
6004                ));
6005            }
6006        }
6007        if let Some(ref val) = self.dstrct_nm {
6008            if val.chars().count() < 1 {
6009                return Err(ValidationError::new(
6010                    1001,
6011                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
6012                ));
6013            }
6014            if val.chars().count() > 35 {
6015                return Err(ValidationError::new(
6016                    1002,
6017                    "dstrct_nm exceeds the maximum length of 35".to_string(),
6018                ));
6019            }
6020        }
6021        if let Some(ref val) = self.ctry_sub_dvsn {
6022            if val.chars().count() < 1 {
6023                return Err(ValidationError::new(
6024                    1001,
6025                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
6026                ));
6027            }
6028            if val.chars().count() > 35 {
6029                return Err(ValidationError::new(
6030                    1002,
6031                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
6032                ));
6033            }
6034        }
6035        if let Some(ref val) = self.ctry {
6036            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
6037            if !pattern.is_match(val) {
6038                return Err(ValidationError::new(
6039                    1005,
6040                    "ctry does not match the required pattern".to_string(),
6041                ));
6042            }
6043        }
6044        if let Some(ref vec) = self.adr_line {
6045            for item in vec {
6046                if item.chars().count() < 1 {
6047                    return Err(ValidationError::new(
6048                        1001,
6049                        "adr_line is shorter than the minimum length of 1".to_string(),
6050                    ));
6051                }
6052                if item.chars().count() > 70 {
6053                    return Err(ValidationError::new(
6054                        1002,
6055                        "adr_line exceeds the maximum length of 70".to_string(),
6056                    ));
6057                }
6058            }
6059        }
6060        Ok(())
6061    }
6062}
6063// PreferredContactMethod1Code ...
6064#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6065pub enum PreferredContactMethod1Code {
6066    #[default]
6067    #[serde(rename = "LETT")]
6068    CodeLETT,
6069    #[serde(rename = "MAIL")]
6070    CodeMAIL,
6071    #[serde(rename = "PHON")]
6072    CodePHON,
6073    #[serde(rename = "FAXX")]
6074    CodeFAXX,
6075    #[serde(rename = "CELL")]
6076    CodeCELL,
6077}
6078
6079impl PreferredContactMethod1Code {
6080    pub fn validate(&self) -> Result<(), ValidationError> {
6081        Ok(())
6082    }
6083}
6084// Price7 ...
6085#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6086pub struct Price7 {
6087    #[serde(rename = "Tp")]
6088    pub tp: YieldedOrValueType1Choice,
6089    #[serde(rename = "Val")]
6090    pub val: PriceRateOrAmount3Choice,
6091}
6092
6093impl Price7 {
6094    pub fn validate(&self) -> Result<(), ValidationError> {
6095        self.tp.validate()?;
6096        self.val.validate()?;
6097        Ok(())
6098    }
6099}
6100// PriceRateOrAmount3Choice ...
6101#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6102pub struct PriceRateOrAmount3Choice {
6103    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
6104    pub rate: Option<f64>,
6105    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
6106    pub amt: Option<ActiveOrHistoricCurrencyAnd13DecimalAmount>,
6107}
6108
6109impl PriceRateOrAmount3Choice {
6110    pub fn validate(&self) -> Result<(), ValidationError> {
6111        if let Some(ref val) = self.amt {
6112            val.validate()?
6113        }
6114        Ok(())
6115    }
6116}
6117// PriceValueType1Code ...
6118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6119pub enum PriceValueType1Code {
6120    #[default]
6121    #[serde(rename = "DISC")]
6122    CodeDISC,
6123    #[serde(rename = "PREM")]
6124    CodePREM,
6125    #[serde(rename = "PARV")]
6126    CodePARV,
6127}
6128
6129impl PriceValueType1Code {
6130    pub fn validate(&self) -> Result<(), ValidationError> {
6131        Ok(())
6132    }
6133}
6134// Priority2Code ...
6135#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6136pub enum Priority2Code {
6137    #[default]
6138    #[serde(rename = "HIGH")]
6139    CodeHIGH,
6140    #[serde(rename = "NORM")]
6141    CodeNORM,
6142}
6143
6144impl Priority2Code {
6145    pub fn validate(&self) -> Result<(), ValidationError> {
6146        Ok(())
6147    }
6148}
6149// Priority3Code ...
6150#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6151pub enum Priority3Code {
6152    #[default]
6153    #[serde(rename = "URGT")]
6154    CodeURGT,
6155    #[serde(rename = "HIGH")]
6156    CodeHIGH,
6157    #[serde(rename = "NORM")]
6158    CodeNORM,
6159}
6160
6161impl Priority3Code {
6162    pub fn validate(&self) -> Result<(), ValidationError> {
6163        Ok(())
6164    }
6165}
6166// Product2 ...
6167#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6168pub struct Product2 {
6169    #[serde(rename = "PdctCd")]
6170    pub pdct_cd: String,
6171    #[serde(rename = "UnitOfMeasr", skip_serializing_if = "Option::is_none")]
6172    pub unit_of_measr: Option<UnitOfMeasure1Code>,
6173    #[serde(rename = "PdctQty", skip_serializing_if = "Option::is_none")]
6174    pub pdct_qty: Option<f64>,
6175    #[serde(rename = "UnitPric", skip_serializing_if = "Option::is_none")]
6176    pub unit_pric: Option<f64>,
6177    #[serde(rename = "PdctAmt", skip_serializing_if = "Option::is_none")]
6178    pub pdct_amt: Option<f64>,
6179    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
6180    pub tax_tp: Option<String>,
6181    #[serde(rename = "AddtlPdctInf", skip_serializing_if = "Option::is_none")]
6182    pub addtl_pdct_inf: Option<String>,
6183}
6184
6185impl Product2 {
6186    pub fn validate(&self) -> Result<(), ValidationError> {
6187        if self.pdct_cd.chars().count() < 1 {
6188            return Err(ValidationError::new(
6189                1001,
6190                "pdct_cd is shorter than the minimum length of 1".to_string(),
6191            ));
6192        }
6193        if self.pdct_cd.chars().count() > 70 {
6194            return Err(ValidationError::new(
6195                1002,
6196                "pdct_cd exceeds the maximum length of 70".to_string(),
6197            ));
6198        }
6199        if let Some(ref val) = self.unit_of_measr {
6200            val.validate()?
6201        }
6202        if let Some(ref val) = self.tax_tp {
6203            if val.chars().count() < 1 {
6204                return Err(ValidationError::new(
6205                    1001,
6206                    "tax_tp is shorter than the minimum length of 1".to_string(),
6207                ));
6208            }
6209            if val.chars().count() > 35 {
6210                return Err(ValidationError::new(
6211                    1002,
6212                    "tax_tp exceeds the maximum length of 35".to_string(),
6213                ));
6214            }
6215        }
6216        if let Some(ref val) = self.addtl_pdct_inf {
6217            if val.chars().count() < 1 {
6218                return Err(ValidationError::new(
6219                    1001,
6220                    "addtl_pdct_inf is shorter than the minimum length of 1".to_string(),
6221                ));
6222            }
6223            if val.chars().count() > 35 {
6224                return Err(ValidationError::new(
6225                    1002,
6226                    "addtl_pdct_inf exceeds the maximum length of 35".to_string(),
6227                ));
6228            }
6229        }
6230        Ok(())
6231    }
6232}
6233// ProprietaryAgent4 ...
6234#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6235pub struct ProprietaryAgent4 {
6236    #[serde(rename = "Tp")]
6237    pub tp: String,
6238    #[serde(rename = "Agt")]
6239    pub agt: BranchAndFinancialInstitutionIdentification6,
6240}
6241
6242impl ProprietaryAgent4 {
6243    pub fn validate(&self) -> Result<(), ValidationError> {
6244        if self.tp.chars().count() < 1 {
6245            return Err(ValidationError::new(
6246                1001,
6247                "tp is shorter than the minimum length of 1".to_string(),
6248            ));
6249        }
6250        if self.tp.chars().count() > 35 {
6251            return Err(ValidationError::new(
6252                1002,
6253                "tp exceeds the maximum length of 35".to_string(),
6254            ));
6255        }
6256        self.agt.validate()?;
6257        Ok(())
6258    }
6259}
6260// ProprietaryBankTransactionCodeStructure1 ...
6261#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6262pub struct ProprietaryBankTransactionCodeStructure1 {
6263    #[serde(rename = "Cd")]
6264    pub cd: String,
6265    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
6266    pub issr: Option<String>,
6267}
6268
6269impl ProprietaryBankTransactionCodeStructure1 {
6270    pub fn validate(&self) -> Result<(), ValidationError> {
6271        if self.cd.chars().count() < 1 {
6272            return Err(ValidationError::new(
6273                1001,
6274                "cd is shorter than the minimum length of 1".to_string(),
6275            ));
6276        }
6277        if self.cd.chars().count() > 35 {
6278            return Err(ValidationError::new(
6279                1002,
6280                "cd exceeds the maximum length of 35".to_string(),
6281            ));
6282        }
6283        if let Some(ref val) = self.issr {
6284            if val.chars().count() < 1 {
6285                return Err(ValidationError::new(
6286                    1001,
6287                    "issr is shorter than the minimum length of 1".to_string(),
6288                ));
6289            }
6290            if val.chars().count() > 35 {
6291                return Err(ValidationError::new(
6292                    1002,
6293                    "issr exceeds the maximum length of 35".to_string(),
6294                ));
6295            }
6296        }
6297        Ok(())
6298    }
6299}
6300// ProprietaryDate3 ...
6301#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6302pub struct ProprietaryDate3 {
6303    #[serde(rename = "Tp")]
6304    pub tp: String,
6305    #[serde(rename = "Dt")]
6306    pub dt: DateAndDateTime2Choice,
6307}
6308
6309impl ProprietaryDate3 {
6310    pub fn validate(&self) -> Result<(), ValidationError> {
6311        if self.tp.chars().count() < 1 {
6312            return Err(ValidationError::new(
6313                1001,
6314                "tp is shorter than the minimum length of 1".to_string(),
6315            ));
6316        }
6317        if self.tp.chars().count() > 35 {
6318            return Err(ValidationError::new(
6319                1002,
6320                "tp exceeds the maximum length of 35".to_string(),
6321            ));
6322        }
6323        self.dt.validate()?;
6324        Ok(())
6325    }
6326}
6327// ProprietaryParty5 ...
6328#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6329pub struct ProprietaryParty5 {
6330    #[serde(rename = "Tp")]
6331    pub tp: String,
6332    #[serde(rename = "Pty")]
6333    pub pty: Party40Choice,
6334}
6335
6336impl ProprietaryParty5 {
6337    pub fn validate(&self) -> Result<(), ValidationError> {
6338        if self.tp.chars().count() < 1 {
6339            return Err(ValidationError::new(
6340                1001,
6341                "tp is shorter than the minimum length of 1".to_string(),
6342            ));
6343        }
6344        if self.tp.chars().count() > 35 {
6345            return Err(ValidationError::new(
6346                1002,
6347                "tp exceeds the maximum length of 35".to_string(),
6348            ));
6349        }
6350        self.pty.validate()?;
6351        Ok(())
6352    }
6353}
6354// ProprietaryPrice2 ...
6355#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6356pub struct ProprietaryPrice2 {
6357    #[serde(rename = "Tp")]
6358    pub tp: String,
6359    #[serde(rename = "Pric")]
6360    pub pric: ActiveOrHistoricCurrencyAndAmount,
6361}
6362
6363impl ProprietaryPrice2 {
6364    pub fn validate(&self) -> Result<(), ValidationError> {
6365        if self.tp.chars().count() < 1 {
6366            return Err(ValidationError::new(
6367                1001,
6368                "tp is shorter than the minimum length of 1".to_string(),
6369            ));
6370        }
6371        if self.tp.chars().count() > 35 {
6372            return Err(ValidationError::new(
6373                1002,
6374                "tp exceeds the maximum length of 35".to_string(),
6375            ));
6376        }
6377        self.pric.validate()?;
6378        Ok(())
6379    }
6380}
6381// ProprietaryQuantity1 ...
6382#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6383pub struct ProprietaryQuantity1 {
6384    #[serde(rename = "Tp")]
6385    pub tp: String,
6386    #[serde(rename = "Qty")]
6387    pub qty: String,
6388}
6389
6390impl ProprietaryQuantity1 {
6391    pub fn validate(&self) -> Result<(), ValidationError> {
6392        if self.tp.chars().count() < 1 {
6393            return Err(ValidationError::new(
6394                1001,
6395                "tp is shorter than the minimum length of 1".to_string(),
6396            ));
6397        }
6398        if self.tp.chars().count() > 35 {
6399            return Err(ValidationError::new(
6400                1002,
6401                "tp exceeds the maximum length of 35".to_string(),
6402            ));
6403        }
6404        if self.qty.chars().count() < 1 {
6405            return Err(ValidationError::new(
6406                1001,
6407                "qty is shorter than the minimum length of 1".to_string(),
6408            ));
6409        }
6410        if self.qty.chars().count() > 35 {
6411            return Err(ValidationError::new(
6412                1002,
6413                "qty exceeds the maximum length of 35".to_string(),
6414            ));
6415        }
6416        Ok(())
6417    }
6418}
6419// ProprietaryReference1 ...
6420#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6421pub struct ProprietaryReference1 {
6422    #[serde(rename = "Tp")]
6423    pub tp: String,
6424    #[serde(rename = "Ref")]
6425    pub ref_attr: String,
6426}
6427
6428impl ProprietaryReference1 {
6429    pub fn validate(&self) -> Result<(), ValidationError> {
6430        if self.tp.chars().count() < 1 {
6431            return Err(ValidationError::new(
6432                1001,
6433                "tp is shorter than the minimum length of 1".to_string(),
6434            ));
6435        }
6436        if self.tp.chars().count() > 35 {
6437            return Err(ValidationError::new(
6438                1002,
6439                "tp exceeds the maximum length of 35".to_string(),
6440            ));
6441        }
6442        if self.ref_attr.chars().count() < 1 {
6443            return Err(ValidationError::new(
6444                1001,
6445                "ref_attr is shorter than the minimum length of 1".to_string(),
6446            ));
6447        }
6448        if self.ref_attr.chars().count() > 35 {
6449            return Err(ValidationError::new(
6450                1002,
6451                "ref_attr exceeds the maximum length of 35".to_string(),
6452            ));
6453        }
6454        Ok(())
6455    }
6456}
6457// ProxyAccountIdentification1 ...
6458#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6459pub struct ProxyAccountIdentification1 {
6460    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6461    pub tp: Option<ProxyAccountType1Choice>,
6462    #[serde(rename = "Id")]
6463    pub id: String,
6464}
6465
6466impl ProxyAccountIdentification1 {
6467    pub fn validate(&self) -> Result<(), ValidationError> {
6468        if let Some(ref val) = self.tp {
6469            val.validate()?
6470        }
6471        if self.id.chars().count() < 1 {
6472            return Err(ValidationError::new(
6473                1001,
6474                "id is shorter than the minimum length of 1".to_string(),
6475            ));
6476        }
6477        if self.id.chars().count() > 2048 {
6478            return Err(ValidationError::new(
6479                1002,
6480                "id exceeds the maximum length of 2048".to_string(),
6481            ));
6482        }
6483        Ok(())
6484    }
6485}
6486// ProxyAccountType1Choice ...
6487#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6488pub struct ProxyAccountType1Choice {
6489    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6490    pub cd: Option<String>,
6491    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6492    pub prtry: Option<String>,
6493}
6494
6495impl ProxyAccountType1Choice {
6496    pub fn validate(&self) -> Result<(), ValidationError> {
6497        if let Some(ref val) = self.cd {
6498            if val.chars().count() < 1 {
6499                return Err(ValidationError::new(
6500                    1001,
6501                    "cd is shorter than the minimum length of 1".to_string(),
6502                ));
6503            }
6504            if val.chars().count() > 4 {
6505                return Err(ValidationError::new(
6506                    1002,
6507                    "cd exceeds the maximum length of 4".to_string(),
6508                ));
6509            }
6510        }
6511        if let Some(ref val) = self.prtry {
6512            if val.chars().count() < 1 {
6513                return Err(ValidationError::new(
6514                    1001,
6515                    "prtry is shorter than the minimum length of 1".to_string(),
6516                ));
6517            }
6518            if val.chars().count() > 35 {
6519                return Err(ValidationError::new(
6520                    1002,
6521                    "prtry exceeds the maximum length of 35".to_string(),
6522                ));
6523            }
6524        }
6525        Ok(())
6526    }
6527}
6528// Purpose2Choice ...
6529#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6530pub struct Purpose2Choice {
6531    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6532    pub cd: Option<String>,
6533    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6534    pub prtry: Option<String>,
6535}
6536
6537impl Purpose2Choice {
6538    pub fn validate(&self) -> Result<(), ValidationError> {
6539        if let Some(ref val) = self.cd {
6540            if val.chars().count() < 1 {
6541                return Err(ValidationError::new(
6542                    1001,
6543                    "cd is shorter than the minimum length of 1".to_string(),
6544                ));
6545            }
6546            if val.chars().count() > 4 {
6547                return Err(ValidationError::new(
6548                    1002,
6549                    "cd exceeds the maximum length of 4".to_string(),
6550                ));
6551            }
6552        }
6553        if let Some(ref val) = self.prtry {
6554            if val.chars().count() < 1 {
6555                return Err(ValidationError::new(
6556                    1001,
6557                    "prtry is shorter than the minimum length of 1".to_string(),
6558                ));
6559            }
6560            if val.chars().count() > 35 {
6561                return Err(ValidationError::new(
6562                    1002,
6563                    "prtry exceeds the maximum length of 35".to_string(),
6564                ));
6565            }
6566        }
6567        Ok(())
6568    }
6569}
6570// Rate4 ...
6571#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6572pub struct Rate4 {
6573    #[serde(rename = "Tp")]
6574    pub tp: RateType4Choice,
6575    #[serde(rename = "VldtyRg", skip_serializing_if = "Option::is_none")]
6576    pub vldty_rg: Option<ActiveOrHistoricCurrencyAndAmountRange2>,
6577}
6578
6579impl Rate4 {
6580    pub fn validate(&self) -> Result<(), ValidationError> {
6581        self.tp.validate()?;
6582        if let Some(ref val) = self.vldty_rg {
6583            val.validate()?
6584        }
6585        Ok(())
6586    }
6587}
6588// RateType4Choice ...
6589#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6590pub struct RateType4Choice {
6591    #[serde(rename = "Pctg", skip_serializing_if = "Option::is_none")]
6592    pub pctg: Option<f64>,
6593    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
6594    pub othr: Option<String>,
6595}
6596
6597impl RateType4Choice {
6598    pub fn validate(&self) -> Result<(), ValidationError> {
6599        if let Some(ref val) = self.othr {
6600            if val.chars().count() < 1 {
6601                return Err(ValidationError::new(
6602                    1001,
6603                    "othr is shorter than the minimum length of 1".to_string(),
6604                ));
6605            }
6606            if val.chars().count() > 35 {
6607                return Err(ValidationError::new(
6608                    1002,
6609                    "othr exceeds the maximum length of 35".to_string(),
6610                ));
6611            }
6612        }
6613        Ok(())
6614    }
6615}
6616// ReferredDocumentInformation7 ...
6617#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6618pub struct ReferredDocumentInformation7 {
6619    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6620    pub tp: Option<ReferredDocumentType4>,
6621    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
6622    pub nb: Option<String>,
6623    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
6624    pub rltd_dt: Option<String>,
6625    #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
6626    pub line_dtls: Option<Vec<DocumentLineInformation1>>,
6627}
6628
6629impl ReferredDocumentInformation7 {
6630    pub fn validate(&self) -> Result<(), ValidationError> {
6631        if let Some(ref val) = self.tp {
6632            val.validate()?
6633        }
6634        if let Some(ref val) = self.nb {
6635            if val.chars().count() < 1 {
6636                return Err(ValidationError::new(
6637                    1001,
6638                    "nb is shorter than the minimum length of 1".to_string(),
6639                ));
6640            }
6641            if val.chars().count() > 35 {
6642                return Err(ValidationError::new(
6643                    1002,
6644                    "nb exceeds the maximum length of 35".to_string(),
6645                ));
6646            }
6647        }
6648        if let Some(ref vec) = self.line_dtls {
6649            for item in vec {
6650                item.validate()?
6651            }
6652        }
6653        Ok(())
6654    }
6655}
6656// ReferredDocumentType3Choice ...
6657#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6658pub struct ReferredDocumentType3Choice {
6659    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6660    pub cd: Option<DocumentType6Code>,
6661    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6662    pub prtry: Option<String>,
6663}
6664
6665impl ReferredDocumentType3Choice {
6666    pub fn validate(&self) -> Result<(), ValidationError> {
6667        if let Some(ref val) = self.cd {
6668            val.validate()?
6669        }
6670        if let Some(ref val) = self.prtry {
6671            if val.chars().count() < 1 {
6672                return Err(ValidationError::new(
6673                    1001,
6674                    "prtry is shorter than the minimum length of 1".to_string(),
6675                ));
6676            }
6677            if val.chars().count() > 35 {
6678                return Err(ValidationError::new(
6679                    1002,
6680                    "prtry exceeds the maximum length of 35".to_string(),
6681                ));
6682            }
6683        }
6684        Ok(())
6685    }
6686}
6687// ReferredDocumentType4 ...
6688#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6689pub struct ReferredDocumentType4 {
6690    #[serde(rename = "CdOrPrtry")]
6691    pub cd_or_prtry: ReferredDocumentType3Choice,
6692    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
6693    pub issr: Option<String>,
6694}
6695
6696impl ReferredDocumentType4 {
6697    pub fn validate(&self) -> Result<(), ValidationError> {
6698        self.cd_or_prtry.validate()?;
6699        if let Some(ref val) = self.issr {
6700            if val.chars().count() < 1 {
6701                return Err(ValidationError::new(
6702                    1001,
6703                    "issr is shorter than the minimum length of 1".to_string(),
6704                ));
6705            }
6706            if val.chars().count() > 35 {
6707                return Err(ValidationError::new(
6708                    1002,
6709                    "issr exceeds the maximum length of 35".to_string(),
6710                ));
6711            }
6712        }
6713        Ok(())
6714    }
6715}
6716// RemittanceAmount2 ...
6717#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6718pub struct RemittanceAmount2 {
6719    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
6720    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6721    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
6722    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
6723    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
6724    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6725    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
6726    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
6727    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
6728    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
6729    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
6730    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6731}
6732
6733impl RemittanceAmount2 {
6734    pub fn validate(&self) -> Result<(), ValidationError> {
6735        if let Some(ref val) = self.due_pybl_amt {
6736            val.validate()?
6737        }
6738        if let Some(ref vec) = self.dscnt_apld_amt {
6739            for item in vec {
6740                item.validate()?
6741            }
6742        }
6743        if let Some(ref val) = self.cdt_note_amt {
6744            val.validate()?
6745        }
6746        if let Some(ref vec) = self.tax_amt {
6747            for item in vec {
6748                item.validate()?
6749            }
6750        }
6751        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
6752            for item in vec {
6753                item.validate()?
6754            }
6755        }
6756        if let Some(ref val) = self.rmtd_amt {
6757            val.validate()?
6758        }
6759        Ok(())
6760    }
6761}
6762// RemittanceAmount3 ...
6763#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6764pub struct RemittanceAmount3 {
6765    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
6766    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6767    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
6768    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
6769    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
6770    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6771    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
6772    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
6773    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
6774    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
6775    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
6776    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6777}
6778
6779impl RemittanceAmount3 {
6780    pub fn validate(&self) -> Result<(), ValidationError> {
6781        if let Some(ref val) = self.due_pybl_amt {
6782            val.validate()?
6783        }
6784        if let Some(ref vec) = self.dscnt_apld_amt {
6785            for item in vec {
6786                item.validate()?
6787            }
6788        }
6789        if let Some(ref val) = self.cdt_note_amt {
6790            val.validate()?
6791        }
6792        if let Some(ref vec) = self.tax_amt {
6793            for item in vec {
6794                item.validate()?
6795            }
6796        }
6797        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
6798            for item in vec {
6799                item.validate()?
6800            }
6801        }
6802        if let Some(ref val) = self.rmtd_amt {
6803            val.validate()?
6804        }
6805        Ok(())
6806    }
6807}
6808// RemittanceInformation16 ...
6809#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6810pub struct RemittanceInformation16 {
6811    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
6812    pub ustrd: Option<Vec<String>>,
6813    #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
6814    pub strd: Option<Vec<StructuredRemittanceInformation16>>,
6815}
6816
6817impl RemittanceInformation16 {
6818    pub fn validate(&self) -> Result<(), ValidationError> {
6819        if let Some(ref vec) = self.ustrd {
6820            for item in vec {
6821                if item.chars().count() < 1 {
6822                    return Err(ValidationError::new(
6823                        1001,
6824                        "ustrd is shorter than the minimum length of 1".to_string(),
6825                    ));
6826                }
6827                if item.chars().count() > 140 {
6828                    return Err(ValidationError::new(
6829                        1002,
6830                        "ustrd exceeds the maximum length of 140".to_string(),
6831                    ));
6832                }
6833            }
6834        }
6835        if let Some(ref vec) = self.strd {
6836            for item in vec {
6837                item.validate()?
6838            }
6839        }
6840        Ok(())
6841    }
6842}
6843// RemittanceLocation7 ...
6844#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6845pub struct RemittanceLocation7 {
6846    #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
6847    pub rmt_id: Option<String>,
6848    #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
6849    pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData1>>,
6850}
6851
6852impl RemittanceLocation7 {
6853    pub fn validate(&self) -> Result<(), ValidationError> {
6854        if let Some(ref val) = self.rmt_id {
6855            if val.chars().count() < 1 {
6856                return Err(ValidationError::new(
6857                    1001,
6858                    "rmt_id is shorter than the minimum length of 1".to_string(),
6859                ));
6860            }
6861            if val.chars().count() > 35 {
6862                return Err(ValidationError::new(
6863                    1002,
6864                    "rmt_id exceeds the maximum length of 35".to_string(),
6865                ));
6866            }
6867        }
6868        if let Some(ref vec) = self.rmt_lctn_dtls {
6869            for item in vec {
6870                item.validate()?
6871            }
6872        }
6873        Ok(())
6874    }
6875}
6876// RemittanceLocationData1 ...
6877#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6878pub struct RemittanceLocationData1 {
6879    #[serde(rename = "Mtd")]
6880    pub mtd: RemittanceLocationMethod2Code,
6881    #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
6882    pub elctrnc_adr: Option<String>,
6883    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
6884    pub pstl_adr: Option<NameAndAddress16>,
6885}
6886
6887impl RemittanceLocationData1 {
6888    pub fn validate(&self) -> Result<(), ValidationError> {
6889        self.mtd.validate()?;
6890        if let Some(ref val) = self.elctrnc_adr {
6891            if val.chars().count() < 1 {
6892                return Err(ValidationError::new(
6893                    1001,
6894                    "elctrnc_adr is shorter than the minimum length of 1".to_string(),
6895                ));
6896            }
6897            if val.chars().count() > 2048 {
6898                return Err(ValidationError::new(
6899                    1002,
6900                    "elctrnc_adr exceeds the maximum length of 2048".to_string(),
6901                ));
6902            }
6903        }
6904        if let Some(ref val) = self.pstl_adr {
6905            val.validate()?
6906        }
6907        Ok(())
6908    }
6909}
6910// RemittanceLocationMethod2Code ...
6911#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6912pub enum RemittanceLocationMethod2Code {
6913    #[default]
6914    #[serde(rename = "FAXI")]
6915    CodeFAXI,
6916    #[serde(rename = "EDIC")]
6917    CodeEDIC,
6918    #[serde(rename = "URID")]
6919    CodeURID,
6920    #[serde(rename = "EMAL")]
6921    CodeEMAL,
6922    #[serde(rename = "POST")]
6923    CodePOST,
6924    #[serde(rename = "SMSM")]
6925    CodeSMSM,
6926}
6927
6928impl RemittanceLocationMethod2Code {
6929    pub fn validate(&self) -> Result<(), ValidationError> {
6930        Ok(())
6931    }
6932}
6933// ReportEntry10 ...
6934#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6935pub struct ReportEntry10 {
6936    #[serde(rename = "NtryRef", skip_serializing_if = "Option::is_none")]
6937    pub ntry_ref: Option<String>,
6938    #[serde(rename = "Amt")]
6939    pub amt: ActiveOrHistoricCurrencyAndAmount,
6940    #[serde(rename = "CdtDbtInd")]
6941    pub cdt_dbt_ind: CreditDebitCode,
6942    #[serde(rename = "RvslInd", skip_serializing_if = "Option::is_none")]
6943    pub rvsl_ind: Option<bool>,
6944    #[serde(rename = "Sts")]
6945    pub sts: EntryStatus1Choice,
6946    #[serde(rename = "BookgDt", skip_serializing_if = "Option::is_none")]
6947    pub bookg_dt: Option<DateAndDateTime2Choice>,
6948    #[serde(rename = "ValDt", skip_serializing_if = "Option::is_none")]
6949    pub val_dt: Option<DateAndDateTime2Choice>,
6950    #[serde(rename = "AcctSvcrRef", skip_serializing_if = "Option::is_none")]
6951    pub acct_svcr_ref: Option<String>,
6952    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
6953    pub avlbty: Option<Vec<CashAvailability1>>,
6954    #[serde(rename = "BkTxCd")]
6955    pub bk_tx_cd: BankTransactionCodeStructure4,
6956    #[serde(rename = "ComssnWvrInd", skip_serializing_if = "Option::is_none")]
6957    pub comssn_wvr_ind: Option<bool>,
6958    #[serde(rename = "AddtlInfInd", skip_serializing_if = "Option::is_none")]
6959    pub addtl_inf_ind: Option<MessageIdentification2>,
6960    #[serde(rename = "AmtDtls", skip_serializing_if = "Option::is_none")]
6961    pub amt_dtls: Option<AmountAndCurrencyExchange3>,
6962    #[serde(rename = "Chrgs", skip_serializing_if = "Option::is_none")]
6963    pub chrgs: Option<Charges6>,
6964    #[serde(rename = "TechInptChanl", skip_serializing_if = "Option::is_none")]
6965    pub tech_inpt_chanl: Option<TechnicalInputChannel1Choice>,
6966    #[serde(rename = "Intrst", skip_serializing_if = "Option::is_none")]
6967    pub intrst: Option<TransactionInterest4>,
6968    #[serde(rename = "CardTx", skip_serializing_if = "Option::is_none")]
6969    pub card_tx: Option<CardEntry4>,
6970    #[serde(rename = "NtryDtls", skip_serializing_if = "Option::is_none")]
6971    pub ntry_dtls: Option<Vec<EntryDetails9>>,
6972    #[serde(rename = "AddtlNtryInf", skip_serializing_if = "Option::is_none")]
6973    pub addtl_ntry_inf: Option<String>,
6974}
6975
6976impl ReportEntry10 {
6977    pub fn validate(&self) -> Result<(), ValidationError> {
6978        if let Some(ref val) = self.ntry_ref {
6979            if val.chars().count() < 1 {
6980                return Err(ValidationError::new(
6981                    1001,
6982                    "ntry_ref is shorter than the minimum length of 1".to_string(),
6983                ));
6984            }
6985            if val.chars().count() > 35 {
6986                return Err(ValidationError::new(
6987                    1002,
6988                    "ntry_ref exceeds the maximum length of 35".to_string(),
6989                ));
6990            }
6991        }
6992        self.amt.validate()?;
6993        self.cdt_dbt_ind.validate()?;
6994        self.sts.validate()?;
6995        if let Some(ref val) = self.bookg_dt {
6996            val.validate()?
6997        }
6998        if let Some(ref val) = self.val_dt {
6999            val.validate()?
7000        }
7001        if let Some(ref val) = self.acct_svcr_ref {
7002            if val.chars().count() < 1 {
7003                return Err(ValidationError::new(
7004                    1001,
7005                    "acct_svcr_ref is shorter than the minimum length of 1".to_string(),
7006                ));
7007            }
7008            if val.chars().count() > 35 {
7009                return Err(ValidationError::new(
7010                    1002,
7011                    "acct_svcr_ref exceeds the maximum length of 35".to_string(),
7012                ));
7013            }
7014        }
7015        if let Some(ref vec) = self.avlbty {
7016            for item in vec {
7017                item.validate()?
7018            }
7019        }
7020        self.bk_tx_cd.validate()?;
7021        if let Some(ref val) = self.addtl_inf_ind {
7022            val.validate()?
7023        }
7024        if let Some(ref val) = self.amt_dtls {
7025            val.validate()?
7026        }
7027        if let Some(ref val) = self.chrgs {
7028            val.validate()?
7029        }
7030        if let Some(ref val) = self.tech_inpt_chanl {
7031            val.validate()?
7032        }
7033        if let Some(ref val) = self.intrst {
7034            val.validate()?
7035        }
7036        if let Some(ref val) = self.card_tx {
7037            val.validate()?
7038        }
7039        if let Some(ref vec) = self.ntry_dtls {
7040            for item in vec {
7041                item.validate()?
7042            }
7043        }
7044        if let Some(ref val) = self.addtl_ntry_inf {
7045            if val.chars().count() < 1 {
7046                return Err(ValidationError::new(
7047                    1001,
7048                    "addtl_ntry_inf is shorter than the minimum length of 1".to_string(),
7049                ));
7050            }
7051            if val.chars().count() > 500 {
7052                return Err(ValidationError::new(
7053                    1002,
7054                    "addtl_ntry_inf exceeds the maximum length of 500".to_string(),
7055                ));
7056            }
7057        }
7058        Ok(())
7059    }
7060}
7061// ReportingSource1Choice ...
7062#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7063pub struct ReportingSource1Choice {
7064    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7065    pub cd: Option<String>,
7066    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7067    pub prtry: Option<String>,
7068}
7069
7070impl ReportingSource1Choice {
7071    pub fn validate(&self) -> Result<(), ValidationError> {
7072        if let Some(ref val) = self.cd {
7073            if val.chars().count() < 1 {
7074                return Err(ValidationError::new(
7075                    1001,
7076                    "cd is shorter than the minimum length of 1".to_string(),
7077                ));
7078            }
7079            if val.chars().count() > 4 {
7080                return Err(ValidationError::new(
7081                    1002,
7082                    "cd exceeds the maximum length of 4".to_string(),
7083                ));
7084            }
7085        }
7086        if let Some(ref val) = self.prtry {
7087            if val.chars().count() < 1 {
7088                return Err(ValidationError::new(
7089                    1001,
7090                    "prtry is shorter than the minimum length of 1".to_string(),
7091                ));
7092            }
7093            if val.chars().count() > 35 {
7094                return Err(ValidationError::new(
7095                    1002,
7096                    "prtry exceeds the maximum length of 35".to_string(),
7097                ));
7098            }
7099        }
7100        Ok(())
7101    }
7102}
7103// ReturnReason5Choice ...
7104#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7105pub struct ReturnReason5Choice {
7106    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7107    pub cd: Option<String>,
7108    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7109    pub prtry: Option<String>,
7110}
7111
7112impl ReturnReason5Choice {
7113    pub fn validate(&self) -> Result<(), ValidationError> {
7114        if let Some(ref val) = self.cd {
7115            if val.chars().count() < 1 {
7116                return Err(ValidationError::new(
7117                    1001,
7118                    "cd is shorter than the minimum length of 1".to_string(),
7119                ));
7120            }
7121            if val.chars().count() > 4 {
7122                return Err(ValidationError::new(
7123                    1002,
7124                    "cd exceeds the maximum length of 4".to_string(),
7125                ));
7126            }
7127        }
7128        if let Some(ref val) = self.prtry {
7129            if val.chars().count() < 1 {
7130                return Err(ValidationError::new(
7131                    1001,
7132                    "prtry is shorter than the minimum length of 1".to_string(),
7133                ));
7134            }
7135            if val.chars().count() > 35 {
7136                return Err(ValidationError::new(
7137                    1002,
7138                    "prtry exceeds the maximum length of 35".to_string(),
7139                ));
7140            }
7141        }
7142        Ok(())
7143    }
7144}
7145// SecuritiesAccount19 ...
7146#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7147pub struct SecuritiesAccount19 {
7148    #[serde(rename = "Id")]
7149    pub id: String,
7150    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7151    pub tp: Option<GenericIdentification30>,
7152    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
7153    pub nm: Option<String>,
7154}
7155
7156impl SecuritiesAccount19 {
7157    pub fn validate(&self) -> Result<(), ValidationError> {
7158        if self.id.chars().count() < 1 {
7159            return Err(ValidationError::new(
7160                1001,
7161                "id is shorter than the minimum length of 1".to_string(),
7162            ));
7163        }
7164        if self.id.chars().count() > 35 {
7165            return Err(ValidationError::new(
7166                1002,
7167                "id exceeds the maximum length of 35".to_string(),
7168            ));
7169        }
7170        if let Some(ref val) = self.tp {
7171            val.validate()?
7172        }
7173        if let Some(ref val) = self.nm {
7174            if val.chars().count() < 1 {
7175                return Err(ValidationError::new(
7176                    1001,
7177                    "nm is shorter than the minimum length of 1".to_string(),
7178                ));
7179            }
7180            if val.chars().count() > 70 {
7181                return Err(ValidationError::new(
7182                    1002,
7183                    "nm exceeds the maximum length of 70".to_string(),
7184                ));
7185            }
7186        }
7187        Ok(())
7188    }
7189}
7190// SecurityIdentification19 ...
7191#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7192pub struct SecurityIdentification19 {
7193    #[serde(rename = "ISIN", skip_serializing_if = "Option::is_none")]
7194    pub isin: Option<String>,
7195    #[serde(rename = "OthrId", skip_serializing_if = "Option::is_none")]
7196    pub othr_id: Option<Vec<OtherIdentification1>>,
7197    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
7198    pub desc: Option<String>,
7199}
7200
7201impl SecurityIdentification19 {
7202    pub fn validate(&self) -> Result<(), ValidationError> {
7203        if let Some(ref val) = self.isin {
7204            let pattern = Regex::new("[A-Z]{2,2}[A-Z0-9]{9,9}[0-9]{1,1}").unwrap();
7205            if !pattern.is_match(val) {
7206                return Err(ValidationError::new(
7207                    1005,
7208                    "isin does not match the required pattern".to_string(),
7209                ));
7210            }
7211        }
7212        if let Some(ref vec) = self.othr_id {
7213            for item in vec {
7214                item.validate()?
7215            }
7216        }
7217        if let Some(ref val) = self.desc {
7218            if val.chars().count() < 1 {
7219                return Err(ValidationError::new(
7220                    1001,
7221                    "desc is shorter than the minimum length of 1".to_string(),
7222                ));
7223            }
7224            if val.chars().count() > 140 {
7225                return Err(ValidationError::new(
7226                    1002,
7227                    "desc exceeds the maximum length of 140".to_string(),
7228                ));
7229            }
7230        }
7231        Ok(())
7232    }
7233}
7234// SequenceRange1 ...
7235#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7236pub struct SequenceRange1 {
7237    #[serde(rename = "FrSeq")]
7238    pub fr_seq: String,
7239    #[serde(rename = "ToSeq")]
7240    pub to_seq: String,
7241}
7242
7243impl SequenceRange1 {
7244    pub fn validate(&self) -> Result<(), ValidationError> {
7245        if self.fr_seq.chars().count() < 1 {
7246            return Err(ValidationError::new(
7247                1001,
7248                "fr_seq is shorter than the minimum length of 1".to_string(),
7249            ));
7250        }
7251        if self.fr_seq.chars().count() > 35 {
7252            return Err(ValidationError::new(
7253                1002,
7254                "fr_seq exceeds the maximum length of 35".to_string(),
7255            ));
7256        }
7257        if self.to_seq.chars().count() < 1 {
7258            return Err(ValidationError::new(
7259                1001,
7260                "to_seq is shorter than the minimum length of 1".to_string(),
7261            ));
7262        }
7263        if self.to_seq.chars().count() > 35 {
7264            return Err(ValidationError::new(
7265                1002,
7266                "to_seq exceeds the maximum length of 35".to_string(),
7267            ));
7268        }
7269        Ok(())
7270    }
7271}
7272// SequenceRange1Choice ...
7273#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7274pub struct SequenceRange1Choice {
7275    #[serde(rename = "FrSeq", skip_serializing_if = "Option::is_none")]
7276    pub fr_seq: Option<String>,
7277    #[serde(rename = "ToSeq", skip_serializing_if = "Option::is_none")]
7278    pub to_seq: Option<String>,
7279    #[serde(rename = "FrToSeq", skip_serializing_if = "Option::is_none")]
7280    pub fr_to_seq: Option<Vec<SequenceRange1>>,
7281    #[serde(rename = "EQSeq", skip_serializing_if = "Option::is_none")]
7282    pub eq_seq: Option<Vec<String>>,
7283    #[serde(rename = "NEQSeq", skip_serializing_if = "Option::is_none")]
7284    pub neq_seq: Option<Vec<String>>,
7285}
7286
7287impl SequenceRange1Choice {
7288    pub fn validate(&self) -> Result<(), ValidationError> {
7289        if let Some(ref val) = self.fr_seq {
7290            if val.chars().count() < 1 {
7291                return Err(ValidationError::new(
7292                    1001,
7293                    "fr_seq is shorter than the minimum length of 1".to_string(),
7294                ));
7295            }
7296            if val.chars().count() > 35 {
7297                return Err(ValidationError::new(
7298                    1002,
7299                    "fr_seq exceeds the maximum length of 35".to_string(),
7300                ));
7301            }
7302        }
7303        if let Some(ref val) = self.to_seq {
7304            if val.chars().count() < 1 {
7305                return Err(ValidationError::new(
7306                    1001,
7307                    "to_seq is shorter than the minimum length of 1".to_string(),
7308                ));
7309            }
7310            if val.chars().count() > 35 {
7311                return Err(ValidationError::new(
7312                    1002,
7313                    "to_seq exceeds the maximum length of 35".to_string(),
7314                ));
7315            }
7316        }
7317        if let Some(ref vec) = self.fr_to_seq {
7318            for item in vec {
7319                item.validate()?
7320            }
7321        }
7322        if let Some(ref vec) = self.eq_seq {
7323            for item in vec {
7324                if item.chars().count() < 1 {
7325                    return Err(ValidationError::new(
7326                        1001,
7327                        "eq_seq is shorter than the minimum length of 1".to_string(),
7328                    ));
7329                }
7330                if item.chars().count() > 35 {
7331                    return Err(ValidationError::new(
7332                        1002,
7333                        "eq_seq exceeds the maximum length of 35".to_string(),
7334                    ));
7335                }
7336            }
7337        }
7338        if let Some(ref vec) = self.neq_seq {
7339            for item in vec {
7340                if item.chars().count() < 1 {
7341                    return Err(ValidationError::new(
7342                        1001,
7343                        "neq_seq is shorter than the minimum length of 1".to_string(),
7344                    ));
7345                }
7346                if item.chars().count() > 35 {
7347                    return Err(ValidationError::new(
7348                        1002,
7349                        "neq_seq exceeds the maximum length of 35".to_string(),
7350                    ));
7351                }
7352            }
7353        }
7354        Ok(())
7355    }
7356}
7357// SequenceType3Code ...
7358#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7359pub enum SequenceType3Code {
7360    #[default]
7361    #[serde(rename = "FRST")]
7362    CodeFRST,
7363    #[serde(rename = "RCUR")]
7364    CodeRCUR,
7365    #[serde(rename = "FNAL")]
7366    CodeFNAL,
7367    #[serde(rename = "OOFF")]
7368    CodeOOFF,
7369    #[serde(rename = "RPRE")]
7370    CodeRPRE,
7371}
7372
7373impl SequenceType3Code {
7374    pub fn validate(&self) -> Result<(), ValidationError> {
7375        Ok(())
7376    }
7377}
7378// ServiceLevel8Choice ...
7379#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7380pub struct ServiceLevel8Choice {
7381    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7382    pub cd: Option<String>,
7383    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7384    pub prtry: Option<String>,
7385}
7386
7387impl ServiceLevel8Choice {
7388    pub fn validate(&self) -> Result<(), ValidationError> {
7389        if let Some(ref val) = self.cd {
7390            if val.chars().count() < 1 {
7391                return Err(ValidationError::new(
7392                    1001,
7393                    "cd is shorter than the minimum length of 1".to_string(),
7394                ));
7395            }
7396            if val.chars().count() > 4 {
7397                return Err(ValidationError::new(
7398                    1002,
7399                    "cd exceeds the maximum length of 4".to_string(),
7400                ));
7401            }
7402        }
7403        if let Some(ref val) = self.prtry {
7404            if val.chars().count() < 1 {
7405                return Err(ValidationError::new(
7406                    1001,
7407                    "prtry is shorter than the minimum length of 1".to_string(),
7408                ));
7409            }
7410            if val.chars().count() > 35 {
7411                return Err(ValidationError::new(
7412                    1002,
7413                    "prtry exceeds the maximum length of 35".to_string(),
7414                ));
7415            }
7416        }
7417        Ok(())
7418    }
7419}
7420// SettlementDateTimeIndication1 ...
7421#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7422pub struct SettlementDateTimeIndication1 {
7423    #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
7424    pub dbt_dt_tm: Option<String>,
7425    #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
7426    pub cdt_dt_tm: Option<String>,
7427}
7428
7429impl SettlementDateTimeIndication1 {
7430    pub fn validate(&self) -> Result<(), ValidationError> {
7431        Ok(())
7432    }
7433}
7434// SettlementInstruction7 ...
7435#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7436pub struct SettlementInstruction7 {
7437    #[serde(rename = "SttlmMtd")]
7438    pub sttlm_mtd: SettlementMethod1Code,
7439    #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
7440    pub sttlm_acct: Option<CashAccount38>,
7441    #[serde(rename = "ClrSys", skip_serializing_if = "Option::is_none")]
7442    pub clr_sys: Option<ClearingSystemIdentification3Choice>,
7443    #[serde(rename = "InstgRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
7444    pub instg_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
7445    #[serde(
7446        rename = "InstgRmbrsmntAgtAcct",
7447        skip_serializing_if = "Option::is_none"
7448    )]
7449    pub instg_rmbrsmnt_agt_acct: Option<CashAccount38>,
7450    #[serde(rename = "InstdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
7451    pub instd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
7452    #[serde(
7453        rename = "InstdRmbrsmntAgtAcct",
7454        skip_serializing_if = "Option::is_none"
7455    )]
7456    pub instd_rmbrsmnt_agt_acct: Option<CashAccount38>,
7457    #[serde(rename = "ThrdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
7458    pub thrd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
7459    #[serde(
7460        rename = "ThrdRmbrsmntAgtAcct",
7461        skip_serializing_if = "Option::is_none"
7462    )]
7463    pub thrd_rmbrsmnt_agt_acct: Option<CashAccount38>,
7464}
7465
7466impl SettlementInstruction7 {
7467    pub fn validate(&self) -> Result<(), ValidationError> {
7468        self.sttlm_mtd.validate()?;
7469        if let Some(ref val) = self.sttlm_acct {
7470            val.validate()?
7471        }
7472        if let Some(ref val) = self.clr_sys {
7473            val.validate()?
7474        }
7475        if let Some(ref val) = self.instg_rmbrsmnt_agt {
7476            val.validate()?
7477        }
7478        if let Some(ref val) = self.instg_rmbrsmnt_agt_acct {
7479            val.validate()?
7480        }
7481        if let Some(ref val) = self.instd_rmbrsmnt_agt {
7482            val.validate()?
7483        }
7484        if let Some(ref val) = self.instd_rmbrsmnt_agt_acct {
7485            val.validate()?
7486        }
7487        if let Some(ref val) = self.thrd_rmbrsmnt_agt {
7488            val.validate()?
7489        }
7490        if let Some(ref val) = self.thrd_rmbrsmnt_agt_acct {
7491            val.validate()?
7492        }
7493        Ok(())
7494    }
7495}
7496// SettlementMethod1Code ...
7497#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7498pub enum SettlementMethod1Code {
7499    #[default]
7500    #[serde(rename = "INDA")]
7501    CodeINDA,
7502    #[serde(rename = "INGA")]
7503    CodeINGA,
7504    #[serde(rename = "COVE")]
7505    CodeCOVE,
7506    #[serde(rename = "CLRG")]
7507    CodeCLRG,
7508}
7509
7510impl SettlementMethod1Code {
7511    pub fn validate(&self) -> Result<(), ValidationError> {
7512        Ok(())
7513    }
7514}
7515// SettlementTimeRequest2 ...
7516#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7517pub struct SettlementTimeRequest2 {
7518    #[serde(rename = "CLSTm", skip_serializing_if = "Option::is_none")]
7519    pub cls_tm: Option<String>,
7520    #[serde(rename = "TillTm", skip_serializing_if = "Option::is_none")]
7521    pub till_tm: Option<String>,
7522    #[serde(rename = "FrTm", skip_serializing_if = "Option::is_none")]
7523    pub fr_tm: Option<String>,
7524    #[serde(rename = "RjctTm", skip_serializing_if = "Option::is_none")]
7525    pub rjct_tm: Option<String>,
7526}
7527
7528impl SettlementTimeRequest2 {
7529    pub fn validate(&self) -> Result<(), ValidationError> {
7530        Ok(())
7531    }
7532}
7533// StructuredRemittanceInformation16 ...
7534#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7535pub struct StructuredRemittanceInformation16 {
7536    #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
7537    pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation7>>,
7538    #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
7539    pub rfrd_doc_amt: Option<RemittanceAmount2>,
7540    #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
7541    pub cdtr_ref_inf: Option<CreditorReferenceInformation2>,
7542    #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
7543    pub invcr: Option<PartyIdentification135>,
7544    #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
7545    pub invcee: Option<PartyIdentification135>,
7546    #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
7547    pub tax_rmt: Option<TaxInformation7>,
7548    #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
7549    pub grnshmt_rmt: Option<Garnishment3>,
7550    #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
7551    pub addtl_rmt_inf: Option<Vec<String>>,
7552}
7553
7554impl StructuredRemittanceInformation16 {
7555    pub fn validate(&self) -> Result<(), ValidationError> {
7556        if let Some(ref vec) = self.rfrd_doc_inf {
7557            for item in vec {
7558                item.validate()?
7559            }
7560        }
7561        if let Some(ref val) = self.rfrd_doc_amt {
7562            val.validate()?
7563        }
7564        if let Some(ref val) = self.cdtr_ref_inf {
7565            val.validate()?
7566        }
7567        if let Some(ref val) = self.invcr {
7568            val.validate()?
7569        }
7570        if let Some(ref val) = self.invcee {
7571            val.validate()?
7572        }
7573        if let Some(ref val) = self.tax_rmt {
7574            val.validate()?
7575        }
7576        if let Some(ref val) = self.grnshmt_rmt {
7577            val.validate()?
7578        }
7579        if let Some(ref vec) = self.addtl_rmt_inf {
7580            for item in vec {
7581                if item.chars().count() < 1 {
7582                    return Err(ValidationError::new(
7583                        1001,
7584                        "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
7585                    ));
7586                }
7587                if item.chars().count() > 140 {
7588                    return Err(ValidationError::new(
7589                        1002,
7590                        "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
7591                    ));
7592                }
7593            }
7594        }
7595        Ok(())
7596    }
7597}
7598// SupplementaryData1 ...
7599#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7600pub struct SupplementaryData1 {
7601    #[serde(rename = "PlcAndNm", skip_serializing_if = "Option::is_none")]
7602    pub plc_and_nm: Option<String>,
7603    #[serde(rename = "Envlp")]
7604    pub envlp: SupplementaryDataEnvelope1,
7605}
7606
7607impl SupplementaryData1 {
7608    pub fn validate(&self) -> Result<(), ValidationError> {
7609        if let Some(ref val) = self.plc_and_nm {
7610            if val.chars().count() < 1 {
7611                return Err(ValidationError::new(
7612                    1001,
7613                    "plc_and_nm is shorter than the minimum length of 1".to_string(),
7614                ));
7615            }
7616            if val.chars().count() > 350 {
7617                return Err(ValidationError::new(
7618                    1002,
7619                    "plc_and_nm exceeds the maximum length of 350".to_string(),
7620                ));
7621            }
7622        }
7623        self.envlp.validate()?;
7624        Ok(())
7625    }
7626}
7627// SupplementaryDataEnvelope1 ...
7628#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7629pub struct SupplementaryDataEnvelope1 {}
7630
7631impl SupplementaryDataEnvelope1 {
7632    pub fn validate(&self) -> Result<(), ValidationError> {
7633        Ok(())
7634    }
7635}
7636// TaxAmount2 ...
7637#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7638pub struct TaxAmount2 {
7639    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
7640    pub rate: Option<f64>,
7641    #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
7642    pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7643    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
7644    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7645    #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
7646    pub dtls: Option<Vec<TaxRecordDetails2>>,
7647}
7648
7649impl TaxAmount2 {
7650    pub fn validate(&self) -> Result<(), ValidationError> {
7651        if let Some(ref val) = self.taxbl_base_amt {
7652            val.validate()?
7653        }
7654        if let Some(ref val) = self.ttl_amt {
7655            val.validate()?
7656        }
7657        if let Some(ref vec) = self.dtls {
7658            for item in vec {
7659                item.validate()?
7660            }
7661        }
7662        Ok(())
7663    }
7664}
7665// TaxAmountAndType1 ...
7666#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7667pub struct TaxAmountAndType1 {
7668    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7669    pub tp: Option<TaxAmountType1Choice>,
7670    #[serde(rename = "Amt")]
7671    pub amt: ActiveOrHistoricCurrencyAndAmount,
7672}
7673
7674impl TaxAmountAndType1 {
7675    pub fn validate(&self) -> Result<(), ValidationError> {
7676        if let Some(ref val) = self.tp {
7677            val.validate()?
7678        }
7679        self.amt.validate()?;
7680        Ok(())
7681    }
7682}
7683// TaxAmountType1Choice ...
7684#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7685pub struct TaxAmountType1Choice {
7686    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7687    pub cd: Option<String>,
7688    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7689    pub prtry: Option<String>,
7690}
7691
7692impl TaxAmountType1Choice {
7693    pub fn validate(&self) -> Result<(), ValidationError> {
7694        if let Some(ref val) = self.cd {
7695            if val.chars().count() < 1 {
7696                return Err(ValidationError::new(
7697                    1001,
7698                    "cd is shorter than the minimum length of 1".to_string(),
7699                ));
7700            }
7701            if val.chars().count() > 4 {
7702                return Err(ValidationError::new(
7703                    1002,
7704                    "cd exceeds the maximum length of 4".to_string(),
7705                ));
7706            }
7707        }
7708        if let Some(ref val) = self.prtry {
7709            if val.chars().count() < 1 {
7710                return Err(ValidationError::new(
7711                    1001,
7712                    "prtry is shorter than the minimum length of 1".to_string(),
7713                ));
7714            }
7715            if val.chars().count() > 35 {
7716                return Err(ValidationError::new(
7717                    1002,
7718                    "prtry exceeds the maximum length of 35".to_string(),
7719                ));
7720            }
7721        }
7722        Ok(())
7723    }
7724}
7725// TaxAuthorisation1 ...
7726#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7727pub struct TaxAuthorisation1 {
7728    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
7729    pub titl: Option<String>,
7730    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
7731    pub nm: Option<String>,
7732}
7733
7734impl TaxAuthorisation1 {
7735    pub fn validate(&self) -> Result<(), ValidationError> {
7736        if let Some(ref val) = self.titl {
7737            if val.chars().count() < 1 {
7738                return Err(ValidationError::new(
7739                    1001,
7740                    "titl is shorter than the minimum length of 1".to_string(),
7741                ));
7742            }
7743            if val.chars().count() > 35 {
7744                return Err(ValidationError::new(
7745                    1002,
7746                    "titl exceeds the maximum length of 35".to_string(),
7747                ));
7748            }
7749        }
7750        if let Some(ref val) = self.nm {
7751            if val.chars().count() < 1 {
7752                return Err(ValidationError::new(
7753                    1001,
7754                    "nm is shorter than the minimum length of 1".to_string(),
7755                ));
7756            }
7757            if val.chars().count() > 140 {
7758                return Err(ValidationError::new(
7759                    1002,
7760                    "nm exceeds the maximum length of 140".to_string(),
7761                ));
7762            }
7763        }
7764        Ok(())
7765    }
7766}
7767// TaxCharges2 ...
7768#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7769pub struct TaxCharges2 {
7770    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
7771    pub id: Option<String>,
7772    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
7773    pub rate: Option<f64>,
7774    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
7775    pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7776}
7777
7778impl TaxCharges2 {
7779    pub fn validate(&self) -> Result<(), ValidationError> {
7780        if let Some(ref val) = self.id {
7781            if val.chars().count() < 1 {
7782                return Err(ValidationError::new(
7783                    1001,
7784                    "id is shorter than the minimum length of 1".to_string(),
7785                ));
7786            }
7787            if val.chars().count() > 35 {
7788                return Err(ValidationError::new(
7789                    1002,
7790                    "id exceeds the maximum length of 35".to_string(),
7791                ));
7792            }
7793        }
7794        if let Some(ref val) = self.amt {
7795            val.validate()?
7796        }
7797        Ok(())
7798    }
7799}
7800// TaxInformation7 ...
7801#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7802pub struct TaxInformation7 {
7803    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
7804    pub cdtr: Option<TaxParty1>,
7805    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
7806    pub dbtr: Option<TaxParty2>,
7807    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
7808    pub ultmt_dbtr: Option<TaxParty2>,
7809    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
7810    pub admstn_zone: Option<String>,
7811    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
7812    pub ref_nb: Option<String>,
7813    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
7814    pub mtd: Option<String>,
7815    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
7816    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7817    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
7818    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7819    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
7820    pub dt: Option<String>,
7821    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
7822    pub seq_nb: Option<f64>,
7823    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
7824    pub rcrd: Option<Vec<TaxRecord2>>,
7825}
7826
7827impl TaxInformation7 {
7828    pub fn validate(&self) -> Result<(), ValidationError> {
7829        if let Some(ref val) = self.cdtr {
7830            val.validate()?
7831        }
7832        if let Some(ref val) = self.dbtr {
7833            val.validate()?
7834        }
7835        if let Some(ref val) = self.ultmt_dbtr {
7836            val.validate()?
7837        }
7838        if let Some(ref val) = self.admstn_zone {
7839            if val.chars().count() < 1 {
7840                return Err(ValidationError::new(
7841                    1001,
7842                    "admstn_zone is shorter than the minimum length of 1".to_string(),
7843                ));
7844            }
7845            if val.chars().count() > 35 {
7846                return Err(ValidationError::new(
7847                    1002,
7848                    "admstn_zone exceeds the maximum length of 35".to_string(),
7849                ));
7850            }
7851        }
7852        if let Some(ref val) = self.ref_nb {
7853            if val.chars().count() < 1 {
7854                return Err(ValidationError::new(
7855                    1001,
7856                    "ref_nb is shorter than the minimum length of 1".to_string(),
7857                ));
7858            }
7859            if val.chars().count() > 140 {
7860                return Err(ValidationError::new(
7861                    1002,
7862                    "ref_nb exceeds the maximum length of 140".to_string(),
7863                ));
7864            }
7865        }
7866        if let Some(ref val) = self.mtd {
7867            if val.chars().count() < 1 {
7868                return Err(ValidationError::new(
7869                    1001,
7870                    "mtd is shorter than the minimum length of 1".to_string(),
7871                ));
7872            }
7873            if val.chars().count() > 35 {
7874                return Err(ValidationError::new(
7875                    1002,
7876                    "mtd exceeds the maximum length of 35".to_string(),
7877                ));
7878            }
7879        }
7880        if let Some(ref val) = self.ttl_taxbl_base_amt {
7881            val.validate()?
7882        }
7883        if let Some(ref val) = self.ttl_tax_amt {
7884            val.validate()?
7885        }
7886        if let Some(ref vec) = self.rcrd {
7887            for item in vec {
7888                item.validate()?
7889            }
7890        }
7891        Ok(())
7892    }
7893}
7894// TaxInformation8 ...
7895#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7896pub struct TaxInformation8 {
7897    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
7898    pub cdtr: Option<TaxParty1>,
7899    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
7900    pub dbtr: Option<TaxParty2>,
7901    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
7902    pub admstn_zone: Option<String>,
7903    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
7904    pub ref_nb: Option<String>,
7905    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
7906    pub mtd: Option<String>,
7907    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
7908    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7909    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
7910    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7911    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
7912    pub dt: Option<String>,
7913    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
7914    pub seq_nb: Option<f64>,
7915    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
7916    pub rcrd: Option<Vec<TaxRecord2>>,
7917}
7918
7919impl TaxInformation8 {
7920    pub fn validate(&self) -> Result<(), ValidationError> {
7921        if let Some(ref val) = self.cdtr {
7922            val.validate()?
7923        }
7924        if let Some(ref val) = self.dbtr {
7925            val.validate()?
7926        }
7927        if let Some(ref val) = self.admstn_zone {
7928            if val.chars().count() < 1 {
7929                return Err(ValidationError::new(
7930                    1001,
7931                    "admstn_zone is shorter than the minimum length of 1".to_string(),
7932                ));
7933            }
7934            if val.chars().count() > 35 {
7935                return Err(ValidationError::new(
7936                    1002,
7937                    "admstn_zone exceeds the maximum length of 35".to_string(),
7938                ));
7939            }
7940        }
7941        if let Some(ref val) = self.ref_nb {
7942            if val.chars().count() < 1 {
7943                return Err(ValidationError::new(
7944                    1001,
7945                    "ref_nb is shorter than the minimum length of 1".to_string(),
7946                ));
7947            }
7948            if val.chars().count() > 140 {
7949                return Err(ValidationError::new(
7950                    1002,
7951                    "ref_nb exceeds the maximum length of 140".to_string(),
7952                ));
7953            }
7954        }
7955        if let Some(ref val) = self.mtd {
7956            if val.chars().count() < 1 {
7957                return Err(ValidationError::new(
7958                    1001,
7959                    "mtd is shorter than the minimum length of 1".to_string(),
7960                ));
7961            }
7962            if val.chars().count() > 35 {
7963                return Err(ValidationError::new(
7964                    1002,
7965                    "mtd exceeds the maximum length of 35".to_string(),
7966                ));
7967            }
7968        }
7969        if let Some(ref val) = self.ttl_taxbl_base_amt {
7970            val.validate()?
7971        }
7972        if let Some(ref val) = self.ttl_tax_amt {
7973            val.validate()?
7974        }
7975        if let Some(ref vec) = self.rcrd {
7976            for item in vec {
7977                item.validate()?
7978            }
7979        }
7980        Ok(())
7981    }
7982}
7983// TaxParty1 ...
7984#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7985pub struct TaxParty1 {
7986    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
7987    pub tax_id: Option<String>,
7988    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
7989    pub regn_id: Option<String>,
7990    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
7991    pub tax_tp: Option<String>,
7992}
7993
7994impl TaxParty1 {
7995    pub fn validate(&self) -> Result<(), ValidationError> {
7996        if let Some(ref val) = self.tax_id {
7997            if val.chars().count() < 1 {
7998                return Err(ValidationError::new(
7999                    1001,
8000                    "tax_id is shorter than the minimum length of 1".to_string(),
8001                ));
8002            }
8003            if val.chars().count() > 35 {
8004                return Err(ValidationError::new(
8005                    1002,
8006                    "tax_id exceeds the maximum length of 35".to_string(),
8007                ));
8008            }
8009        }
8010        if let Some(ref val) = self.regn_id {
8011            if val.chars().count() < 1 {
8012                return Err(ValidationError::new(
8013                    1001,
8014                    "regn_id is shorter than the minimum length of 1".to_string(),
8015                ));
8016            }
8017            if val.chars().count() > 35 {
8018                return Err(ValidationError::new(
8019                    1002,
8020                    "regn_id exceeds the maximum length of 35".to_string(),
8021                ));
8022            }
8023        }
8024        if let Some(ref val) = self.tax_tp {
8025            if val.chars().count() < 1 {
8026                return Err(ValidationError::new(
8027                    1001,
8028                    "tax_tp is shorter than the minimum length of 1".to_string(),
8029                ));
8030            }
8031            if val.chars().count() > 35 {
8032                return Err(ValidationError::new(
8033                    1002,
8034                    "tax_tp exceeds the maximum length of 35".to_string(),
8035                ));
8036            }
8037        }
8038        Ok(())
8039    }
8040}
8041// TaxParty2 ...
8042#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8043pub struct TaxParty2 {
8044    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
8045    pub tax_id: Option<String>,
8046    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
8047    pub regn_id: Option<String>,
8048    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
8049    pub tax_tp: Option<String>,
8050    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
8051    pub authstn: Option<TaxAuthorisation1>,
8052}
8053
8054impl TaxParty2 {
8055    pub fn validate(&self) -> Result<(), ValidationError> {
8056        if let Some(ref val) = self.tax_id {
8057            if val.chars().count() < 1 {
8058                return Err(ValidationError::new(
8059                    1001,
8060                    "tax_id is shorter than the minimum length of 1".to_string(),
8061                ));
8062            }
8063            if val.chars().count() > 35 {
8064                return Err(ValidationError::new(
8065                    1002,
8066                    "tax_id exceeds the maximum length of 35".to_string(),
8067                ));
8068            }
8069        }
8070        if let Some(ref val) = self.regn_id {
8071            if val.chars().count() < 1 {
8072                return Err(ValidationError::new(
8073                    1001,
8074                    "regn_id is shorter than the minimum length of 1".to_string(),
8075                ));
8076            }
8077            if val.chars().count() > 35 {
8078                return Err(ValidationError::new(
8079                    1002,
8080                    "regn_id exceeds the maximum length of 35".to_string(),
8081                ));
8082            }
8083        }
8084        if let Some(ref val) = self.tax_tp {
8085            if val.chars().count() < 1 {
8086                return Err(ValidationError::new(
8087                    1001,
8088                    "tax_tp is shorter than the minimum length of 1".to_string(),
8089                ));
8090            }
8091            if val.chars().count() > 35 {
8092                return Err(ValidationError::new(
8093                    1002,
8094                    "tax_tp exceeds the maximum length of 35".to_string(),
8095                ));
8096            }
8097        }
8098        if let Some(ref val) = self.authstn {
8099            val.validate()?
8100        }
8101        Ok(())
8102    }
8103}
8104// TaxPeriod2 ...
8105#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8106pub struct TaxPeriod2 {
8107    #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
8108    pub yr: Option<String>,
8109    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
8110    pub tp: Option<TaxRecordPeriod1Code>,
8111    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
8112    pub fr_to_dt: Option<DatePeriod2>,
8113}
8114
8115impl TaxPeriod2 {
8116    pub fn validate(&self) -> Result<(), ValidationError> {
8117        if let Some(ref val) = self.tp {
8118            val.validate()?
8119        }
8120        if let Some(ref val) = self.fr_to_dt {
8121            val.validate()?
8122        }
8123        Ok(())
8124    }
8125}
8126// TaxRecord2 ...
8127#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8128pub struct TaxRecord2 {
8129    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
8130    pub tp: Option<String>,
8131    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
8132    pub ctgy: Option<String>,
8133    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
8134    pub ctgy_dtls: Option<String>,
8135    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
8136    pub dbtr_sts: Option<String>,
8137    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
8138    pub cert_id: Option<String>,
8139    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
8140    pub frms_cd: Option<String>,
8141    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
8142    pub prd: Option<TaxPeriod2>,
8143    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
8144    pub tax_amt: Option<TaxAmount2>,
8145    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
8146    pub addtl_inf: Option<String>,
8147}
8148
8149impl TaxRecord2 {
8150    pub fn validate(&self) -> Result<(), ValidationError> {
8151        if let Some(ref val) = self.tp {
8152            if val.chars().count() < 1 {
8153                return Err(ValidationError::new(
8154                    1001,
8155                    "tp is shorter than the minimum length of 1".to_string(),
8156                ));
8157            }
8158            if val.chars().count() > 35 {
8159                return Err(ValidationError::new(
8160                    1002,
8161                    "tp exceeds the maximum length of 35".to_string(),
8162                ));
8163            }
8164        }
8165        if let Some(ref val) = self.ctgy {
8166            if val.chars().count() < 1 {
8167                return Err(ValidationError::new(
8168                    1001,
8169                    "ctgy is shorter than the minimum length of 1".to_string(),
8170                ));
8171            }
8172            if val.chars().count() > 35 {
8173                return Err(ValidationError::new(
8174                    1002,
8175                    "ctgy exceeds the maximum length of 35".to_string(),
8176                ));
8177            }
8178        }
8179        if let Some(ref val) = self.ctgy_dtls {
8180            if val.chars().count() < 1 {
8181                return Err(ValidationError::new(
8182                    1001,
8183                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
8184                ));
8185            }
8186            if val.chars().count() > 35 {
8187                return Err(ValidationError::new(
8188                    1002,
8189                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
8190                ));
8191            }
8192        }
8193        if let Some(ref val) = self.dbtr_sts {
8194            if val.chars().count() < 1 {
8195                return Err(ValidationError::new(
8196                    1001,
8197                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
8198                ));
8199            }
8200            if val.chars().count() > 35 {
8201                return Err(ValidationError::new(
8202                    1002,
8203                    "dbtr_sts exceeds the maximum length of 35".to_string(),
8204                ));
8205            }
8206        }
8207        if let Some(ref val) = self.cert_id {
8208            if val.chars().count() < 1 {
8209                return Err(ValidationError::new(
8210                    1001,
8211                    "cert_id is shorter than the minimum length of 1".to_string(),
8212                ));
8213            }
8214            if val.chars().count() > 35 {
8215                return Err(ValidationError::new(
8216                    1002,
8217                    "cert_id exceeds the maximum length of 35".to_string(),
8218                ));
8219            }
8220        }
8221        if let Some(ref val) = self.frms_cd {
8222            if val.chars().count() < 1 {
8223                return Err(ValidationError::new(
8224                    1001,
8225                    "frms_cd is shorter than the minimum length of 1".to_string(),
8226                ));
8227            }
8228            if val.chars().count() > 35 {
8229                return Err(ValidationError::new(
8230                    1002,
8231                    "frms_cd exceeds the maximum length of 35".to_string(),
8232                ));
8233            }
8234        }
8235        if let Some(ref val) = self.prd {
8236            val.validate()?
8237        }
8238        if let Some(ref val) = self.tax_amt {
8239            val.validate()?
8240        }
8241        if let Some(ref val) = self.addtl_inf {
8242            if val.chars().count() < 1 {
8243                return Err(ValidationError::new(
8244                    1001,
8245                    "addtl_inf is shorter than the minimum length of 1".to_string(),
8246                ));
8247            }
8248            if val.chars().count() > 140 {
8249                return Err(ValidationError::new(
8250                    1002,
8251                    "addtl_inf exceeds the maximum length of 140".to_string(),
8252                ));
8253            }
8254        }
8255        Ok(())
8256    }
8257}
8258// TaxRecordDetails2 ...
8259#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8260pub struct TaxRecordDetails2 {
8261    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
8262    pub prd: Option<TaxPeriod2>,
8263    #[serde(rename = "Amt")]
8264    pub amt: ActiveOrHistoricCurrencyAndAmount,
8265}
8266
8267impl TaxRecordDetails2 {
8268    pub fn validate(&self) -> Result<(), ValidationError> {
8269        if let Some(ref val) = self.prd {
8270            val.validate()?
8271        }
8272        self.amt.validate()?;
8273        Ok(())
8274    }
8275}
8276// TaxRecordPeriod1Code ...
8277#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8278pub enum TaxRecordPeriod1Code {
8279    #[default]
8280    #[serde(rename = "MM01")]
8281    CodeMM01,
8282    #[serde(rename = "MM02")]
8283    CodeMM02,
8284    #[serde(rename = "MM03")]
8285    CodeMM03,
8286    #[serde(rename = "MM04")]
8287    CodeMM04,
8288    #[serde(rename = "MM05")]
8289    CodeMM05,
8290    #[serde(rename = "MM06")]
8291    CodeMM06,
8292    #[serde(rename = "MM07")]
8293    CodeMM07,
8294    #[serde(rename = "MM08")]
8295    CodeMM08,
8296    #[serde(rename = "MM09")]
8297    CodeMM09,
8298    #[serde(rename = "MM10")]
8299    CodeMM10,
8300    #[serde(rename = "MM11")]
8301    CodeMM11,
8302    #[serde(rename = "MM12")]
8303    CodeMM12,
8304    #[serde(rename = "QTR1")]
8305    CodeQTR1,
8306    #[serde(rename = "QTR2")]
8307    CodeQTR2,
8308    #[serde(rename = "QTR3")]
8309    CodeQTR3,
8310    #[serde(rename = "QTR4")]
8311    CodeQTR4,
8312    #[serde(rename = "HLF1")]
8313    CodeHLF1,
8314    #[serde(rename = "HLF2")]
8315    CodeHLF2,
8316}
8317
8318impl TaxRecordPeriod1Code {
8319    pub fn validate(&self) -> Result<(), ValidationError> {
8320        Ok(())
8321    }
8322}
8323// TechnicalInputChannel1Choice ...
8324#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8325pub struct TechnicalInputChannel1Choice {
8326    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
8327    pub cd: Option<String>,
8328    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8329    pub prtry: Option<String>,
8330}
8331
8332impl TechnicalInputChannel1Choice {
8333    pub fn validate(&self) -> Result<(), ValidationError> {
8334        if let Some(ref val) = self.cd {
8335            if val.chars().count() < 1 {
8336                return Err(ValidationError::new(
8337                    1001,
8338                    "cd is shorter than the minimum length of 1".to_string(),
8339                ));
8340            }
8341            if val.chars().count() > 4 {
8342                return Err(ValidationError::new(
8343                    1002,
8344                    "cd exceeds the maximum length of 4".to_string(),
8345                ));
8346            }
8347        }
8348        if let Some(ref val) = self.prtry {
8349            if val.chars().count() < 1 {
8350                return Err(ValidationError::new(
8351                    1001,
8352                    "prtry is shorter than the minimum length of 1".to_string(),
8353                ));
8354            }
8355            if val.chars().count() > 35 {
8356                return Err(ValidationError::new(
8357                    1002,
8358                    "prtry exceeds the maximum length of 35".to_string(),
8359                ));
8360            }
8361        }
8362        Ok(())
8363    }
8364}
8365// TotalTransactions6 ...
8366#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8367pub struct TotalTransactions6 {
8368    #[serde(rename = "TtlNtries", skip_serializing_if = "Option::is_none")]
8369    pub ttl_ntries: Option<NumberAndSumOfTransactions4>,
8370    #[serde(rename = "TtlCdtNtries", skip_serializing_if = "Option::is_none")]
8371    pub ttl_cdt_ntries: Option<NumberAndSumOfTransactions1>,
8372    #[serde(rename = "TtlDbtNtries", skip_serializing_if = "Option::is_none")]
8373    pub ttl_dbt_ntries: Option<NumberAndSumOfTransactions1>,
8374    #[serde(rename = "TtlNtriesPerBkTxCd", skip_serializing_if = "Option::is_none")]
8375    pub ttl_ntries_per_bk_tx_cd: Option<Vec<TotalsPerBankTransactionCode5>>,
8376}
8377
8378impl TotalTransactions6 {
8379    pub fn validate(&self) -> Result<(), ValidationError> {
8380        if let Some(ref val) = self.ttl_ntries {
8381            val.validate()?
8382        }
8383        if let Some(ref val) = self.ttl_cdt_ntries {
8384            val.validate()?
8385        }
8386        if let Some(ref val) = self.ttl_dbt_ntries {
8387            val.validate()?
8388        }
8389        if let Some(ref vec) = self.ttl_ntries_per_bk_tx_cd {
8390            for item in vec {
8391                item.validate()?
8392            }
8393        }
8394        Ok(())
8395    }
8396}
8397// TotalsPerBankTransactionCode5 ...
8398#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8399pub struct TotalsPerBankTransactionCode5 {
8400    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
8401    pub nb_of_ntries: Option<String>,
8402    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
8403    pub sum: Option<f64>,
8404    #[serde(rename = "TtlNetNtry", skip_serializing_if = "Option::is_none")]
8405    pub ttl_net_ntry: Option<AmountAndDirection35>,
8406    #[serde(rename = "CdtNtries", skip_serializing_if = "Option::is_none")]
8407    pub cdt_ntries: Option<NumberAndSumOfTransactions1>,
8408    #[serde(rename = "DbtNtries", skip_serializing_if = "Option::is_none")]
8409    pub dbt_ntries: Option<NumberAndSumOfTransactions1>,
8410    #[serde(rename = "FcstInd", skip_serializing_if = "Option::is_none")]
8411    pub fcst_ind: Option<bool>,
8412    #[serde(rename = "BkTxCd")]
8413    pub bk_tx_cd: BankTransactionCodeStructure4,
8414    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
8415    pub avlbty: Option<Vec<CashAvailability1>>,
8416    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
8417    pub dt: Option<DateAndDateTime2Choice>,
8418}
8419
8420impl TotalsPerBankTransactionCode5 {
8421    pub fn validate(&self) -> Result<(), ValidationError> {
8422        if let Some(ref val) = self.nb_of_ntries {
8423            let pattern = Regex::new("[0-9]{1,15}").unwrap();
8424            if !pattern.is_match(val) {
8425                return Err(ValidationError::new(
8426                    1005,
8427                    "nb_of_ntries does not match the required pattern".to_string(),
8428                ));
8429            }
8430        }
8431        if let Some(ref val) = self.ttl_net_ntry {
8432            val.validate()?
8433        }
8434        if let Some(ref val) = self.cdt_ntries {
8435            val.validate()?
8436        }
8437        if let Some(ref val) = self.dbt_ntries {
8438            val.validate()?
8439        }
8440        self.bk_tx_cd.validate()?;
8441        if let Some(ref vec) = self.avlbty {
8442            for item in vec {
8443                item.validate()?
8444            }
8445        }
8446        if let Some(ref val) = self.dt {
8447            val.validate()?
8448        }
8449        Ok(())
8450    }
8451}
8452// TrackData1 ...
8453#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8454pub struct TrackData1 {
8455    #[serde(rename = "TrckNb", skip_serializing_if = "Option::is_none")]
8456    pub trck_nb: Option<String>,
8457    #[serde(rename = "TrckVal")]
8458    pub trck_val: String,
8459}
8460
8461impl TrackData1 {
8462    pub fn validate(&self) -> Result<(), ValidationError> {
8463        if let Some(ref val) = self.trck_nb {
8464            let pattern = Regex::new("[0-9]").unwrap();
8465            if !pattern.is_match(val) {
8466                return Err(ValidationError::new(
8467                    1005,
8468                    "trck_nb does not match the required pattern".to_string(),
8469                ));
8470            }
8471        }
8472        if self.trck_val.chars().count() < 1 {
8473            return Err(ValidationError::new(
8474                1001,
8475                "trck_val is shorter than the minimum length of 1".to_string(),
8476            ));
8477        }
8478        if self.trck_val.chars().count() > 140 {
8479            return Err(ValidationError::new(
8480                1002,
8481                "trck_val exceeds the maximum length of 140".to_string(),
8482            ));
8483        }
8484        Ok(())
8485    }
8486}
8487// TransactionAgents5 ...
8488#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8489pub struct TransactionAgents5 {
8490    #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
8491    pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8492    #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
8493    pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8494    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
8495    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8496    #[serde(rename = "CdtrAgt", skip_serializing_if = "Option::is_none")]
8497    pub cdtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8498    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
8499    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
8500    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
8501    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
8502    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
8503    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
8504    #[serde(rename = "RcvgAgt", skip_serializing_if = "Option::is_none")]
8505    pub rcvg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8506    #[serde(rename = "DlvrgAgt", skip_serializing_if = "Option::is_none")]
8507    pub dlvrg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8508    #[serde(rename = "IssgAgt", skip_serializing_if = "Option::is_none")]
8509    pub issg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
8510    #[serde(rename = "SttlmPlc", skip_serializing_if = "Option::is_none")]
8511    pub sttlm_plc: Option<BranchAndFinancialInstitutionIdentification6>,
8512    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8513    pub prtry: Option<Vec<ProprietaryAgent4>>,
8514}
8515
8516impl TransactionAgents5 {
8517    pub fn validate(&self) -> Result<(), ValidationError> {
8518        if let Some(ref val) = self.instg_agt {
8519            val.validate()?
8520        }
8521        if let Some(ref val) = self.instd_agt {
8522            val.validate()?
8523        }
8524        if let Some(ref val) = self.dbtr_agt {
8525            val.validate()?
8526        }
8527        if let Some(ref val) = self.cdtr_agt {
8528            val.validate()?
8529        }
8530        if let Some(ref val) = self.intrmy_agt1 {
8531            val.validate()?
8532        }
8533        if let Some(ref val) = self.intrmy_agt2 {
8534            val.validate()?
8535        }
8536        if let Some(ref val) = self.intrmy_agt3 {
8537            val.validate()?
8538        }
8539        if let Some(ref val) = self.rcvg_agt {
8540            val.validate()?
8541        }
8542        if let Some(ref val) = self.dlvrg_agt {
8543            val.validate()?
8544        }
8545        if let Some(ref val) = self.issg_agt {
8546            val.validate()?
8547        }
8548        if let Some(ref val) = self.sttlm_plc {
8549            val.validate()?
8550        }
8551        if let Some(ref vec) = self.prtry {
8552            for item in vec {
8553                item.validate()?
8554            }
8555        }
8556        Ok(())
8557    }
8558}
8559// TransactionChannel1Code ...
8560#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8561pub enum TransactionChannel1Code {
8562    #[default]
8563    #[serde(rename = "MAIL")]
8564    CodeMAIL,
8565    #[serde(rename = "TLPH")]
8566    CodeTLPH,
8567    #[serde(rename = "ECOM")]
8568    CodeECOM,
8569    #[serde(rename = "TVPY")]
8570    CodeTVPY,
8571}
8572
8573impl TransactionChannel1Code {
8574    pub fn validate(&self) -> Result<(), ValidationError> {
8575        Ok(())
8576    }
8577}
8578// TransactionDates3 ...
8579#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8580pub struct TransactionDates3 {
8581    #[serde(rename = "AccptncDtTm", skip_serializing_if = "Option::is_none")]
8582    pub accptnc_dt_tm: Option<String>,
8583    #[serde(
8584        rename = "TradActvtyCtrctlSttlmDt",
8585        skip_serializing_if = "Option::is_none"
8586    )]
8587    pub trad_actvty_ctrctl_sttlm_dt: Option<String>,
8588    #[serde(rename = "TradDt", skip_serializing_if = "Option::is_none")]
8589    pub trad_dt: Option<String>,
8590    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
8591    pub intr_bk_sttlm_dt: Option<String>,
8592    #[serde(rename = "StartDt", skip_serializing_if = "Option::is_none")]
8593    pub start_dt: Option<String>,
8594    #[serde(rename = "EndDt", skip_serializing_if = "Option::is_none")]
8595    pub end_dt: Option<String>,
8596    #[serde(rename = "TxDtTm", skip_serializing_if = "Option::is_none")]
8597    pub tx_dt_tm: Option<String>,
8598    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8599    pub prtry: Option<Vec<ProprietaryDate3>>,
8600}
8601
8602impl TransactionDates3 {
8603    pub fn validate(&self) -> Result<(), ValidationError> {
8604        if let Some(ref vec) = self.prtry {
8605            for item in vec {
8606                item.validate()?
8607            }
8608        }
8609        Ok(())
8610    }
8611}
8612// TransactionEnvironment1Code ...
8613#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8614pub enum TransactionEnvironment1Code {
8615    #[default]
8616    #[serde(rename = "MERC")]
8617    CodeMERC,
8618    #[serde(rename = "PRIV")]
8619    CodePRIV,
8620    #[serde(rename = "PUBL")]
8621    CodePUBL,
8622}
8623
8624impl TransactionEnvironment1Code {
8625    pub fn validate(&self) -> Result<(), ValidationError> {
8626        Ok(())
8627    }
8628}
8629// TransactionIdentifier1 ...
8630#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8631pub struct TransactionIdentifier1 {
8632    #[serde(rename = "TxDtTm")]
8633    pub tx_dt_tm: String,
8634    #[serde(rename = "TxRef")]
8635    pub tx_ref: String,
8636}
8637
8638impl TransactionIdentifier1 {
8639    pub fn validate(&self) -> Result<(), ValidationError> {
8640        if self.tx_ref.chars().count() < 1 {
8641            return Err(ValidationError::new(
8642                1001,
8643                "tx_ref is shorter than the minimum length of 1".to_string(),
8644            ));
8645        }
8646        if self.tx_ref.chars().count() > 35 {
8647            return Err(ValidationError::new(
8648                1002,
8649                "tx_ref exceeds the maximum length of 35".to_string(),
8650            ));
8651        }
8652        Ok(())
8653    }
8654}
8655// TransactionInterest4 ...
8656#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8657pub struct TransactionInterest4 {
8658    #[serde(rename = "TtlIntrstAndTaxAmt", skip_serializing_if = "Option::is_none")]
8659    pub ttl_intrst_and_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8660    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
8661    pub rcrd: Option<Vec<InterestRecord2>>,
8662}
8663
8664impl TransactionInterest4 {
8665    pub fn validate(&self) -> Result<(), ValidationError> {
8666        if let Some(ref val) = self.ttl_intrst_and_tax_amt {
8667            val.validate()?
8668        }
8669        if let Some(ref vec) = self.rcrd {
8670            for item in vec {
8671                item.validate()?
8672            }
8673        }
8674        Ok(())
8675    }
8676}
8677// TransactionParties6 ...
8678#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8679pub struct TransactionParties6 {
8680    #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
8681    pub initg_pty: Option<Party40Choice>,
8682    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
8683    pub dbtr: Option<Party40Choice>,
8684    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
8685    pub dbtr_acct: Option<CashAccount38>,
8686    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
8687    pub ultmt_dbtr: Option<Party40Choice>,
8688    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
8689    pub cdtr: Option<Party40Choice>,
8690    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
8691    pub cdtr_acct: Option<CashAccount38>,
8692    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
8693    pub ultmt_cdtr: Option<Party40Choice>,
8694    #[serde(rename = "TradgPty", skip_serializing_if = "Option::is_none")]
8695    pub tradg_pty: Option<Party40Choice>,
8696    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8697    pub prtry: Option<Vec<ProprietaryParty5>>,
8698}
8699
8700impl TransactionParties6 {
8701    pub fn validate(&self) -> Result<(), ValidationError> {
8702        if let Some(ref val) = self.initg_pty {
8703            val.validate()?
8704        }
8705        if let Some(ref val) = self.dbtr {
8706            val.validate()?
8707        }
8708        if let Some(ref val) = self.dbtr_acct {
8709            val.validate()?
8710        }
8711        if let Some(ref val) = self.ultmt_dbtr {
8712            val.validate()?
8713        }
8714        if let Some(ref val) = self.cdtr {
8715            val.validate()?
8716        }
8717        if let Some(ref val) = self.cdtr_acct {
8718            val.validate()?
8719        }
8720        if let Some(ref val) = self.ultmt_cdtr {
8721            val.validate()?
8722        }
8723        if let Some(ref val) = self.tradg_pty {
8724            val.validate()?
8725        }
8726        if let Some(ref vec) = self.prtry {
8727            for item in vec {
8728                item.validate()?
8729            }
8730        }
8731        Ok(())
8732    }
8733}
8734// TransactionPrice4Choice ...
8735#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8736pub struct TransactionPrice4Choice {
8737    #[serde(rename = "DealPric", skip_serializing_if = "Option::is_none")]
8738    pub deal_pric: Option<Price7>,
8739    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8740    pub prtry: Option<Vec<ProprietaryPrice2>>,
8741}
8742
8743impl TransactionPrice4Choice {
8744    pub fn validate(&self) -> Result<(), ValidationError> {
8745        if let Some(ref val) = self.deal_pric {
8746            val.validate()?
8747        }
8748        if let Some(ref vec) = self.prtry {
8749            for item in vec {
8750                item.validate()?
8751            }
8752        }
8753        Ok(())
8754    }
8755}
8756// TransactionQuantities3Choice ...
8757#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8758pub struct TransactionQuantities3Choice {
8759    #[serde(rename = "Qty", skip_serializing_if = "Option::is_none")]
8760    pub qty: Option<FinancialInstrumentQuantity1Choice>,
8761    #[serde(rename = "OrgnlAndCurFaceAmt", skip_serializing_if = "Option::is_none")]
8762    pub orgnl_and_cur_face_amt: Option<OriginalAndCurrentQuantities1>,
8763    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8764    pub prtry: Option<ProprietaryQuantity1>,
8765}
8766
8767impl TransactionQuantities3Choice {
8768    pub fn validate(&self) -> Result<(), ValidationError> {
8769        if let Some(ref val) = self.qty {
8770            val.validate()?
8771        }
8772        if let Some(ref val) = self.orgnl_and_cur_face_amt {
8773            val.validate()?
8774        }
8775        if let Some(ref val) = self.prtry {
8776            val.validate()?
8777        }
8778        Ok(())
8779    }
8780}
8781// TransactionReferences6 ...
8782#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8783pub struct TransactionReferences6 {
8784    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
8785    pub msg_id: Option<String>,
8786    #[serde(rename = "AcctSvcrRef", skip_serializing_if = "Option::is_none")]
8787    pub acct_svcr_ref: Option<String>,
8788    #[serde(rename = "PmtInfId", skip_serializing_if = "Option::is_none")]
8789    pub pmt_inf_id: Option<String>,
8790    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
8791    pub instr_id: Option<String>,
8792    #[serde(rename = "EndToEndId", skip_serializing_if = "Option::is_none")]
8793    pub end_to_end_id: Option<String>,
8794    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
8795    pub uetr: Option<String>,
8796    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
8797    pub tx_id: Option<String>,
8798    #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
8799    pub mndt_id: Option<String>,
8800    #[serde(rename = "ChqNb", skip_serializing_if = "Option::is_none")]
8801    pub chq_nb: Option<String>,
8802    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
8803    pub clr_sys_ref: Option<String>,
8804    #[serde(rename = "AcctOwnrTxId", skip_serializing_if = "Option::is_none")]
8805    pub acct_ownr_tx_id: Option<String>,
8806    #[serde(rename = "AcctSvcrTxId", skip_serializing_if = "Option::is_none")]
8807    pub acct_svcr_tx_id: Option<String>,
8808    #[serde(rename = "MktInfrstrctrTxId", skip_serializing_if = "Option::is_none")]
8809    pub mkt_infrstrctr_tx_id: Option<String>,
8810    #[serde(rename = "PrcgId", skip_serializing_if = "Option::is_none")]
8811    pub prcg_id: Option<String>,
8812    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8813    pub prtry: Option<Vec<ProprietaryReference1>>,
8814}
8815
8816impl TransactionReferences6 {
8817    pub fn validate(&self) -> Result<(), ValidationError> {
8818        if let Some(ref val) = self.msg_id {
8819            if val.chars().count() < 1 {
8820                return Err(ValidationError::new(
8821                    1001,
8822                    "msg_id is shorter than the minimum length of 1".to_string(),
8823                ));
8824            }
8825            if val.chars().count() > 35 {
8826                return Err(ValidationError::new(
8827                    1002,
8828                    "msg_id exceeds the maximum length of 35".to_string(),
8829                ));
8830            }
8831        }
8832        if let Some(ref val) = self.acct_svcr_ref {
8833            if val.chars().count() < 1 {
8834                return Err(ValidationError::new(
8835                    1001,
8836                    "acct_svcr_ref is shorter than the minimum length of 1".to_string(),
8837                ));
8838            }
8839            if val.chars().count() > 35 {
8840                return Err(ValidationError::new(
8841                    1002,
8842                    "acct_svcr_ref exceeds the maximum length of 35".to_string(),
8843                ));
8844            }
8845        }
8846        if let Some(ref val) = self.pmt_inf_id {
8847            if val.chars().count() < 1 {
8848                return Err(ValidationError::new(
8849                    1001,
8850                    "pmt_inf_id is shorter than the minimum length of 1".to_string(),
8851                ));
8852            }
8853            if val.chars().count() > 35 {
8854                return Err(ValidationError::new(
8855                    1002,
8856                    "pmt_inf_id exceeds the maximum length of 35".to_string(),
8857                ));
8858            }
8859        }
8860        if let Some(ref val) = self.instr_id {
8861            if val.chars().count() < 1 {
8862                return Err(ValidationError::new(
8863                    1001,
8864                    "instr_id is shorter than the minimum length of 1".to_string(),
8865                ));
8866            }
8867            if val.chars().count() > 35 {
8868                return Err(ValidationError::new(
8869                    1002,
8870                    "instr_id exceeds the maximum length of 35".to_string(),
8871                ));
8872            }
8873        }
8874        if let Some(ref val) = self.end_to_end_id {
8875            if val.chars().count() < 1 {
8876                return Err(ValidationError::new(
8877                    1001,
8878                    "end_to_end_id is shorter than the minimum length of 1".to_string(),
8879                ));
8880            }
8881            if val.chars().count() > 35 {
8882                return Err(ValidationError::new(
8883                    1002,
8884                    "end_to_end_id exceeds the maximum length of 35".to_string(),
8885                ));
8886            }
8887        }
8888        if let Some(ref val) = self.uetr {
8889            let pattern =
8890                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
8891                    .unwrap();
8892            if !pattern.is_match(val) {
8893                return Err(ValidationError::new(
8894                    1005,
8895                    "uetr does not match the required pattern".to_string(),
8896                ));
8897            }
8898        }
8899        if let Some(ref val) = self.tx_id {
8900            if val.chars().count() < 1 {
8901                return Err(ValidationError::new(
8902                    1001,
8903                    "tx_id is shorter than the minimum length of 1".to_string(),
8904                ));
8905            }
8906            if val.chars().count() > 35 {
8907                return Err(ValidationError::new(
8908                    1002,
8909                    "tx_id exceeds the maximum length of 35".to_string(),
8910                ));
8911            }
8912        }
8913        if let Some(ref val) = self.mndt_id {
8914            if val.chars().count() < 1 {
8915                return Err(ValidationError::new(
8916                    1001,
8917                    "mndt_id is shorter than the minimum length of 1".to_string(),
8918                ));
8919            }
8920            if val.chars().count() > 35 {
8921                return Err(ValidationError::new(
8922                    1002,
8923                    "mndt_id exceeds the maximum length of 35".to_string(),
8924                ));
8925            }
8926        }
8927        if let Some(ref val) = self.chq_nb {
8928            if val.chars().count() < 1 {
8929                return Err(ValidationError::new(
8930                    1001,
8931                    "chq_nb is shorter than the minimum length of 1".to_string(),
8932                ));
8933            }
8934            if val.chars().count() > 35 {
8935                return Err(ValidationError::new(
8936                    1002,
8937                    "chq_nb exceeds the maximum length of 35".to_string(),
8938                ));
8939            }
8940        }
8941        if let Some(ref val) = self.clr_sys_ref {
8942            if val.chars().count() < 1 {
8943                return Err(ValidationError::new(
8944                    1001,
8945                    "clr_sys_ref is shorter than the minimum length of 1".to_string(),
8946                ));
8947            }
8948            if val.chars().count() > 35 {
8949                return Err(ValidationError::new(
8950                    1002,
8951                    "clr_sys_ref exceeds the maximum length of 35".to_string(),
8952                ));
8953            }
8954        }
8955        if let Some(ref val) = self.acct_ownr_tx_id {
8956            if val.chars().count() < 1 {
8957                return Err(ValidationError::new(
8958                    1001,
8959                    "acct_ownr_tx_id is shorter than the minimum length of 1".to_string(),
8960                ));
8961            }
8962            if val.chars().count() > 35 {
8963                return Err(ValidationError::new(
8964                    1002,
8965                    "acct_ownr_tx_id exceeds the maximum length of 35".to_string(),
8966                ));
8967            }
8968        }
8969        if let Some(ref val) = self.acct_svcr_tx_id {
8970            if val.chars().count() < 1 {
8971                return Err(ValidationError::new(
8972                    1001,
8973                    "acct_svcr_tx_id is shorter than the minimum length of 1".to_string(),
8974                ));
8975            }
8976            if val.chars().count() > 35 {
8977                return Err(ValidationError::new(
8978                    1002,
8979                    "acct_svcr_tx_id exceeds the maximum length of 35".to_string(),
8980                ));
8981            }
8982        }
8983        if let Some(ref val) = self.mkt_infrstrctr_tx_id {
8984            if val.chars().count() < 1 {
8985                return Err(ValidationError::new(
8986                    1001,
8987                    "mkt_infrstrctr_tx_id is shorter than the minimum length of 1".to_string(),
8988                ));
8989            }
8990            if val.chars().count() > 35 {
8991                return Err(ValidationError::new(
8992                    1002,
8993                    "mkt_infrstrctr_tx_id exceeds the maximum length of 35".to_string(),
8994                ));
8995            }
8996        }
8997        if let Some(ref val) = self.prcg_id {
8998            if val.chars().count() < 1 {
8999                return Err(ValidationError::new(
9000                    1001,
9001                    "prcg_id is shorter than the minimum length of 1".to_string(),
9002                ));
9003            }
9004            if val.chars().count() > 35 {
9005                return Err(ValidationError::new(
9006                    1002,
9007                    "prcg_id exceeds the maximum length of 35".to_string(),
9008                ));
9009            }
9010        }
9011        if let Some(ref vec) = self.prtry {
9012            for item in vec {
9013                item.validate()?
9014            }
9015        }
9016        Ok(())
9017    }
9018}
9019// UnderlyingGroupInformation1 ...
9020#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9021pub struct UnderlyingGroupInformation1 {
9022    #[serde(rename = "OrgnlMsgId")]
9023    pub orgnl_msg_id: String,
9024    #[serde(rename = "OrgnlMsgNmId")]
9025    pub orgnl_msg_nm_id: String,
9026    #[serde(rename = "OrgnlCreDtTm", skip_serializing_if = "Option::is_none")]
9027    pub orgnl_cre_dt_tm: Option<String>,
9028    #[serde(rename = "OrgnlMsgDlvryChanl", skip_serializing_if = "Option::is_none")]
9029    pub orgnl_msg_dlvry_chanl: Option<String>,
9030}
9031
9032impl UnderlyingGroupInformation1 {
9033    pub fn validate(&self) -> Result<(), ValidationError> {
9034        if self.orgnl_msg_id.chars().count() < 1 {
9035            return Err(ValidationError::new(
9036                1001,
9037                "orgnl_msg_id is shorter than the minimum length of 1".to_string(),
9038            ));
9039        }
9040        if self.orgnl_msg_id.chars().count() > 35 {
9041            return Err(ValidationError::new(
9042                1002,
9043                "orgnl_msg_id exceeds the maximum length of 35".to_string(),
9044            ));
9045        }
9046        if self.orgnl_msg_nm_id.chars().count() < 1 {
9047            return Err(ValidationError::new(
9048                1001,
9049                "orgnl_msg_nm_id is shorter than the minimum length of 1".to_string(),
9050            ));
9051        }
9052        if self.orgnl_msg_nm_id.chars().count() > 35 {
9053            return Err(ValidationError::new(
9054                1002,
9055                "orgnl_msg_nm_id exceeds the maximum length of 35".to_string(),
9056            ));
9057        }
9058        if let Some(ref val) = self.orgnl_msg_dlvry_chanl {
9059            if val.chars().count() < 1 {
9060                return Err(ValidationError::new(
9061                    1001,
9062                    "orgnl_msg_dlvry_chanl is shorter than the minimum length of 1".to_string(),
9063                ));
9064            }
9065            if val.chars().count() > 35 {
9066                return Err(ValidationError::new(
9067                    1002,
9068                    "orgnl_msg_dlvry_chanl exceeds the maximum length of 35".to_string(),
9069                ));
9070            }
9071        }
9072        Ok(())
9073    }
9074}
9075// UnderlyingPaymentInstruction5 ...
9076#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9077pub struct UnderlyingPaymentInstruction5 {
9078    #[serde(rename = "OrgnlGrpInf", skip_serializing_if = "Option::is_none")]
9079    pub orgnl_grp_inf: Option<UnderlyingGroupInformation1>,
9080    #[serde(rename = "OrgnlPmtInfId", skip_serializing_if = "Option::is_none")]
9081    pub orgnl_pmt_inf_id: Option<String>,
9082    #[serde(rename = "OrgnlInstrId", skip_serializing_if = "Option::is_none")]
9083    pub orgnl_instr_id: Option<String>,
9084    #[serde(rename = "OrgnlEndToEndId", skip_serializing_if = "Option::is_none")]
9085    pub orgnl_end_to_end_id: Option<String>,
9086    #[serde(rename = "OrgnlUETR", skip_serializing_if = "Option::is_none")]
9087    pub orgnl_uetr: Option<String>,
9088    #[serde(rename = "OrgnlInstdAmt")]
9089    pub orgnl_instd_amt: ActiveOrHistoricCurrencyAndAmount,
9090    #[serde(rename = "ReqdExctnDt", skip_serializing_if = "Option::is_none")]
9091    pub reqd_exctn_dt: Option<DateAndDateTime2Choice>,
9092    #[serde(rename = "ReqdColltnDt", skip_serializing_if = "Option::is_none")]
9093    pub reqd_colltn_dt: Option<String>,
9094    #[serde(rename = "OrgnlTxRef", skip_serializing_if = "Option::is_none")]
9095    pub orgnl_tx_ref: Option<OriginalTransactionReference28>,
9096}
9097
9098impl UnderlyingPaymentInstruction5 {
9099    pub fn validate(&self) -> Result<(), ValidationError> {
9100        if let Some(ref val) = self.orgnl_grp_inf {
9101            val.validate()?
9102        }
9103        if let Some(ref val) = self.orgnl_pmt_inf_id {
9104            if val.chars().count() < 1 {
9105                return Err(ValidationError::new(
9106                    1001,
9107                    "orgnl_pmt_inf_id is shorter than the minimum length of 1".to_string(),
9108                ));
9109            }
9110            if val.chars().count() > 35 {
9111                return Err(ValidationError::new(
9112                    1002,
9113                    "orgnl_pmt_inf_id exceeds the maximum length of 35".to_string(),
9114                ));
9115            }
9116        }
9117        if let Some(ref val) = self.orgnl_instr_id {
9118            if val.chars().count() < 1 {
9119                return Err(ValidationError::new(
9120                    1001,
9121                    "orgnl_instr_id is shorter than the minimum length of 1".to_string(),
9122                ));
9123            }
9124            if val.chars().count() > 35 {
9125                return Err(ValidationError::new(
9126                    1002,
9127                    "orgnl_instr_id exceeds the maximum length of 35".to_string(),
9128                ));
9129            }
9130        }
9131        if let Some(ref val) = self.orgnl_end_to_end_id {
9132            if val.chars().count() < 1 {
9133                return Err(ValidationError::new(
9134                    1001,
9135                    "orgnl_end_to_end_id is shorter than the minimum length of 1".to_string(),
9136                ));
9137            }
9138            if val.chars().count() > 35 {
9139                return Err(ValidationError::new(
9140                    1002,
9141                    "orgnl_end_to_end_id exceeds the maximum length of 35".to_string(),
9142                ));
9143            }
9144        }
9145        if let Some(ref val) = self.orgnl_uetr {
9146            let pattern =
9147                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
9148                    .unwrap();
9149            if !pattern.is_match(val) {
9150                return Err(ValidationError::new(
9151                    1005,
9152                    "orgnl_uetr does not match the required pattern".to_string(),
9153                ));
9154            }
9155        }
9156        self.orgnl_instd_amt.validate()?;
9157        if let Some(ref val) = self.reqd_exctn_dt {
9158            val.validate()?
9159        }
9160        if let Some(ref val) = self.orgnl_tx_ref {
9161            val.validate()?
9162        }
9163        Ok(())
9164    }
9165}
9166// UnderlyingPaymentTransaction4 ...
9167#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9168pub struct UnderlyingPaymentTransaction4 {
9169    #[serde(rename = "OrgnlGrpInf", skip_serializing_if = "Option::is_none")]
9170    pub orgnl_grp_inf: Option<UnderlyingGroupInformation1>,
9171    #[serde(rename = "OrgnlInstrId", skip_serializing_if = "Option::is_none")]
9172    pub orgnl_instr_id: Option<String>,
9173    #[serde(rename = "OrgnlEndToEndId", skip_serializing_if = "Option::is_none")]
9174    pub orgnl_end_to_end_id: Option<String>,
9175    #[serde(rename = "OrgnlTxId", skip_serializing_if = "Option::is_none")]
9176    pub orgnl_tx_id: Option<String>,
9177    #[serde(rename = "OrgnlUETR", skip_serializing_if = "Option::is_none")]
9178    pub orgnl_uetr: Option<String>,
9179    #[serde(rename = "OrgnlIntrBkSttlmAmt")]
9180    pub orgnl_intr_bk_sttlm_amt: ActiveOrHistoricCurrencyAndAmount,
9181    #[serde(rename = "OrgnlIntrBkSttlmDt")]
9182    pub orgnl_intr_bk_sttlm_dt: String,
9183    #[serde(rename = "OrgnlTxRef", skip_serializing_if = "Option::is_none")]
9184    pub orgnl_tx_ref: Option<OriginalTransactionReference28>,
9185}
9186
9187impl UnderlyingPaymentTransaction4 {
9188    pub fn validate(&self) -> Result<(), ValidationError> {
9189        if let Some(ref val) = self.orgnl_grp_inf {
9190            val.validate()?
9191        }
9192        if let Some(ref val) = self.orgnl_instr_id {
9193            if val.chars().count() < 1 {
9194                return Err(ValidationError::new(
9195                    1001,
9196                    "orgnl_instr_id is shorter than the minimum length of 1".to_string(),
9197                ));
9198            }
9199            if val.chars().count() > 35 {
9200                return Err(ValidationError::new(
9201                    1002,
9202                    "orgnl_instr_id exceeds the maximum length of 35".to_string(),
9203                ));
9204            }
9205        }
9206        if let Some(ref val) = self.orgnl_end_to_end_id {
9207            if val.chars().count() < 1 {
9208                return Err(ValidationError::new(
9209                    1001,
9210                    "orgnl_end_to_end_id is shorter than the minimum length of 1".to_string(),
9211                ));
9212            }
9213            if val.chars().count() > 35 {
9214                return Err(ValidationError::new(
9215                    1002,
9216                    "orgnl_end_to_end_id exceeds the maximum length of 35".to_string(),
9217                ));
9218            }
9219        }
9220        if let Some(ref val) = self.orgnl_tx_id {
9221            if val.chars().count() < 1 {
9222                return Err(ValidationError::new(
9223                    1001,
9224                    "orgnl_tx_id is shorter than the minimum length of 1".to_string(),
9225                ));
9226            }
9227            if val.chars().count() > 35 {
9228                return Err(ValidationError::new(
9229                    1002,
9230                    "orgnl_tx_id exceeds the maximum length of 35".to_string(),
9231                ));
9232            }
9233        }
9234        if let Some(ref val) = self.orgnl_uetr {
9235            let pattern =
9236                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
9237                    .unwrap();
9238            if !pattern.is_match(val) {
9239                return Err(ValidationError::new(
9240                    1005,
9241                    "orgnl_uetr does not match the required pattern".to_string(),
9242                ));
9243            }
9244        }
9245        self.orgnl_intr_bk_sttlm_amt.validate()?;
9246        if let Some(ref val) = self.orgnl_tx_ref {
9247            val.validate()?
9248        }
9249        Ok(())
9250    }
9251}
9252// UnderlyingStatementEntry3 ...
9253#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9254pub struct UnderlyingStatementEntry3 {
9255    #[serde(rename = "OrgnlGrpInf", skip_serializing_if = "Option::is_none")]
9256    pub orgnl_grp_inf: Option<OriginalGroupInformation29>,
9257    #[serde(rename = "OrgnlStmtId", skip_serializing_if = "Option::is_none")]
9258    pub orgnl_stmt_id: Option<String>,
9259    #[serde(rename = "OrgnlNtryId", skip_serializing_if = "Option::is_none")]
9260    pub orgnl_ntry_id: Option<String>,
9261    #[serde(rename = "OrgnlUETR", skip_serializing_if = "Option::is_none")]
9262    pub orgnl_uetr: Option<String>,
9263}
9264
9265impl UnderlyingStatementEntry3 {
9266    pub fn validate(&self) -> Result<(), ValidationError> {
9267        if let Some(ref val) = self.orgnl_grp_inf {
9268            val.validate()?
9269        }
9270        if let Some(ref val) = self.orgnl_stmt_id {
9271            if val.chars().count() < 1 {
9272                return Err(ValidationError::new(
9273                    1001,
9274                    "orgnl_stmt_id is shorter than the minimum length of 1".to_string(),
9275                ));
9276            }
9277            if val.chars().count() > 35 {
9278                return Err(ValidationError::new(
9279                    1002,
9280                    "orgnl_stmt_id exceeds the maximum length of 35".to_string(),
9281                ));
9282            }
9283        }
9284        if let Some(ref val) = self.orgnl_ntry_id {
9285            if val.chars().count() < 1 {
9286                return Err(ValidationError::new(
9287                    1001,
9288                    "orgnl_ntry_id is shorter than the minimum length of 1".to_string(),
9289                ));
9290            }
9291            if val.chars().count() > 35 {
9292                return Err(ValidationError::new(
9293                    1002,
9294                    "orgnl_ntry_id exceeds the maximum length of 35".to_string(),
9295                ));
9296            }
9297        }
9298        if let Some(ref val) = self.orgnl_uetr {
9299            let pattern =
9300                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
9301                    .unwrap();
9302            if !pattern.is_match(val) {
9303                return Err(ValidationError::new(
9304                    1005,
9305                    "orgnl_uetr does not match the required pattern".to_string(),
9306                ));
9307            }
9308        }
9309        Ok(())
9310    }
9311}
9312// UnderlyingTransaction5Choice ...
9313#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9314pub struct UnderlyingTransaction5Choice {
9315    #[serde(rename = "Initn", skip_serializing_if = "Option::is_none")]
9316    pub initn: Option<UnderlyingPaymentInstruction5>,
9317    #[serde(rename = "IntrBk", skip_serializing_if = "Option::is_none")]
9318    pub intr_bk: Option<UnderlyingPaymentTransaction4>,
9319    #[serde(rename = "StmtNtry", skip_serializing_if = "Option::is_none")]
9320    pub stmt_ntry: Option<UnderlyingStatementEntry3>,
9321}
9322
9323impl UnderlyingTransaction5Choice {
9324    pub fn validate(&self) -> Result<(), ValidationError> {
9325        if let Some(ref val) = self.initn {
9326            val.validate()?
9327        }
9328        if let Some(ref val) = self.intr_bk {
9329            val.validate()?
9330        }
9331        if let Some(ref val) = self.stmt_ntry {
9332            val.validate()?
9333        }
9334        Ok(())
9335    }
9336}
9337// UnitOfMeasure1Code ...
9338#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9339pub enum UnitOfMeasure1Code {
9340    #[default]
9341    #[serde(rename = "PIEC")]
9342    CodePIEC,
9343    #[serde(rename = "TONS")]
9344    CodeTONS,
9345    #[serde(rename = "FOOT")]
9346    CodeFOOT,
9347    #[serde(rename = "GBGA")]
9348    CodeGBGA,
9349    #[serde(rename = "USGA")]
9350    CodeUSGA,
9351    #[serde(rename = "GRAM")]
9352    CodeGRAM,
9353    #[serde(rename = "INCH")]
9354    CodeINCH,
9355    #[serde(rename = "KILO")]
9356    CodeKILO,
9357    #[serde(rename = "PUND")]
9358    CodePUND,
9359    #[serde(rename = "METR")]
9360    CodeMETR,
9361    #[serde(rename = "CMET")]
9362    CodeCMET,
9363    #[serde(rename = "MMET")]
9364    CodeMMET,
9365    #[serde(rename = "LITR")]
9366    CodeLITR,
9367    #[serde(rename = "CELI")]
9368    CodeCELI,
9369    #[serde(rename = "MILI")]
9370    CodeMILI,
9371    #[serde(rename = "GBOU")]
9372    CodeGBOU,
9373    #[serde(rename = "USOU")]
9374    CodeUSOU,
9375    #[serde(rename = "GBQA")]
9376    CodeGBQA,
9377    #[serde(rename = "USQA")]
9378    CodeUSQA,
9379    #[serde(rename = "GBPI")]
9380    CodeGBPI,
9381    #[serde(rename = "USPI")]
9382    CodeUSPI,
9383    #[serde(rename = "MILE")]
9384    CodeMILE,
9385    #[serde(rename = "KMET")]
9386    CodeKMET,
9387    #[serde(rename = "YARD")]
9388    CodeYARD,
9389    #[serde(rename = "SQKI")]
9390    CodeSQKI,
9391    #[serde(rename = "HECT")]
9392    CodeHECT,
9393    #[serde(rename = "ARES")]
9394    CodeARES,
9395    #[serde(rename = "SMET")]
9396    CodeSMET,
9397    #[serde(rename = "SCMT")]
9398    CodeSCMT,
9399    #[serde(rename = "SMIL")]
9400    CodeSMIL,
9401    #[serde(rename = "SQMI")]
9402    CodeSQMI,
9403    #[serde(rename = "SQYA")]
9404    CodeSQYA,
9405    #[serde(rename = "SQFO")]
9406    CodeSQFO,
9407    #[serde(rename = "SQIN")]
9408    CodeSQIN,
9409    #[serde(rename = "ACRE")]
9410    CodeACRE,
9411}
9412
9413impl UnitOfMeasure1Code {
9414    pub fn validate(&self) -> Result<(), ValidationError> {
9415        Ok(())
9416    }
9417}
9418// UserInterface2Code ...
9419#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9420pub enum UserInterface2Code {
9421    #[default]
9422    #[serde(rename = "MDSP")]
9423    CodeMDSP,
9424    #[serde(rename = "CDSP")]
9425    CodeCDSP,
9426}
9427
9428impl UserInterface2Code {
9429    pub fn validate(&self) -> Result<(), ValidationError> {
9430        Ok(())
9431    }
9432}
9433// YieldedOrValueType1Choice ...
9434#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9435pub struct YieldedOrValueType1Choice {
9436    #[serde(rename = "Yldd", skip_serializing_if = "Option::is_none")]
9437    pub yldd: Option<bool>,
9438    #[serde(rename = "ValTp", skip_serializing_if = "Option::is_none")]
9439    pub val_tp: Option<PriceValueType1Code>,
9440}
9441
9442impl YieldedOrValueType1Choice {
9443    pub fn validate(&self) -> Result<(), ValidationError> {
9444        if let Some(ref val) = self.val_tp {
9445            val.validate()?
9446        }
9447        Ok(())
9448    }
9449}