mx_message/
pacs_009_001_08.rs

1// Plasmatic MX Message Parsing Library
2// https://github.com/GoPlasmatic/MXMessage
3//
4// Copyright (c) 2025 Plasmatic
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//     http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// You may obtain a copy of this library at
18// https://github.com/GoPlasmatic/MXMessage
19
20use crate::common::ValidationError;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24// AccountIdentification4Choice ...
25#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice {
27    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
28    pub iban: Option<String>,
29    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
30    pub othr: Option<GenericAccountIdentification1>,
31}
32
33impl AccountIdentification4Choice {
34    pub fn validate(&self) -> Result<(), ValidationError> {
35        if let Some(ref val) = self.iban {
36            let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
37            if !pattern.is_match(val) {
38                return Err(ValidationError::new(
39                    1005,
40                    "iban does not match the required pattern".to_string(),
41                ));
42            }
43        }
44        if let Some(ref val) = self.othr {
45            val.validate()?
46        }
47        Ok(())
48    }
49}
50
51// AccountSchemeName1Choice ...
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountSchemeName1Choice {
54    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55    pub cd: Option<String>,
56    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57    pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice {
61    pub fn validate(&self) -> Result<(), ValidationError> {
62        if let Some(ref val) = self.cd {
63            if val.chars().count() < 1 {
64                return Err(ValidationError::new(
65                    1001,
66                    "cd is shorter than the minimum length of 1".to_string(),
67                ));
68            }
69            if val.chars().count() > 4 {
70                return Err(ValidationError::new(
71                    1002,
72                    "cd exceeds the maximum length of 4".to_string(),
73                ));
74            }
75        }
76        if let Some(ref val) = self.prtry {
77            if val.chars().count() < 1 {
78                return Err(ValidationError::new(
79                    1001,
80                    "prtry is shorter than the minimum length of 1".to_string(),
81                ));
82            }
83            if val.chars().count() > 35 {
84                return Err(ValidationError::new(
85                    1002,
86                    "prtry exceeds the maximum length of 35".to_string(),
87                ));
88            }
89        }
90        Ok(())
91    }
92}
93
94// ActiveCurrencyAndAmount ...
95#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
96pub struct ActiveCurrencyAndAmount {
97    #[serde(rename = "@Ccy")]
98    pub ccy: String,
99    #[serde(rename = "$value")]
100    pub value: f64,
101}
102
103impl ActiveCurrencyAndAmount {
104    pub fn validate(&self) -> Result<(), ValidationError> {
105        Ok(())
106    }
107}
108
109// ActiveOrHistoricCurrencyAndAmount ...
110#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
111pub struct ActiveOrHistoricCurrencyAndAmount {
112    #[serde(rename = "@Ccy")]
113    pub ccy: String,
114    #[serde(rename = "$value")]
115    pub value: f64,
116}
117
118impl ActiveOrHistoricCurrencyAndAmount {
119    pub fn validate(&self) -> Result<(), ValidationError> {
120        Ok(())
121    }
122}
123
124// AddressType2Code ...
125#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
126pub enum AddressType2Code {
127    #[default]
128    #[serde(rename = "ADDR")]
129    CodeADDR,
130    #[serde(rename = "PBOX")]
131    CodePBOX,
132    #[serde(rename = "HOME")]
133    CodeHOME,
134    #[serde(rename = "BIZZ")]
135    CodeBIZZ,
136    #[serde(rename = "MLTO")]
137    CodeMLTO,
138    #[serde(rename = "DLVY")]
139    CodeDLVY,
140}
141
142impl AddressType2Code {
143    pub fn validate(&self) -> Result<(), ValidationError> {
144        Ok(())
145    }
146}
147
148// AddressType3Choice ...
149#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
150pub struct AddressType3Choice {
151    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
152    pub cd: Option<AddressType2Code>,
153    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
154    pub prtry: Option<GenericIdentification30>,
155}
156
157impl AddressType3Choice {
158    pub fn validate(&self) -> Result<(), ValidationError> {
159        if let Some(ref val) = self.cd {
160            val.validate()?
161        }
162        if let Some(ref val) = self.prtry {
163            val.validate()?
164        }
165        Ok(())
166    }
167}
168
169// BranchAndFinancialInstitutionIdentification6 ...
170#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
171pub struct BranchAndFinancialInstitutionIdentification6 {
172    #[serde(rename = "FinInstnId")]
173    pub fin_instn_id: FinancialInstitutionIdentification18,
174    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
175    pub brnch_id: Option<BranchData3>,
176}
177
178impl BranchAndFinancialInstitutionIdentification6 {
179    pub fn validate(&self) -> Result<(), ValidationError> {
180        self.fin_instn_id.validate()?;
181        if let Some(ref val) = self.brnch_id {
182            val.validate()?
183        }
184        Ok(())
185    }
186}
187
188// BranchData3 ...
189#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
190pub struct BranchData3 {
191    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
192    pub id: Option<String>,
193    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
194    pub lei: Option<String>,
195    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
196    pub nm: Option<String>,
197    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
198    pub pstl_adr: Option<PostalAddress24>,
199}
200
201impl BranchData3 {
202    pub fn validate(&self) -> Result<(), ValidationError> {
203        if let Some(ref val) = self.id {
204            if val.chars().count() < 1 {
205                return Err(ValidationError::new(
206                    1001,
207                    "id is shorter than the minimum length of 1".to_string(),
208                ));
209            }
210            if val.chars().count() > 35 {
211                return Err(ValidationError::new(
212                    1002,
213                    "id exceeds the maximum length of 35".to_string(),
214                ));
215            }
216        }
217        if let Some(ref val) = self.lei {
218            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
219            if !pattern.is_match(val) {
220                return Err(ValidationError::new(
221                    1005,
222                    "lei does not match the required pattern".to_string(),
223                ));
224            }
225        }
226        if let Some(ref val) = self.nm {
227            if val.chars().count() < 1 {
228                return Err(ValidationError::new(
229                    1001,
230                    "nm is shorter than the minimum length of 1".to_string(),
231                ));
232            }
233            if val.chars().count() > 140 {
234                return Err(ValidationError::new(
235                    1002,
236                    "nm exceeds the maximum length of 140".to_string(),
237                ));
238            }
239        }
240        if let Some(ref val) = self.pstl_adr {
241            val.validate()?
242        }
243        Ok(())
244    }
245}
246
247// CashAccount38 ...
248#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
249pub struct CashAccount38 {
250    #[serde(rename = "Id")]
251    pub id: AccountIdentification4Choice,
252    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
253    pub tp: Option<CashAccountType2Choice>,
254    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
255    pub ccy: Option<String>,
256    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
257    pub nm: Option<String>,
258    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
259    pub prxy: Option<ProxyAccountIdentification1>,
260}
261
262impl CashAccount38 {
263    pub fn validate(&self) -> Result<(), ValidationError> {
264        self.id.validate()?;
265        if let Some(ref val) = self.tp {
266            val.validate()?
267        }
268        if let Some(ref val) = self.ccy {
269            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
270            if !pattern.is_match(val) {
271                return Err(ValidationError::new(
272                    1005,
273                    "ccy does not match the required pattern".to_string(),
274                ));
275            }
276        }
277        if let Some(ref val) = self.nm {
278            if val.chars().count() < 1 {
279                return Err(ValidationError::new(
280                    1001,
281                    "nm is shorter than the minimum length of 1".to_string(),
282                ));
283            }
284            if val.chars().count() > 70 {
285                return Err(ValidationError::new(
286                    1002,
287                    "nm exceeds the maximum length of 70".to_string(),
288                ));
289            }
290        }
291        if let Some(ref val) = self.prxy {
292            val.validate()?
293        }
294        Ok(())
295    }
296}
297
298// CashAccountType2Choice ...
299#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
300pub struct CashAccountType2Choice {
301    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
302    pub cd: Option<String>,
303    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
304    pub prtry: Option<String>,
305}
306
307impl CashAccountType2Choice {
308    pub fn validate(&self) -> Result<(), ValidationError> {
309        if let Some(ref val) = self.cd {
310            if val.chars().count() < 1 {
311                return Err(ValidationError::new(
312                    1001,
313                    "cd is shorter than the minimum length of 1".to_string(),
314                ));
315            }
316            if val.chars().count() > 4 {
317                return Err(ValidationError::new(
318                    1002,
319                    "cd exceeds the maximum length of 4".to_string(),
320                ));
321            }
322        }
323        if let Some(ref val) = self.prtry {
324            if val.chars().count() < 1 {
325                return Err(ValidationError::new(
326                    1001,
327                    "prtry is shorter than the minimum length of 1".to_string(),
328                ));
329            }
330            if val.chars().count() > 35 {
331                return Err(ValidationError::new(
332                    1002,
333                    "prtry exceeds the maximum length of 35".to_string(),
334                ));
335            }
336        }
337        Ok(())
338    }
339}
340
341// CategoryPurpose1Choice ...
342#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
343pub struct CategoryPurpose1Choice {
344    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
345    pub cd: Option<String>,
346    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
347    pub prtry: Option<String>,
348}
349
350impl CategoryPurpose1Choice {
351    pub fn validate(&self) -> Result<(), ValidationError> {
352        if let Some(ref val) = self.cd {
353            if val.chars().count() < 1 {
354                return Err(ValidationError::new(
355                    1001,
356                    "cd is shorter than the minimum length of 1".to_string(),
357                ));
358            }
359            if val.chars().count() > 4 {
360                return Err(ValidationError::new(
361                    1002,
362                    "cd exceeds the maximum length of 4".to_string(),
363                ));
364            }
365        }
366        if let Some(ref val) = self.prtry {
367            if val.chars().count() < 1 {
368                return Err(ValidationError::new(
369                    1001,
370                    "prtry is shorter than the minimum length of 1".to_string(),
371                ));
372            }
373            if val.chars().count() > 35 {
374                return Err(ValidationError::new(
375                    1002,
376                    "prtry exceeds the maximum length of 35".to_string(),
377                ));
378            }
379        }
380        Ok(())
381    }
382}
383
384// ClearingChannel2Code ...
385#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
386pub enum ClearingChannel2Code {
387    #[default]
388    #[serde(rename = "RTGS")]
389    CodeRTGS,
390    #[serde(rename = "RTNS")]
391    CodeRTNS,
392    #[serde(rename = "MPNS")]
393    CodeMPNS,
394    #[serde(rename = "BOOK")]
395    CodeBOOK,
396}
397
398impl ClearingChannel2Code {
399    pub fn validate(&self) -> Result<(), ValidationError> {
400        Ok(())
401    }
402}
403
404// ClearingSystemIdentification2Choice ...
405#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
406pub struct ClearingSystemIdentification2Choice {
407    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
408    pub cd: Option<String>,
409    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
410    pub prtry: Option<String>,
411}
412
413impl ClearingSystemIdentification2Choice {
414    pub fn validate(&self) -> Result<(), ValidationError> {
415        if let Some(ref val) = self.cd {
416            if val.chars().count() < 1 {
417                return Err(ValidationError::new(
418                    1001,
419                    "cd is shorter than the minimum length of 1".to_string(),
420                ));
421            }
422            if val.chars().count() > 5 {
423                return Err(ValidationError::new(
424                    1002,
425                    "cd exceeds the maximum length of 5".to_string(),
426                ));
427            }
428        }
429        if let Some(ref val) = self.prtry {
430            if val.chars().count() < 1 {
431                return Err(ValidationError::new(
432                    1001,
433                    "prtry is shorter than the minimum length of 1".to_string(),
434                ));
435            }
436            if val.chars().count() > 35 {
437                return Err(ValidationError::new(
438                    1002,
439                    "prtry exceeds the maximum length of 35".to_string(),
440                ));
441            }
442        }
443        Ok(())
444    }
445}
446
447// ClearingSystemIdentification3Choice ...
448#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
449pub struct ClearingSystemIdentification3Choice {
450    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
451    pub cd: Option<String>,
452    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
453    pub prtry: Option<String>,
454}
455
456impl ClearingSystemIdentification3Choice {
457    pub fn validate(&self) -> Result<(), ValidationError> {
458        if let Some(ref val) = self.cd {
459            if val.chars().count() < 1 {
460                return Err(ValidationError::new(
461                    1001,
462                    "cd is shorter than the minimum length of 1".to_string(),
463                ));
464            }
465            if val.chars().count() > 3 {
466                return Err(ValidationError::new(
467                    1002,
468                    "cd exceeds the maximum length of 3".to_string(),
469                ));
470            }
471        }
472        if let Some(ref val) = self.prtry {
473            if val.chars().count() < 1 {
474                return Err(ValidationError::new(
475                    1001,
476                    "prtry is shorter than the minimum length of 1".to_string(),
477                ));
478            }
479            if val.chars().count() > 35 {
480                return Err(ValidationError::new(
481                    1002,
482                    "prtry exceeds the maximum length of 35".to_string(),
483                ));
484            }
485        }
486        Ok(())
487    }
488}
489
490// ClearingSystemMemberIdentification2 ...
491#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
492pub struct ClearingSystemMemberIdentification2 {
493    #[serde(rename = "ClrSysId", skip_serializing_if = "Option::is_none")]
494    pub clr_sys_id: Option<ClearingSystemIdentification2Choice>,
495    #[serde(rename = "MmbId")]
496    pub mmb_id: String,
497}
498
499impl ClearingSystemMemberIdentification2 {
500    pub fn validate(&self) -> Result<(), ValidationError> {
501        if let Some(ref val) = self.clr_sys_id {
502            val.validate()?
503        }
504        if self.mmb_id.chars().count() < 1 {
505            return Err(ValidationError::new(
506                1001,
507                "mmb_id is shorter than the minimum length of 1".to_string(),
508            ));
509        }
510        if self.mmb_id.chars().count() > 35 {
511            return Err(ValidationError::new(
512                1002,
513                "mmb_id exceeds the maximum length of 35".to_string(),
514            ));
515        }
516        Ok(())
517    }
518}
519
520// Contact4 ...
521#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
522pub struct Contact4 {
523    #[serde(rename = "NmPrfx", skip_serializing_if = "Option::is_none")]
524    pub nm_prfx: Option<NamePrefix2Code>,
525    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
526    pub nm: Option<String>,
527    #[serde(rename = "PhneNb", skip_serializing_if = "Option::is_none")]
528    pub phne_nb: Option<String>,
529    #[serde(rename = "MobNb", skip_serializing_if = "Option::is_none")]
530    pub mob_nb: Option<String>,
531    #[serde(rename = "FaxNb", skip_serializing_if = "Option::is_none")]
532    pub fax_nb: Option<String>,
533    #[serde(rename = "EmailAdr", skip_serializing_if = "Option::is_none")]
534    pub email_adr: Option<String>,
535    #[serde(rename = "EmailPurp", skip_serializing_if = "Option::is_none")]
536    pub email_purp: Option<String>,
537    #[serde(rename = "JobTitl", skip_serializing_if = "Option::is_none")]
538    pub job_titl: Option<String>,
539    #[serde(rename = "Rspnsblty", skip_serializing_if = "Option::is_none")]
540    pub rspnsblty: Option<String>,
541    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
542    pub dept: Option<String>,
543    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
544    pub othr: Option<Vec<OtherContact1>>,
545    #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
546    pub prefrd_mtd: Option<PreferredContactMethod1Code>,
547}
548
549impl Contact4 {
550    pub fn validate(&self) -> Result<(), ValidationError> {
551        if let Some(ref val) = self.nm_prfx {
552            val.validate()?
553        }
554        if let Some(ref val) = self.nm {
555            if val.chars().count() < 1 {
556                return Err(ValidationError::new(
557                    1001,
558                    "nm is shorter than the minimum length of 1".to_string(),
559                ));
560            }
561            if val.chars().count() > 140 {
562                return Err(ValidationError::new(
563                    1002,
564                    "nm exceeds the maximum length of 140".to_string(),
565                ));
566            }
567        }
568        if let Some(ref val) = self.phne_nb {
569            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
570            if !pattern.is_match(val) {
571                return Err(ValidationError::new(
572                    1005,
573                    "phne_nb does not match the required pattern".to_string(),
574                ));
575            }
576        }
577        if let Some(ref val) = self.mob_nb {
578            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
579            if !pattern.is_match(val) {
580                return Err(ValidationError::new(
581                    1005,
582                    "mob_nb does not match the required pattern".to_string(),
583                ));
584            }
585        }
586        if let Some(ref val) = self.fax_nb {
587            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
588            if !pattern.is_match(val) {
589                return Err(ValidationError::new(
590                    1005,
591                    "fax_nb does not match the required pattern".to_string(),
592                ));
593            }
594        }
595        if let Some(ref val) = self.email_adr {
596            if val.chars().count() < 1 {
597                return Err(ValidationError::new(
598                    1001,
599                    "email_adr is shorter than the minimum length of 1".to_string(),
600                ));
601            }
602            if val.chars().count() > 2048 {
603                return Err(ValidationError::new(
604                    1002,
605                    "email_adr exceeds the maximum length of 2048".to_string(),
606                ));
607            }
608        }
609        if let Some(ref val) = self.email_purp {
610            if val.chars().count() < 1 {
611                return Err(ValidationError::new(
612                    1001,
613                    "email_purp is shorter than the minimum length of 1".to_string(),
614                ));
615            }
616            if val.chars().count() > 35 {
617                return Err(ValidationError::new(
618                    1002,
619                    "email_purp exceeds the maximum length of 35".to_string(),
620                ));
621            }
622        }
623        if let Some(ref val) = self.job_titl {
624            if val.chars().count() < 1 {
625                return Err(ValidationError::new(
626                    1001,
627                    "job_titl is shorter than the minimum length of 1".to_string(),
628                ));
629            }
630            if val.chars().count() > 35 {
631                return Err(ValidationError::new(
632                    1002,
633                    "job_titl exceeds the maximum length of 35".to_string(),
634                ));
635            }
636        }
637        if let Some(ref val) = self.rspnsblty {
638            if val.chars().count() < 1 {
639                return Err(ValidationError::new(
640                    1001,
641                    "rspnsblty is shorter than the minimum length of 1".to_string(),
642                ));
643            }
644            if val.chars().count() > 35 {
645                return Err(ValidationError::new(
646                    1002,
647                    "rspnsblty exceeds the maximum length of 35".to_string(),
648                ));
649            }
650        }
651        if let Some(ref val) = self.dept {
652            if val.chars().count() < 1 {
653                return Err(ValidationError::new(
654                    1001,
655                    "dept is shorter than the minimum length of 1".to_string(),
656                ));
657            }
658            if val.chars().count() > 70 {
659                return Err(ValidationError::new(
660                    1002,
661                    "dept exceeds the maximum length of 70".to_string(),
662                ));
663            }
664        }
665        if let Some(ref vec) = self.othr {
666            for item in vec {
667                item.validate()?
668            }
669        }
670        if let Some(ref val) = self.prefrd_mtd {
671            val.validate()?
672        }
673        Ok(())
674    }
675}
676
677// CreditDebitCode ...
678#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
679pub enum CreditDebitCode {
680    #[default]
681    #[serde(rename = "CRDT")]
682    CodeCRDT,
683    #[serde(rename = "DBIT")]
684    CodeDBIT,
685}
686
687impl CreditDebitCode {
688    pub fn validate(&self) -> Result<(), ValidationError> {
689        Ok(())
690    }
691}
692
693// CreditTransferTransaction36 ...
694#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
695pub struct CreditTransferTransaction36 {
696    #[serde(rename = "PmtId")]
697    pub pmt_id: PaymentIdentification7,
698    #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
699    pub pmt_tp_inf: Option<PaymentTypeInformation28>,
700    #[serde(rename = "IntrBkSttlmAmt")]
701    pub intr_bk_sttlm_amt: ActiveCurrencyAndAmount,
702    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
703    pub intr_bk_sttlm_dt: Option<String>,
704    #[serde(rename = "SttlmPrty", skip_serializing_if = "Option::is_none")]
705    pub sttlm_prty: Option<Priority3Code>,
706    #[serde(rename = "SttlmTmIndctn", skip_serializing_if = "Option::is_none")]
707    pub sttlm_tm_indctn: Option<SettlementDateTimeIndication1>,
708    #[serde(rename = "SttlmTmReq", skip_serializing_if = "Option::is_none")]
709    pub sttlm_tm_req: Option<SettlementTimeRequest2>,
710    #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
711    pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
712    #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
713    pub prvs_instg_agt1_acct: Option<CashAccount38>,
714    #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
715    pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
716    #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
717    pub prvs_instg_agt2_acct: Option<CashAccount38>,
718    #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
719    pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
720    #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
721    pub prvs_instg_agt3_acct: Option<CashAccount38>,
722    #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
723    pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
724    #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
725    pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
726    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
727    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
728    #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
729    pub intrmy_agt1_acct: Option<CashAccount38>,
730    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
731    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
732    #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
733    pub intrmy_agt2_acct: Option<CashAccount38>,
734    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
735    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
736    #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
737    pub intrmy_agt3_acct: Option<CashAccount38>,
738    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
739    pub ultmt_dbtr: Option<BranchAndFinancialInstitutionIdentification6>,
740    #[serde(rename = "Dbtr")]
741    pub dbtr: BranchAndFinancialInstitutionIdentification6,
742    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
743    pub dbtr_acct: Option<CashAccount38>,
744    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
745    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
746    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
747    pub dbtr_agt_acct: Option<CashAccount38>,
748    #[serde(rename = "CdtrAgt", skip_serializing_if = "Option::is_none")]
749    pub cdtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
750    #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
751    pub cdtr_agt_acct: Option<CashAccount38>,
752    #[serde(rename = "Cdtr")]
753    pub cdtr: BranchAndFinancialInstitutionIdentification6,
754    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
755    pub cdtr_acct: Option<CashAccount38>,
756    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
757    pub ultmt_cdtr: Option<BranchAndFinancialInstitutionIdentification6>,
758    #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
759    pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent2>>,
760    #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
761    pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent1>>,
762    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
763    pub purp: Option<Purpose2Choice>,
764    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
765    pub rmt_inf: Option<RemittanceInformation2>,
766    #[serde(rename = "UndrlygCstmrCdtTrf", skip_serializing_if = "Option::is_none")]
767    pub undrlyg_cstmr_cdt_trf: Option<CreditTransferTransaction37>,
768    #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
769    pub splmtry_data: Option<Vec<SupplementaryData1>>,
770}
771
772impl CreditTransferTransaction36 {
773    pub fn validate(&self) -> Result<(), ValidationError> {
774        self.pmt_id.validate()?;
775        if let Some(ref val) = self.pmt_tp_inf {
776            val.validate()?
777        }
778        self.intr_bk_sttlm_amt.validate()?;
779        if let Some(ref val) = self.sttlm_prty {
780            val.validate()?
781        }
782        if let Some(ref val) = self.sttlm_tm_indctn {
783            val.validate()?
784        }
785        if let Some(ref val) = self.sttlm_tm_req {
786            val.validate()?
787        }
788        if let Some(ref val) = self.prvs_instg_agt1 {
789            val.validate()?
790        }
791        if let Some(ref val) = self.prvs_instg_agt1_acct {
792            val.validate()?
793        }
794        if let Some(ref val) = self.prvs_instg_agt2 {
795            val.validate()?
796        }
797        if let Some(ref val) = self.prvs_instg_agt2_acct {
798            val.validate()?
799        }
800        if let Some(ref val) = self.prvs_instg_agt3 {
801            val.validate()?
802        }
803        if let Some(ref val) = self.prvs_instg_agt3_acct {
804            val.validate()?
805        }
806        if let Some(ref val) = self.instg_agt {
807            val.validate()?
808        }
809        if let Some(ref val) = self.instd_agt {
810            val.validate()?
811        }
812        if let Some(ref val) = self.intrmy_agt1 {
813            val.validate()?
814        }
815        if let Some(ref val) = self.intrmy_agt1_acct {
816            val.validate()?
817        }
818        if let Some(ref val) = self.intrmy_agt2 {
819            val.validate()?
820        }
821        if let Some(ref val) = self.intrmy_agt2_acct {
822            val.validate()?
823        }
824        if let Some(ref val) = self.intrmy_agt3 {
825            val.validate()?
826        }
827        if let Some(ref val) = self.intrmy_agt3_acct {
828            val.validate()?
829        }
830        if let Some(ref val) = self.ultmt_dbtr {
831            val.validate()?
832        }
833        self.dbtr.validate()?;
834        if let Some(ref val) = self.dbtr_acct {
835            val.validate()?
836        }
837        if let Some(ref val) = self.dbtr_agt {
838            val.validate()?
839        }
840        if let Some(ref val) = self.dbtr_agt_acct {
841            val.validate()?
842        }
843        if let Some(ref val) = self.cdtr_agt {
844            val.validate()?
845        }
846        if let Some(ref val) = self.cdtr_agt_acct {
847            val.validate()?
848        }
849        self.cdtr.validate()?;
850        if let Some(ref val) = self.cdtr_acct {
851            val.validate()?
852        }
853        if let Some(ref val) = self.ultmt_cdtr {
854            val.validate()?
855        }
856        if let Some(ref vec) = self.instr_for_cdtr_agt {
857            for item in vec {
858                item.validate()?
859            }
860        }
861        if let Some(ref vec) = self.instr_for_nxt_agt {
862            for item in vec {
863                item.validate()?
864            }
865        }
866        if let Some(ref val) = self.purp {
867            val.validate()?
868        }
869        if let Some(ref val) = self.rmt_inf {
870            val.validate()?
871        }
872        if let Some(ref val) = self.undrlyg_cstmr_cdt_trf {
873            val.validate()?
874        }
875        if let Some(ref vec) = self.splmtry_data {
876            for item in vec {
877                item.validate()?
878            }
879        }
880        Ok(())
881    }
882}
883
884// CreditTransferTransaction37 ...
885#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
886pub struct CreditTransferTransaction37 {
887    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
888    pub ultmt_dbtr: Option<PartyIdentification135>,
889    #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
890    pub initg_pty: Option<PartyIdentification135>,
891    #[serde(rename = "Dbtr")]
892    pub dbtr: PartyIdentification135,
893    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
894    pub dbtr_acct: Option<CashAccount38>,
895    #[serde(rename = "DbtrAgt")]
896    pub dbtr_agt: BranchAndFinancialInstitutionIdentification6,
897    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
898    pub dbtr_agt_acct: Option<CashAccount38>,
899    #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
900    pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
901    #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
902    pub prvs_instg_agt1_acct: Option<CashAccount38>,
903    #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
904    pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
905    #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
906    pub prvs_instg_agt2_acct: Option<CashAccount38>,
907    #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
908    pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
909    #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
910    pub prvs_instg_agt3_acct: Option<CashAccount38>,
911    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
912    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
913    #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
914    pub intrmy_agt1_acct: Option<CashAccount38>,
915    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
916    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
917    #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
918    pub intrmy_agt2_acct: Option<CashAccount38>,
919    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
920    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
921    #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
922    pub intrmy_agt3_acct: Option<CashAccount38>,
923    #[serde(rename = "CdtrAgt")]
924    pub cdtr_agt: BranchAndFinancialInstitutionIdentification6,
925    #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
926    pub cdtr_agt_acct: Option<CashAccount38>,
927    #[serde(rename = "Cdtr")]
928    pub cdtr: PartyIdentification135,
929    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
930    pub cdtr_acct: Option<CashAccount38>,
931    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
932    pub ultmt_cdtr: Option<PartyIdentification135>,
933    #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
934    pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent1>>,
935    #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
936    pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent1>>,
937    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
938    pub tax: Option<TaxInformation8>,
939    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
940    pub rmt_inf: Option<RemittanceInformation16>,
941    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
942    pub instd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
943}
944
945impl CreditTransferTransaction37 {
946    pub fn validate(&self) -> Result<(), ValidationError> {
947        if let Some(ref val) = self.ultmt_dbtr {
948            val.validate()?
949        }
950        if let Some(ref val) = self.initg_pty {
951            val.validate()?
952        }
953        self.dbtr.validate()?;
954        if let Some(ref val) = self.dbtr_acct {
955            val.validate()?
956        }
957        self.dbtr_agt.validate()?;
958        if let Some(ref val) = self.dbtr_agt_acct {
959            val.validate()?
960        }
961        if let Some(ref val) = self.prvs_instg_agt1 {
962            val.validate()?
963        }
964        if let Some(ref val) = self.prvs_instg_agt1_acct {
965            val.validate()?
966        }
967        if let Some(ref val) = self.prvs_instg_agt2 {
968            val.validate()?
969        }
970        if let Some(ref val) = self.prvs_instg_agt2_acct {
971            val.validate()?
972        }
973        if let Some(ref val) = self.prvs_instg_agt3 {
974            val.validate()?
975        }
976        if let Some(ref val) = self.prvs_instg_agt3_acct {
977            val.validate()?
978        }
979        if let Some(ref val) = self.intrmy_agt1 {
980            val.validate()?
981        }
982        if let Some(ref val) = self.intrmy_agt1_acct {
983            val.validate()?
984        }
985        if let Some(ref val) = self.intrmy_agt2 {
986            val.validate()?
987        }
988        if let Some(ref val) = self.intrmy_agt2_acct {
989            val.validate()?
990        }
991        if let Some(ref val) = self.intrmy_agt3 {
992            val.validate()?
993        }
994        if let Some(ref val) = self.intrmy_agt3_acct {
995            val.validate()?
996        }
997        self.cdtr_agt.validate()?;
998        if let Some(ref val) = self.cdtr_agt_acct {
999            val.validate()?
1000        }
1001        self.cdtr.validate()?;
1002        if let Some(ref val) = self.cdtr_acct {
1003            val.validate()?
1004        }
1005        if let Some(ref val) = self.ultmt_cdtr {
1006            val.validate()?
1007        }
1008        if let Some(ref vec) = self.instr_for_cdtr_agt {
1009            for item in vec {
1010                item.validate()?
1011            }
1012        }
1013        if let Some(ref vec) = self.instr_for_nxt_agt {
1014            for item in vec {
1015                item.validate()?
1016            }
1017        }
1018        if let Some(ref val) = self.tax {
1019            val.validate()?
1020        }
1021        if let Some(ref val) = self.rmt_inf {
1022            val.validate()?
1023        }
1024        if let Some(ref val) = self.instd_amt {
1025            val.validate()?
1026        }
1027        Ok(())
1028    }
1029}
1030
1031// CreditorReferenceInformation2 ...
1032#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1033pub struct CreditorReferenceInformation2 {
1034    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1035    pub tp: Option<CreditorReferenceType2>,
1036    #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
1037    pub ref_attr: Option<String>,
1038}
1039
1040impl CreditorReferenceInformation2 {
1041    pub fn validate(&self) -> Result<(), ValidationError> {
1042        if let Some(ref val) = self.tp {
1043            val.validate()?
1044        }
1045        if let Some(ref val) = self.ref_attr {
1046            if val.chars().count() < 1 {
1047                return Err(ValidationError::new(
1048                    1001,
1049                    "ref_attr is shorter than the minimum length of 1".to_string(),
1050                ));
1051            }
1052            if val.chars().count() > 35 {
1053                return Err(ValidationError::new(
1054                    1002,
1055                    "ref_attr exceeds the maximum length of 35".to_string(),
1056                ));
1057            }
1058        }
1059        Ok(())
1060    }
1061}
1062
1063// CreditorReferenceType1Choice ...
1064#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1065pub struct CreditorReferenceType1Choice {
1066    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1067    pub cd: Option<DocumentType3Code>,
1068    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1069    pub prtry: Option<String>,
1070}
1071
1072impl CreditorReferenceType1Choice {
1073    pub fn validate(&self) -> Result<(), ValidationError> {
1074        if let Some(ref val) = self.cd {
1075            val.validate()?
1076        }
1077        if let Some(ref val) = self.prtry {
1078            if val.chars().count() < 1 {
1079                return Err(ValidationError::new(
1080                    1001,
1081                    "prtry is shorter than the minimum length of 1".to_string(),
1082                ));
1083            }
1084            if val.chars().count() > 35 {
1085                return Err(ValidationError::new(
1086                    1002,
1087                    "prtry exceeds the maximum length of 35".to_string(),
1088                ));
1089            }
1090        }
1091        Ok(())
1092    }
1093}
1094
1095// CreditorReferenceType2 ...
1096#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1097pub struct CreditorReferenceType2 {
1098    #[serde(rename = "CdOrPrtry")]
1099    pub cd_or_prtry: CreditorReferenceType1Choice,
1100    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1101    pub issr: Option<String>,
1102}
1103
1104impl CreditorReferenceType2 {
1105    pub fn validate(&self) -> Result<(), ValidationError> {
1106        self.cd_or_prtry.validate()?;
1107        if let Some(ref val) = self.issr {
1108            if val.chars().count() < 1 {
1109                return Err(ValidationError::new(
1110                    1001,
1111                    "issr is shorter than the minimum length of 1".to_string(),
1112                ));
1113            }
1114            if val.chars().count() > 35 {
1115                return Err(ValidationError::new(
1116                    1002,
1117                    "issr exceeds the maximum length of 35".to_string(),
1118                ));
1119            }
1120        }
1121        Ok(())
1122    }
1123}
1124
1125// DateAndPlaceOfBirth1 ...
1126#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1127pub struct DateAndPlaceOfBirth1 {
1128    #[serde(rename = "BirthDt")]
1129    pub birth_dt: String,
1130    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
1131    pub prvc_of_birth: Option<String>,
1132    #[serde(rename = "CityOfBirth")]
1133    pub city_of_birth: String,
1134    #[serde(rename = "CtryOfBirth")]
1135    pub ctry_of_birth: String,
1136}
1137
1138impl DateAndPlaceOfBirth1 {
1139    pub fn validate(&self) -> Result<(), ValidationError> {
1140        if let Some(ref val) = self.prvc_of_birth {
1141            if val.chars().count() < 1 {
1142                return Err(ValidationError::new(
1143                    1001,
1144                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
1145                ));
1146            }
1147            if val.chars().count() > 35 {
1148                return Err(ValidationError::new(
1149                    1002,
1150                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
1151                ));
1152            }
1153        }
1154        if self.city_of_birth.chars().count() < 1 {
1155            return Err(ValidationError::new(
1156                1001,
1157                "city_of_birth is shorter than the minimum length of 1".to_string(),
1158            ));
1159        }
1160        if self.city_of_birth.chars().count() > 35 {
1161            return Err(ValidationError::new(
1162                1002,
1163                "city_of_birth exceeds the maximum length of 35".to_string(),
1164            ));
1165        }
1166        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1167        if !pattern.is_match(&self.ctry_of_birth) {
1168            return Err(ValidationError::new(
1169                1005,
1170                "ctry_of_birth does not match the required pattern".to_string(),
1171            ));
1172        }
1173        Ok(())
1174    }
1175}
1176
1177// DatePeriod2 ...
1178#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1179pub struct DatePeriod2 {
1180    #[serde(rename = "FrDt")]
1181    pub fr_dt: String,
1182    #[serde(rename = "ToDt")]
1183    pub to_dt: String,
1184}
1185
1186impl DatePeriod2 {
1187    pub fn validate(&self) -> Result<(), ValidationError> {
1188        Ok(())
1189    }
1190}
1191
1192// DiscountAmountAndType1 ...
1193#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1194pub struct DiscountAmountAndType1 {
1195    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1196    pub tp: Option<DiscountAmountType1Choice>,
1197    #[serde(rename = "Amt")]
1198    pub amt: ActiveOrHistoricCurrencyAndAmount,
1199}
1200
1201impl DiscountAmountAndType1 {
1202    pub fn validate(&self) -> Result<(), ValidationError> {
1203        if let Some(ref val) = self.tp {
1204            val.validate()?
1205        }
1206        self.amt.validate()?;
1207        Ok(())
1208    }
1209}
1210
1211// DiscountAmountType1Choice ...
1212#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1213pub struct DiscountAmountType1Choice {
1214    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1215    pub cd: Option<String>,
1216    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1217    pub prtry: Option<String>,
1218}
1219
1220impl DiscountAmountType1Choice {
1221    pub fn validate(&self) -> Result<(), ValidationError> {
1222        if let Some(ref val) = self.cd {
1223            if val.chars().count() < 1 {
1224                return Err(ValidationError::new(
1225                    1001,
1226                    "cd is shorter than the minimum length of 1".to_string(),
1227                ));
1228            }
1229            if val.chars().count() > 4 {
1230                return Err(ValidationError::new(
1231                    1002,
1232                    "cd exceeds the maximum length of 4".to_string(),
1233                ));
1234            }
1235        }
1236        if let Some(ref val) = self.prtry {
1237            if val.chars().count() < 1 {
1238                return Err(ValidationError::new(
1239                    1001,
1240                    "prtry is shorter than the minimum length of 1".to_string(),
1241                ));
1242            }
1243            if val.chars().count() > 35 {
1244                return Err(ValidationError::new(
1245                    1002,
1246                    "prtry exceeds the maximum length of 35".to_string(),
1247                ));
1248            }
1249        }
1250        Ok(())
1251    }
1252}
1253
1254// DocumentAdjustment1 ...
1255#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1256pub struct DocumentAdjustment1 {
1257    #[serde(rename = "Amt")]
1258    pub amt: ActiveOrHistoricCurrencyAndAmount,
1259    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1260    pub cdt_dbt_ind: Option<CreditDebitCode>,
1261    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1262    pub rsn: Option<String>,
1263    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1264    pub addtl_inf: Option<String>,
1265}
1266
1267impl DocumentAdjustment1 {
1268    pub fn validate(&self) -> Result<(), ValidationError> {
1269        self.amt.validate()?;
1270        if let Some(ref val) = self.cdt_dbt_ind {
1271            val.validate()?
1272        }
1273        if let Some(ref val) = self.rsn {
1274            if val.chars().count() < 1 {
1275                return Err(ValidationError::new(
1276                    1001,
1277                    "rsn is shorter than the minimum length of 1".to_string(),
1278                ));
1279            }
1280            if val.chars().count() > 4 {
1281                return Err(ValidationError::new(
1282                    1002,
1283                    "rsn exceeds the maximum length of 4".to_string(),
1284                ));
1285            }
1286        }
1287        if let Some(ref val) = self.addtl_inf {
1288            if val.chars().count() < 1 {
1289                return Err(ValidationError::new(
1290                    1001,
1291                    "addtl_inf is shorter than the minimum length of 1".to_string(),
1292                ));
1293            }
1294            if val.chars().count() > 140 {
1295                return Err(ValidationError::new(
1296                    1002,
1297                    "addtl_inf exceeds the maximum length of 140".to_string(),
1298                ));
1299            }
1300        }
1301        Ok(())
1302    }
1303}
1304
1305// DocumentLineIdentification1 ...
1306#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1307pub struct DocumentLineIdentification1 {
1308    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1309    pub tp: Option<DocumentLineType1>,
1310    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
1311    pub nb: Option<String>,
1312    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
1313    pub rltd_dt: Option<String>,
1314}
1315
1316impl DocumentLineIdentification1 {
1317    pub fn validate(&self) -> Result<(), ValidationError> {
1318        if let Some(ref val) = self.tp {
1319            val.validate()?
1320        }
1321        if let Some(ref val) = self.nb {
1322            if val.chars().count() < 1 {
1323                return Err(ValidationError::new(
1324                    1001,
1325                    "nb is shorter than the minimum length of 1".to_string(),
1326                ));
1327            }
1328            if val.chars().count() > 35 {
1329                return Err(ValidationError::new(
1330                    1002,
1331                    "nb exceeds the maximum length of 35".to_string(),
1332                ));
1333            }
1334        }
1335        Ok(())
1336    }
1337}
1338
1339// DocumentLineInformation1 ...
1340#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1341pub struct DocumentLineInformation1 {
1342    #[serde(rename = "Id")]
1343    pub id: Vec<DocumentLineIdentification1>,
1344    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
1345    pub desc: Option<String>,
1346    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
1347    pub amt: Option<RemittanceAmount3>,
1348}
1349
1350impl DocumentLineInformation1 {
1351    pub fn validate(&self) -> Result<(), ValidationError> {
1352        for item in &self.id {
1353            item.validate()?
1354        }
1355        if let Some(ref val) = self.desc {
1356            if val.chars().count() < 1 {
1357                return Err(ValidationError::new(
1358                    1001,
1359                    "desc is shorter than the minimum length of 1".to_string(),
1360                ));
1361            }
1362            if val.chars().count() > 2048 {
1363                return Err(ValidationError::new(
1364                    1002,
1365                    "desc exceeds the maximum length of 2048".to_string(),
1366                ));
1367            }
1368        }
1369        if let Some(ref val) = self.amt {
1370            val.validate()?
1371        }
1372        Ok(())
1373    }
1374}
1375
1376// DocumentLineType1 ...
1377#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1378pub struct DocumentLineType1 {
1379    #[serde(rename = "CdOrPrtry")]
1380    pub cd_or_prtry: DocumentLineType1Choice,
1381    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1382    pub issr: Option<String>,
1383}
1384
1385impl DocumentLineType1 {
1386    pub fn validate(&self) -> Result<(), ValidationError> {
1387        self.cd_or_prtry.validate()?;
1388        if let Some(ref val) = self.issr {
1389            if val.chars().count() < 1 {
1390                return Err(ValidationError::new(
1391                    1001,
1392                    "issr is shorter than the minimum length of 1".to_string(),
1393                ));
1394            }
1395            if val.chars().count() > 35 {
1396                return Err(ValidationError::new(
1397                    1002,
1398                    "issr exceeds the maximum length of 35".to_string(),
1399                ));
1400            }
1401        }
1402        Ok(())
1403    }
1404}
1405
1406// DocumentLineType1Choice ...
1407#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1408pub struct DocumentLineType1Choice {
1409    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1410    pub cd: Option<String>,
1411    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1412    pub prtry: Option<String>,
1413}
1414
1415impl DocumentLineType1Choice {
1416    pub fn validate(&self) -> Result<(), ValidationError> {
1417        if let Some(ref val) = self.cd {
1418            if val.chars().count() < 1 {
1419                return Err(ValidationError::new(
1420                    1001,
1421                    "cd is shorter than the minimum length of 1".to_string(),
1422                ));
1423            }
1424            if val.chars().count() > 4 {
1425                return Err(ValidationError::new(
1426                    1002,
1427                    "cd exceeds the maximum length of 4".to_string(),
1428                ));
1429            }
1430        }
1431        if let Some(ref val) = self.prtry {
1432            if val.chars().count() < 1 {
1433                return Err(ValidationError::new(
1434                    1001,
1435                    "prtry is shorter than the minimum length of 1".to_string(),
1436                ));
1437            }
1438            if val.chars().count() > 35 {
1439                return Err(ValidationError::new(
1440                    1002,
1441                    "prtry exceeds the maximum length of 35".to_string(),
1442                ));
1443            }
1444        }
1445        Ok(())
1446    }
1447}
1448
1449// DocumentType3Code ...
1450#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1451pub enum DocumentType3Code {
1452    #[default]
1453    #[serde(rename = "RADM")]
1454    CodeRADM,
1455    #[serde(rename = "RPIN")]
1456    CodeRPIN,
1457    #[serde(rename = "FXDR")]
1458    CodeFXDR,
1459    #[serde(rename = "DISP")]
1460    CodeDISP,
1461    #[serde(rename = "PUOR")]
1462    CodePUOR,
1463    #[serde(rename = "SCOR")]
1464    CodeSCOR,
1465}
1466
1467impl DocumentType3Code {
1468    pub fn validate(&self) -> Result<(), ValidationError> {
1469        Ok(())
1470    }
1471}
1472
1473// DocumentType6Code ...
1474#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1475pub enum DocumentType6Code {
1476    #[default]
1477    #[serde(rename = "MSIN")]
1478    CodeMSIN,
1479    #[serde(rename = "CNFA")]
1480    CodeCNFA,
1481    #[serde(rename = "DNFA")]
1482    CodeDNFA,
1483    #[serde(rename = "CINV")]
1484    CodeCINV,
1485    #[serde(rename = "CREN")]
1486    CodeCREN,
1487    #[serde(rename = "DEBN")]
1488    CodeDEBN,
1489    #[serde(rename = "HIRI")]
1490    CodeHIRI,
1491    #[serde(rename = "SBIN")]
1492    CodeSBIN,
1493    #[serde(rename = "CMCN")]
1494    CodeCMCN,
1495    #[serde(rename = "SOAC")]
1496    CodeSOAC,
1497    #[serde(rename = "DISP")]
1498    CodeDISP,
1499    #[serde(rename = "BOLD")]
1500    CodeBOLD,
1501    #[serde(rename = "VCHR")]
1502    CodeVCHR,
1503    #[serde(rename = "AROI")]
1504    CodeAROI,
1505    #[serde(rename = "TSUT")]
1506    CodeTSUT,
1507    #[serde(rename = "PUOR")]
1508    CodePUOR,
1509}
1510
1511impl DocumentType6Code {
1512    pub fn validate(&self) -> Result<(), ValidationError> {
1513        Ok(())
1514    }
1515}
1516
1517// FinancialIdentificationSchemeName1Choice ...
1518#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1519pub struct FinancialIdentificationSchemeName1Choice {
1520    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1521    pub cd: Option<String>,
1522    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1523    pub prtry: Option<String>,
1524}
1525
1526impl FinancialIdentificationSchemeName1Choice {
1527    pub fn validate(&self) -> Result<(), ValidationError> {
1528        if let Some(ref val) = self.cd {
1529            if val.chars().count() < 1 {
1530                return Err(ValidationError::new(
1531                    1001,
1532                    "cd is shorter than the minimum length of 1".to_string(),
1533                ));
1534            }
1535            if val.chars().count() > 4 {
1536                return Err(ValidationError::new(
1537                    1002,
1538                    "cd exceeds the maximum length of 4".to_string(),
1539                ));
1540            }
1541        }
1542        if let Some(ref val) = self.prtry {
1543            if val.chars().count() < 1 {
1544                return Err(ValidationError::new(
1545                    1001,
1546                    "prtry is shorter than the minimum length of 1".to_string(),
1547                ));
1548            }
1549            if val.chars().count() > 35 {
1550                return Err(ValidationError::new(
1551                    1002,
1552                    "prtry exceeds the maximum length of 35".to_string(),
1553                ));
1554            }
1555        }
1556        Ok(())
1557    }
1558}
1559
1560// FinancialInstitutionCreditTransferV08 ...
1561#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1562pub struct FinancialInstitutionCreditTransferV08 {
1563    #[serde(rename = "GrpHdr")]
1564    pub grp_hdr: GroupHeader93,
1565    #[serde(rename = "CdtTrfTxInf")]
1566    pub cdt_trf_tx_inf: Vec<CreditTransferTransaction36>,
1567    #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
1568    pub splmtry_data: Option<Vec<SupplementaryData1>>,
1569}
1570
1571impl FinancialInstitutionCreditTransferV08 {
1572    pub fn validate(&self) -> Result<(), ValidationError> {
1573        self.grp_hdr.validate()?;
1574        for item in &self.cdt_trf_tx_inf {
1575            item.validate()?
1576        }
1577        if let Some(ref vec) = self.splmtry_data {
1578            for item in vec {
1579                item.validate()?
1580            }
1581        }
1582        Ok(())
1583    }
1584}
1585
1586// FinancialInstitutionIdentification18 ...
1587#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1588pub struct FinancialInstitutionIdentification18 {
1589    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1590    pub bicfi: Option<String>,
1591    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1592    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification2>,
1593    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1594    pub lei: Option<String>,
1595    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1596    pub nm: Option<String>,
1597    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1598    pub pstl_adr: Option<PostalAddress24>,
1599    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1600    pub othr: Option<GenericFinancialIdentification1>,
1601}
1602
1603impl FinancialInstitutionIdentification18 {
1604    pub fn validate(&self) -> Result<(), ValidationError> {
1605        if let Some(ref val) = self.bicfi {
1606            let pattern =
1607                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1608            if !pattern.is_match(val) {
1609                return Err(ValidationError::new(
1610                    1005,
1611                    "bicfi does not match the required pattern".to_string(),
1612                ));
1613            }
1614        }
1615        if let Some(ref val) = self.clr_sys_mmb_id {
1616            val.validate()?
1617        }
1618        if let Some(ref val) = self.lei {
1619            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1620            if !pattern.is_match(val) {
1621                return Err(ValidationError::new(
1622                    1005,
1623                    "lei does not match the required pattern".to_string(),
1624                ));
1625            }
1626        }
1627        if let Some(ref val) = self.nm {
1628            if val.chars().count() < 1 {
1629                return Err(ValidationError::new(
1630                    1001,
1631                    "nm is shorter than the minimum length of 1".to_string(),
1632                ));
1633            }
1634            if val.chars().count() > 140 {
1635                return Err(ValidationError::new(
1636                    1002,
1637                    "nm exceeds the maximum length of 140".to_string(),
1638                ));
1639            }
1640        }
1641        if let Some(ref val) = self.pstl_adr {
1642            val.validate()?
1643        }
1644        if let Some(ref val) = self.othr {
1645            val.validate()?
1646        }
1647        Ok(())
1648    }
1649}
1650
1651// Garnishment3 ...
1652#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1653pub struct Garnishment3 {
1654    #[serde(rename = "Tp")]
1655    pub tp: GarnishmentType1,
1656    #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
1657    pub grnshee: Option<PartyIdentification135>,
1658    #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
1659    pub grnshmt_admstr: Option<PartyIdentification135>,
1660    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
1661    pub ref_nb: Option<String>,
1662    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
1663    pub dt: Option<String>,
1664    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
1665    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1666    #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
1667    pub fmly_mdcl_insrnc_ind: Option<bool>,
1668    #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
1669    pub mplyee_termntn_ind: Option<bool>,
1670}
1671
1672impl Garnishment3 {
1673    pub fn validate(&self) -> Result<(), ValidationError> {
1674        self.tp.validate()?;
1675        if let Some(ref val) = self.grnshee {
1676            val.validate()?
1677        }
1678        if let Some(ref val) = self.grnshmt_admstr {
1679            val.validate()?
1680        }
1681        if let Some(ref val) = self.ref_nb {
1682            if val.chars().count() < 1 {
1683                return Err(ValidationError::new(
1684                    1001,
1685                    "ref_nb is shorter than the minimum length of 1".to_string(),
1686                ));
1687            }
1688            if val.chars().count() > 140 {
1689                return Err(ValidationError::new(
1690                    1002,
1691                    "ref_nb exceeds the maximum length of 140".to_string(),
1692                ));
1693            }
1694        }
1695        if let Some(ref val) = self.rmtd_amt {
1696            val.validate()?
1697        }
1698        Ok(())
1699    }
1700}
1701
1702// GarnishmentType1 ...
1703#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1704pub struct GarnishmentType1 {
1705    #[serde(rename = "CdOrPrtry")]
1706    pub cd_or_prtry: GarnishmentType1Choice,
1707    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1708    pub issr: Option<String>,
1709}
1710
1711impl GarnishmentType1 {
1712    pub fn validate(&self) -> Result<(), ValidationError> {
1713        self.cd_or_prtry.validate()?;
1714        if let Some(ref val) = self.issr {
1715            if val.chars().count() < 1 {
1716                return Err(ValidationError::new(
1717                    1001,
1718                    "issr is shorter than the minimum length of 1".to_string(),
1719                ));
1720            }
1721            if val.chars().count() > 35 {
1722                return Err(ValidationError::new(
1723                    1002,
1724                    "issr exceeds the maximum length of 35".to_string(),
1725                ));
1726            }
1727        }
1728        Ok(())
1729    }
1730}
1731
1732// GarnishmentType1Choice ...
1733#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1734pub struct GarnishmentType1Choice {
1735    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1736    pub cd: Option<String>,
1737    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1738    pub prtry: Option<String>,
1739}
1740
1741impl GarnishmentType1Choice {
1742    pub fn validate(&self) -> Result<(), ValidationError> {
1743        if let Some(ref val) = self.cd {
1744            if val.chars().count() < 1 {
1745                return Err(ValidationError::new(
1746                    1001,
1747                    "cd is shorter than the minimum length of 1".to_string(),
1748                ));
1749            }
1750            if val.chars().count() > 4 {
1751                return Err(ValidationError::new(
1752                    1002,
1753                    "cd exceeds the maximum length of 4".to_string(),
1754                ));
1755            }
1756        }
1757        if let Some(ref val) = self.prtry {
1758            if val.chars().count() < 1 {
1759                return Err(ValidationError::new(
1760                    1001,
1761                    "prtry is shorter than the minimum length of 1".to_string(),
1762                ));
1763            }
1764            if val.chars().count() > 35 {
1765                return Err(ValidationError::new(
1766                    1002,
1767                    "prtry exceeds the maximum length of 35".to_string(),
1768                ));
1769            }
1770        }
1771        Ok(())
1772    }
1773}
1774
1775// GenericAccountIdentification1 ...
1776#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1777pub struct GenericAccountIdentification1 {
1778    #[serde(rename = "Id")]
1779    pub id: String,
1780    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1781    pub schme_nm: Option<AccountSchemeName1Choice>,
1782    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1783    pub issr: Option<String>,
1784}
1785
1786impl GenericAccountIdentification1 {
1787    pub fn validate(&self) -> Result<(), ValidationError> {
1788        if self.id.chars().count() < 1 {
1789            return Err(ValidationError::new(
1790                1001,
1791                "id is shorter than the minimum length of 1".to_string(),
1792            ));
1793        }
1794        if self.id.chars().count() > 34 {
1795            return Err(ValidationError::new(
1796                1002,
1797                "id exceeds the maximum length of 34".to_string(),
1798            ));
1799        }
1800        if let Some(ref val) = self.schme_nm {
1801            val.validate()?
1802        }
1803        if let Some(ref val) = self.issr {
1804            if val.chars().count() < 1 {
1805                return Err(ValidationError::new(
1806                    1001,
1807                    "issr is shorter than the minimum length of 1".to_string(),
1808                ));
1809            }
1810            if val.chars().count() > 35 {
1811                return Err(ValidationError::new(
1812                    1002,
1813                    "issr exceeds the maximum length of 35".to_string(),
1814                ));
1815            }
1816        }
1817        Ok(())
1818    }
1819}
1820
1821// GenericFinancialIdentification1 ...
1822#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1823pub struct GenericFinancialIdentification1 {
1824    #[serde(rename = "Id")]
1825    pub id: String,
1826    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1827    pub schme_nm: Option<FinancialIdentificationSchemeName1Choice>,
1828    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1829    pub issr: Option<String>,
1830}
1831
1832impl GenericFinancialIdentification1 {
1833    pub fn validate(&self) -> Result<(), ValidationError> {
1834        if self.id.chars().count() < 1 {
1835            return Err(ValidationError::new(
1836                1001,
1837                "id is shorter than the minimum length of 1".to_string(),
1838            ));
1839        }
1840        if self.id.chars().count() > 35 {
1841            return Err(ValidationError::new(
1842                1002,
1843                "id exceeds the maximum length of 35".to_string(),
1844            ));
1845        }
1846        if let Some(ref val) = self.schme_nm {
1847            val.validate()?
1848        }
1849        if let Some(ref val) = self.issr {
1850            if val.chars().count() < 1 {
1851                return Err(ValidationError::new(
1852                    1001,
1853                    "issr is shorter than the minimum length of 1".to_string(),
1854                ));
1855            }
1856            if val.chars().count() > 35 {
1857                return Err(ValidationError::new(
1858                    1002,
1859                    "issr exceeds the maximum length of 35".to_string(),
1860                ));
1861            }
1862        }
1863        Ok(())
1864    }
1865}
1866
1867// GenericIdentification30 ...
1868#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1869pub struct GenericIdentification30 {
1870    #[serde(rename = "Id")]
1871    pub id: String,
1872    #[serde(rename = "Issr")]
1873    pub issr: String,
1874    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1875    pub schme_nm: Option<String>,
1876}
1877
1878impl GenericIdentification30 {
1879    pub fn validate(&self) -> Result<(), ValidationError> {
1880        let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
1881        if !pattern.is_match(&self.id) {
1882            return Err(ValidationError::new(
1883                1005,
1884                "id does not match the required pattern".to_string(),
1885            ));
1886        }
1887        if self.issr.chars().count() < 1 {
1888            return Err(ValidationError::new(
1889                1001,
1890                "issr is shorter than the minimum length of 1".to_string(),
1891            ));
1892        }
1893        if self.issr.chars().count() > 35 {
1894            return Err(ValidationError::new(
1895                1002,
1896                "issr exceeds the maximum length of 35".to_string(),
1897            ));
1898        }
1899        if let Some(ref val) = self.schme_nm {
1900            if val.chars().count() < 1 {
1901                return Err(ValidationError::new(
1902                    1001,
1903                    "schme_nm is shorter than the minimum length of 1".to_string(),
1904                ));
1905            }
1906            if val.chars().count() > 35 {
1907                return Err(ValidationError::new(
1908                    1002,
1909                    "schme_nm exceeds the maximum length of 35".to_string(),
1910                ));
1911            }
1912        }
1913        Ok(())
1914    }
1915}
1916
1917// GenericOrganisationIdentification1 ...
1918#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1919pub struct GenericOrganisationIdentification1 {
1920    #[serde(rename = "Id")]
1921    pub id: String,
1922    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1923    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
1924    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1925    pub issr: Option<String>,
1926}
1927
1928impl GenericOrganisationIdentification1 {
1929    pub fn validate(&self) -> Result<(), ValidationError> {
1930        if self.id.chars().count() < 1 {
1931            return Err(ValidationError::new(
1932                1001,
1933                "id is shorter than the minimum length of 1".to_string(),
1934            ));
1935        }
1936        if self.id.chars().count() > 35 {
1937            return Err(ValidationError::new(
1938                1002,
1939                "id exceeds the maximum length of 35".to_string(),
1940            ));
1941        }
1942        if let Some(ref val) = self.schme_nm {
1943            val.validate()?
1944        }
1945        if let Some(ref val) = self.issr {
1946            if val.chars().count() < 1 {
1947                return Err(ValidationError::new(
1948                    1001,
1949                    "issr is shorter than the minimum length of 1".to_string(),
1950                ));
1951            }
1952            if val.chars().count() > 35 {
1953                return Err(ValidationError::new(
1954                    1002,
1955                    "issr exceeds the maximum length of 35".to_string(),
1956                ));
1957            }
1958        }
1959        Ok(())
1960    }
1961}
1962
1963// GenericPersonIdentification1 ...
1964#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1965pub struct GenericPersonIdentification1 {
1966    #[serde(rename = "Id")]
1967    pub id: String,
1968    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1969    pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
1970    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1971    pub issr: Option<String>,
1972}
1973
1974impl GenericPersonIdentification1 {
1975    pub fn validate(&self) -> Result<(), ValidationError> {
1976        if self.id.chars().count() < 1 {
1977            return Err(ValidationError::new(
1978                1001,
1979                "id is shorter than the minimum length of 1".to_string(),
1980            ));
1981        }
1982        if self.id.chars().count() > 35 {
1983            return Err(ValidationError::new(
1984                1002,
1985                "id exceeds the maximum length of 35".to_string(),
1986            ));
1987        }
1988        if let Some(ref val) = self.schme_nm {
1989            val.validate()?
1990        }
1991        if let Some(ref val) = self.issr {
1992            if val.chars().count() < 1 {
1993                return Err(ValidationError::new(
1994                    1001,
1995                    "issr is shorter than the minimum length of 1".to_string(),
1996                ));
1997            }
1998            if val.chars().count() > 35 {
1999                return Err(ValidationError::new(
2000                    1002,
2001                    "issr exceeds the maximum length of 35".to_string(),
2002                ));
2003            }
2004        }
2005        Ok(())
2006    }
2007}
2008
2009// GroupHeader93 ...
2010#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2011pub struct GroupHeader93 {
2012    #[serde(rename = "MsgId")]
2013    pub msg_id: String,
2014    #[serde(rename = "CreDtTm")]
2015    pub cre_dt_tm: String,
2016    #[serde(rename = "BtchBookg", skip_serializing_if = "Option::is_none")]
2017    pub btch_bookg: Option<bool>,
2018    #[serde(rename = "NbOfTxs")]
2019    pub nb_of_txs: String,
2020    #[serde(rename = "CtrlSum", skip_serializing_if = "Option::is_none")]
2021    pub ctrl_sum: Option<f64>,
2022    #[serde(rename = "TtlIntrBkSttlmAmt", skip_serializing_if = "Option::is_none")]
2023    pub ttl_intr_bk_sttlm_amt: Option<ActiveCurrencyAndAmount>,
2024    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
2025    pub intr_bk_sttlm_dt: Option<String>,
2026    #[serde(rename = "SttlmInf")]
2027    pub sttlm_inf: SettlementInstruction7,
2028    #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
2029    pub pmt_tp_inf: Option<PaymentTypeInformation28>,
2030    #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
2031    pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
2032    #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
2033    pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
2034}
2035
2036impl GroupHeader93 {
2037    pub fn validate(&self) -> Result<(), ValidationError> {
2038        if self.msg_id.chars().count() < 1 {
2039            return Err(ValidationError::new(
2040                1001,
2041                "msg_id is shorter than the minimum length of 1".to_string(),
2042            ));
2043        }
2044        if self.msg_id.chars().count() > 35 {
2045            return Err(ValidationError::new(
2046                1002,
2047                "msg_id exceeds the maximum length of 35".to_string(),
2048            ));
2049        }
2050        let pattern = Regex::new("[0-9]{1,15}").unwrap();
2051        if !pattern.is_match(&self.nb_of_txs) {
2052            return Err(ValidationError::new(
2053                1005,
2054                "nb_of_txs does not match the required pattern".to_string(),
2055            ));
2056        }
2057        if let Some(ref val) = self.ttl_intr_bk_sttlm_amt {
2058            val.validate()?
2059        }
2060        self.sttlm_inf.validate()?;
2061        if let Some(ref val) = self.pmt_tp_inf {
2062            val.validate()?
2063        }
2064        if let Some(ref val) = self.instg_agt {
2065            val.validate()?
2066        }
2067        if let Some(ref val) = self.instd_agt {
2068            val.validate()?
2069        }
2070        Ok(())
2071    }
2072}
2073
2074// Instruction3Code ...
2075#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2076pub enum Instruction3Code {
2077    #[default]
2078    #[serde(rename = "CHQB")]
2079    CodeCHQB,
2080    #[serde(rename = "HOLD")]
2081    CodeHOLD,
2082    #[serde(rename = "PHOB")]
2083    CodePHOB,
2084    #[serde(rename = "TELB")]
2085    CodeTELB,
2086}
2087
2088impl Instruction3Code {
2089    pub fn validate(&self) -> Result<(), ValidationError> {
2090        Ok(())
2091    }
2092}
2093
2094// Instruction4Code ...
2095#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2096pub enum Instruction4Code {
2097    #[default]
2098    #[serde(rename = "PHOA")]
2099    CodePHOA,
2100    #[serde(rename = "TELA")]
2101    CodeTELA,
2102}
2103
2104impl Instruction4Code {
2105    pub fn validate(&self) -> Result<(), ValidationError> {
2106        Ok(())
2107    }
2108}
2109
2110// Instruction5Code ...
2111#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2112pub enum Instruction5Code {
2113    #[default]
2114    #[serde(rename = "PHOB")]
2115    CodePHOB,
2116    #[serde(rename = "TELB")]
2117    CodeTELB,
2118}
2119
2120impl Instruction5Code {
2121    pub fn validate(&self) -> Result<(), ValidationError> {
2122        Ok(())
2123    }
2124}
2125
2126// InstructionForCreditorAgent1 ...
2127#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2128pub struct InstructionForCreditorAgent1 {
2129    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2130    pub cd: Option<Instruction3Code>,
2131    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2132    pub instr_inf: Option<String>,
2133}
2134
2135impl InstructionForCreditorAgent1 {
2136    pub fn validate(&self) -> Result<(), ValidationError> {
2137        if let Some(ref val) = self.cd {
2138            val.validate()?
2139        }
2140        if let Some(ref val) = self.instr_inf {
2141            if val.chars().count() < 1 {
2142                return Err(ValidationError::new(
2143                    1001,
2144                    "instr_inf is shorter than the minimum length of 1".to_string(),
2145                ));
2146            }
2147            if val.chars().count() > 140 {
2148                return Err(ValidationError::new(
2149                    1002,
2150                    "instr_inf exceeds the maximum length of 140".to_string(),
2151                ));
2152            }
2153        }
2154        Ok(())
2155    }
2156}
2157
2158// InstructionForCreditorAgent2 ...
2159#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2160pub struct InstructionForCreditorAgent2 {
2161    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2162    pub cd: Option<Instruction5Code>,
2163    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2164    pub instr_inf: Option<String>,
2165}
2166
2167impl InstructionForCreditorAgent2 {
2168    pub fn validate(&self) -> Result<(), ValidationError> {
2169        if let Some(ref val) = self.cd {
2170            val.validate()?
2171        }
2172        if let Some(ref val) = self.instr_inf {
2173            if val.chars().count() < 1 {
2174                return Err(ValidationError::new(
2175                    1001,
2176                    "instr_inf is shorter than the minimum length of 1".to_string(),
2177                ));
2178            }
2179            if val.chars().count() > 140 {
2180                return Err(ValidationError::new(
2181                    1002,
2182                    "instr_inf exceeds the maximum length of 140".to_string(),
2183                ));
2184            }
2185        }
2186        Ok(())
2187    }
2188}
2189
2190// InstructionForNextAgent1 ...
2191#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2192pub struct InstructionForNextAgent1 {
2193    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2194    pub cd: Option<Instruction4Code>,
2195    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2196    pub instr_inf: Option<String>,
2197}
2198
2199impl InstructionForNextAgent1 {
2200    pub fn validate(&self) -> Result<(), ValidationError> {
2201        if let Some(ref val) = self.cd {
2202            val.validate()?
2203        }
2204        if let Some(ref val) = self.instr_inf {
2205            if val.chars().count() < 1 {
2206                return Err(ValidationError::new(
2207                    1001,
2208                    "instr_inf is shorter than the minimum length of 1".to_string(),
2209                ));
2210            }
2211            if val.chars().count() > 140 {
2212                return Err(ValidationError::new(
2213                    1002,
2214                    "instr_inf exceeds the maximum length of 140".to_string(),
2215                ));
2216            }
2217        }
2218        Ok(())
2219    }
2220}
2221
2222// LocalInstrument2Choice ...
2223#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2224pub struct LocalInstrument2Choice {
2225    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2226    pub cd: Option<String>,
2227    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2228    pub prtry: Option<String>,
2229}
2230
2231impl LocalInstrument2Choice {
2232    pub fn validate(&self) -> Result<(), ValidationError> {
2233        if let Some(ref val) = self.cd {
2234            if val.chars().count() < 1 {
2235                return Err(ValidationError::new(
2236                    1001,
2237                    "cd is shorter than the minimum length of 1".to_string(),
2238                ));
2239            }
2240            if val.chars().count() > 35 {
2241                return Err(ValidationError::new(
2242                    1002,
2243                    "cd exceeds the maximum length of 35".to_string(),
2244                ));
2245            }
2246        }
2247        if let Some(ref val) = self.prtry {
2248            if val.chars().count() < 1 {
2249                return Err(ValidationError::new(
2250                    1001,
2251                    "prtry is shorter than the minimum length of 1".to_string(),
2252                ));
2253            }
2254            if val.chars().count() > 35 {
2255                return Err(ValidationError::new(
2256                    1002,
2257                    "prtry exceeds the maximum length of 35".to_string(),
2258                ));
2259            }
2260        }
2261        Ok(())
2262    }
2263}
2264
2265// NamePrefix2Code ...
2266#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2267pub enum NamePrefix2Code {
2268    #[default]
2269    #[serde(rename = "DOCT")]
2270    CodeDOCT,
2271    #[serde(rename = "MADM")]
2272    CodeMADM,
2273    #[serde(rename = "MISS")]
2274    CodeMISS,
2275    #[serde(rename = "MIST")]
2276    CodeMIST,
2277    #[serde(rename = "MIKS")]
2278    CodeMIKS,
2279}
2280
2281impl NamePrefix2Code {
2282    pub fn validate(&self) -> Result<(), ValidationError> {
2283        Ok(())
2284    }
2285}
2286
2287// OrganisationIdentification29 ...
2288#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2289pub struct OrganisationIdentification29 {
2290    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2291    pub any_bic: Option<String>,
2292    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2293    pub lei: Option<String>,
2294    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2295    pub othr: Option<Vec<GenericOrganisationIdentification1>>,
2296}
2297
2298impl OrganisationIdentification29 {
2299    pub fn validate(&self) -> Result<(), ValidationError> {
2300        if let Some(ref val) = self.any_bic {
2301            let pattern =
2302                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2303            if !pattern.is_match(val) {
2304                return Err(ValidationError::new(
2305                    1005,
2306                    "any_bic does not match the required pattern".to_string(),
2307                ));
2308            }
2309        }
2310        if let Some(ref val) = self.lei {
2311            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2312            if !pattern.is_match(val) {
2313                return Err(ValidationError::new(
2314                    1005,
2315                    "lei does not match the required pattern".to_string(),
2316                ));
2317            }
2318        }
2319        if let Some(ref vec) = self.othr {
2320            for item in vec {
2321                item.validate()?
2322            }
2323        }
2324        Ok(())
2325    }
2326}
2327
2328// OrganisationIdentificationSchemeName1Choice ...
2329#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2330pub struct OrganisationIdentificationSchemeName1Choice {
2331    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2332    pub cd: Option<String>,
2333    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2334    pub prtry: Option<String>,
2335}
2336
2337impl OrganisationIdentificationSchemeName1Choice {
2338    pub fn validate(&self) -> Result<(), ValidationError> {
2339        if let Some(ref val) = self.cd {
2340            if val.chars().count() < 1 {
2341                return Err(ValidationError::new(
2342                    1001,
2343                    "cd is shorter than the minimum length of 1".to_string(),
2344                ));
2345            }
2346            if val.chars().count() > 4 {
2347                return Err(ValidationError::new(
2348                    1002,
2349                    "cd exceeds the maximum length of 4".to_string(),
2350                ));
2351            }
2352        }
2353        if let Some(ref val) = self.prtry {
2354            if val.chars().count() < 1 {
2355                return Err(ValidationError::new(
2356                    1001,
2357                    "prtry is shorter than the minimum length of 1".to_string(),
2358                ));
2359            }
2360            if val.chars().count() > 35 {
2361                return Err(ValidationError::new(
2362                    1002,
2363                    "prtry exceeds the maximum length of 35".to_string(),
2364                ));
2365            }
2366        }
2367        Ok(())
2368    }
2369}
2370
2371// OtherContact1 ...
2372#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2373pub struct OtherContact1 {
2374    #[serde(rename = "ChanlTp")]
2375    pub chanl_tp: String,
2376    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2377    pub id: Option<String>,
2378}
2379
2380impl OtherContact1 {
2381    pub fn validate(&self) -> Result<(), ValidationError> {
2382        if self.chanl_tp.chars().count() < 1 {
2383            return Err(ValidationError::new(
2384                1001,
2385                "chanl_tp is shorter than the minimum length of 1".to_string(),
2386            ));
2387        }
2388        if self.chanl_tp.chars().count() > 4 {
2389            return Err(ValidationError::new(
2390                1002,
2391                "chanl_tp exceeds the maximum length of 4".to_string(),
2392            ));
2393        }
2394        if let Some(ref val) = self.id {
2395            if val.chars().count() < 1 {
2396                return Err(ValidationError::new(
2397                    1001,
2398                    "id is shorter than the minimum length of 1".to_string(),
2399                ));
2400            }
2401            if val.chars().count() > 128 {
2402                return Err(ValidationError::new(
2403                    1002,
2404                    "id exceeds the maximum length of 128".to_string(),
2405                ));
2406            }
2407        }
2408        Ok(())
2409    }
2410}
2411
2412// Party38Choice ...
2413#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2414pub struct Party38Choice {
2415    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2416    pub org_id: Option<OrganisationIdentification29>,
2417    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2418    pub prvt_id: Option<PersonIdentification13>,
2419}
2420
2421impl Party38Choice {
2422    pub fn validate(&self) -> Result<(), ValidationError> {
2423        if let Some(ref val) = self.org_id {
2424            val.validate()?
2425        }
2426        if let Some(ref val) = self.prvt_id {
2427            val.validate()?
2428        }
2429        Ok(())
2430    }
2431}
2432
2433// PartyIdentification135 ...
2434#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2435pub struct PartyIdentification135 {
2436    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2437    pub nm: Option<String>,
2438    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2439    pub pstl_adr: Option<PostalAddress24>,
2440    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2441    pub id: Option<Party38Choice>,
2442    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2443    pub ctry_of_res: Option<String>,
2444    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
2445    pub ctct_dtls: Option<Contact4>,
2446}
2447
2448impl PartyIdentification135 {
2449    pub fn validate(&self) -> Result<(), ValidationError> {
2450        if let Some(ref val) = self.nm {
2451            if val.chars().count() < 1 {
2452                return Err(ValidationError::new(
2453                    1001,
2454                    "nm is shorter than the minimum length of 1".to_string(),
2455                ));
2456            }
2457            if val.chars().count() > 140 {
2458                return Err(ValidationError::new(
2459                    1002,
2460                    "nm exceeds the maximum length of 140".to_string(),
2461                ));
2462            }
2463        }
2464        if let Some(ref val) = self.pstl_adr {
2465            val.validate()?
2466        }
2467        if let Some(ref val) = self.id {
2468            val.validate()?
2469        }
2470        if let Some(ref val) = self.ctry_of_res {
2471            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2472            if !pattern.is_match(val) {
2473                return Err(ValidationError::new(
2474                    1005,
2475                    "ctry_of_res does not match the required pattern".to_string(),
2476                ));
2477            }
2478        }
2479        if let Some(ref val) = self.ctct_dtls {
2480            val.validate()?
2481        }
2482        Ok(())
2483    }
2484}
2485
2486// PaymentIdentification7 ...
2487#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2488pub struct PaymentIdentification7 {
2489    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
2490    pub instr_id: Option<String>,
2491    #[serde(rename = "EndToEndId")]
2492    pub end_to_end_id: String,
2493    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
2494    pub tx_id: Option<String>,
2495    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
2496    pub uetr: Option<String>,
2497    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
2498    pub clr_sys_ref: Option<String>,
2499}
2500
2501impl PaymentIdentification7 {
2502    pub fn validate(&self) -> Result<(), ValidationError> {
2503        if let Some(ref val) = self.instr_id {
2504            if val.chars().count() < 1 {
2505                return Err(ValidationError::new(
2506                    1001,
2507                    "instr_id is shorter than the minimum length of 1".to_string(),
2508                ));
2509            }
2510            if val.chars().count() > 35 {
2511                return Err(ValidationError::new(
2512                    1002,
2513                    "instr_id exceeds the maximum length of 35".to_string(),
2514                ));
2515            }
2516        }
2517        if self.end_to_end_id.chars().count() < 1 {
2518            return Err(ValidationError::new(
2519                1001,
2520                "end_to_end_id is shorter than the minimum length of 1".to_string(),
2521            ));
2522        }
2523        if self.end_to_end_id.chars().count() > 35 {
2524            return Err(ValidationError::new(
2525                1002,
2526                "end_to_end_id exceeds the maximum length of 35".to_string(),
2527            ));
2528        }
2529        if let Some(ref val) = self.tx_id {
2530            if val.chars().count() < 1 {
2531                return Err(ValidationError::new(
2532                    1001,
2533                    "tx_id is shorter than the minimum length of 1".to_string(),
2534                ));
2535            }
2536            if val.chars().count() > 35 {
2537                return Err(ValidationError::new(
2538                    1002,
2539                    "tx_id exceeds the maximum length of 35".to_string(),
2540                ));
2541            }
2542        }
2543        if let Some(ref val) = self.uetr {
2544            let pattern =
2545                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
2546                    .unwrap();
2547            if !pattern.is_match(val) {
2548                return Err(ValidationError::new(
2549                    1005,
2550                    "uetr does not match the required pattern".to_string(),
2551                ));
2552            }
2553        }
2554        if let Some(ref val) = self.clr_sys_ref {
2555            if val.chars().count() < 1 {
2556                return Err(ValidationError::new(
2557                    1001,
2558                    "clr_sys_ref is shorter than the minimum length of 1".to_string(),
2559                ));
2560            }
2561            if val.chars().count() > 35 {
2562                return Err(ValidationError::new(
2563                    1002,
2564                    "clr_sys_ref exceeds the maximum length of 35".to_string(),
2565                ));
2566            }
2567        }
2568        Ok(())
2569    }
2570}
2571
2572// PaymentTypeInformation28 ...
2573#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2574pub struct PaymentTypeInformation28 {
2575    #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
2576    pub instr_prty: Option<Priority2Code>,
2577    #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
2578    pub clr_chanl: Option<ClearingChannel2Code>,
2579    #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
2580    pub svc_lvl: Option<Vec<ServiceLevel8Choice>>,
2581    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2582    pub lcl_instrm: Option<LocalInstrument2Choice>,
2583    #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
2584    pub ctgy_purp: Option<CategoryPurpose1Choice>,
2585}
2586
2587impl PaymentTypeInformation28 {
2588    pub fn validate(&self) -> Result<(), ValidationError> {
2589        if let Some(ref val) = self.instr_prty {
2590            val.validate()?
2591        }
2592        if let Some(ref val) = self.clr_chanl {
2593            val.validate()?
2594        }
2595        if let Some(ref vec) = self.svc_lvl {
2596            for item in vec {
2597                item.validate()?
2598            }
2599        }
2600        if let Some(ref val) = self.lcl_instrm {
2601            val.validate()?
2602        }
2603        if let Some(ref val) = self.ctgy_purp {
2604            val.validate()?
2605        }
2606        Ok(())
2607    }
2608}
2609
2610// PersonIdentification13 ...
2611#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2612pub struct PersonIdentification13 {
2613    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
2614    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
2615    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2616    pub othr: Option<Vec<GenericPersonIdentification1>>,
2617}
2618
2619impl PersonIdentification13 {
2620    pub fn validate(&self) -> Result<(), ValidationError> {
2621        if let Some(ref val) = self.dt_and_plc_of_birth {
2622            val.validate()?
2623        }
2624        if let Some(ref vec) = self.othr {
2625            for item in vec {
2626                item.validate()?
2627            }
2628        }
2629        Ok(())
2630    }
2631}
2632
2633// PersonIdentificationSchemeName1Choice ...
2634#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2635pub struct PersonIdentificationSchemeName1Choice {
2636    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2637    pub cd: Option<String>,
2638    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2639    pub prtry: Option<String>,
2640}
2641
2642impl PersonIdentificationSchemeName1Choice {
2643    pub fn validate(&self) -> Result<(), ValidationError> {
2644        if let Some(ref val) = self.cd {
2645            if val.chars().count() < 1 {
2646                return Err(ValidationError::new(
2647                    1001,
2648                    "cd is shorter than the minimum length of 1".to_string(),
2649                ));
2650            }
2651            if val.chars().count() > 4 {
2652                return Err(ValidationError::new(
2653                    1002,
2654                    "cd exceeds the maximum length of 4".to_string(),
2655                ));
2656            }
2657        }
2658        if let Some(ref val) = self.prtry {
2659            if val.chars().count() < 1 {
2660                return Err(ValidationError::new(
2661                    1001,
2662                    "prtry is shorter than the minimum length of 1".to_string(),
2663                ));
2664            }
2665            if val.chars().count() > 35 {
2666                return Err(ValidationError::new(
2667                    1002,
2668                    "prtry exceeds the maximum length of 35".to_string(),
2669                ));
2670            }
2671        }
2672        Ok(())
2673    }
2674}
2675
2676// PostalAddress24 ...
2677#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2678pub struct PostalAddress24 {
2679    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
2680    pub adr_tp: Option<AddressType3Choice>,
2681    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
2682    pub dept: Option<String>,
2683    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
2684    pub sub_dept: Option<String>,
2685    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
2686    pub strt_nm: Option<String>,
2687    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
2688    pub bldg_nb: Option<String>,
2689    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
2690    pub bldg_nm: Option<String>,
2691    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
2692    pub flr: Option<String>,
2693    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
2694    pub pst_bx: Option<String>,
2695    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
2696    pub room: Option<String>,
2697    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
2698    pub pst_cd: Option<String>,
2699    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
2700    pub twn_nm: Option<String>,
2701    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
2702    pub twn_lctn_nm: Option<String>,
2703    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
2704    pub dstrct_nm: Option<String>,
2705    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
2706    pub ctry_sub_dvsn: Option<String>,
2707    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
2708    pub ctry: Option<String>,
2709    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
2710    pub adr_line: Option<Vec<String>>,
2711}
2712
2713impl PostalAddress24 {
2714    pub fn validate(&self) -> Result<(), ValidationError> {
2715        if let Some(ref val) = self.adr_tp {
2716            val.validate()?
2717        }
2718        if let Some(ref val) = self.dept {
2719            if val.chars().count() < 1 {
2720                return Err(ValidationError::new(
2721                    1001,
2722                    "dept is shorter than the minimum length of 1".to_string(),
2723                ));
2724            }
2725            if val.chars().count() > 70 {
2726                return Err(ValidationError::new(
2727                    1002,
2728                    "dept exceeds the maximum length of 70".to_string(),
2729                ));
2730            }
2731        }
2732        if let Some(ref val) = self.sub_dept {
2733            if val.chars().count() < 1 {
2734                return Err(ValidationError::new(
2735                    1001,
2736                    "sub_dept is shorter than the minimum length of 1".to_string(),
2737                ));
2738            }
2739            if val.chars().count() > 70 {
2740                return Err(ValidationError::new(
2741                    1002,
2742                    "sub_dept exceeds the maximum length of 70".to_string(),
2743                ));
2744            }
2745        }
2746        if let Some(ref val) = self.strt_nm {
2747            if val.chars().count() < 1 {
2748                return Err(ValidationError::new(
2749                    1001,
2750                    "strt_nm is shorter than the minimum length of 1".to_string(),
2751                ));
2752            }
2753            if val.chars().count() > 70 {
2754                return Err(ValidationError::new(
2755                    1002,
2756                    "strt_nm exceeds the maximum length of 70".to_string(),
2757                ));
2758            }
2759        }
2760        if let Some(ref val) = self.bldg_nb {
2761            if val.chars().count() < 1 {
2762                return Err(ValidationError::new(
2763                    1001,
2764                    "bldg_nb is shorter than the minimum length of 1".to_string(),
2765                ));
2766            }
2767            if val.chars().count() > 16 {
2768                return Err(ValidationError::new(
2769                    1002,
2770                    "bldg_nb exceeds the maximum length of 16".to_string(),
2771                ));
2772            }
2773        }
2774        if let Some(ref val) = self.bldg_nm {
2775            if val.chars().count() < 1 {
2776                return Err(ValidationError::new(
2777                    1001,
2778                    "bldg_nm is shorter than the minimum length of 1".to_string(),
2779                ));
2780            }
2781            if val.chars().count() > 35 {
2782                return Err(ValidationError::new(
2783                    1002,
2784                    "bldg_nm exceeds the maximum length of 35".to_string(),
2785                ));
2786            }
2787        }
2788        if let Some(ref val) = self.flr {
2789            if val.chars().count() < 1 {
2790                return Err(ValidationError::new(
2791                    1001,
2792                    "flr is shorter than the minimum length of 1".to_string(),
2793                ));
2794            }
2795            if val.chars().count() > 70 {
2796                return Err(ValidationError::new(
2797                    1002,
2798                    "flr exceeds the maximum length of 70".to_string(),
2799                ));
2800            }
2801        }
2802        if let Some(ref val) = self.pst_bx {
2803            if val.chars().count() < 1 {
2804                return Err(ValidationError::new(
2805                    1001,
2806                    "pst_bx is shorter than the minimum length of 1".to_string(),
2807                ));
2808            }
2809            if val.chars().count() > 16 {
2810                return Err(ValidationError::new(
2811                    1002,
2812                    "pst_bx exceeds the maximum length of 16".to_string(),
2813                ));
2814            }
2815        }
2816        if let Some(ref val) = self.room {
2817            if val.chars().count() < 1 {
2818                return Err(ValidationError::new(
2819                    1001,
2820                    "room is shorter than the minimum length of 1".to_string(),
2821                ));
2822            }
2823            if val.chars().count() > 70 {
2824                return Err(ValidationError::new(
2825                    1002,
2826                    "room exceeds the maximum length of 70".to_string(),
2827                ));
2828            }
2829        }
2830        if let Some(ref val) = self.pst_cd {
2831            if val.chars().count() < 1 {
2832                return Err(ValidationError::new(
2833                    1001,
2834                    "pst_cd is shorter than the minimum length of 1".to_string(),
2835                ));
2836            }
2837            if val.chars().count() > 16 {
2838                return Err(ValidationError::new(
2839                    1002,
2840                    "pst_cd exceeds the maximum length of 16".to_string(),
2841                ));
2842            }
2843        }
2844        if let Some(ref val) = self.twn_nm {
2845            if val.chars().count() < 1 {
2846                return Err(ValidationError::new(
2847                    1001,
2848                    "twn_nm is shorter than the minimum length of 1".to_string(),
2849                ));
2850            }
2851            if val.chars().count() > 35 {
2852                return Err(ValidationError::new(
2853                    1002,
2854                    "twn_nm exceeds the maximum length of 35".to_string(),
2855                ));
2856            }
2857        }
2858        if let Some(ref val) = self.twn_lctn_nm {
2859            if val.chars().count() < 1 {
2860                return Err(ValidationError::new(
2861                    1001,
2862                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
2863                ));
2864            }
2865            if val.chars().count() > 35 {
2866                return Err(ValidationError::new(
2867                    1002,
2868                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
2869                ));
2870            }
2871        }
2872        if let Some(ref val) = self.dstrct_nm {
2873            if val.chars().count() < 1 {
2874                return Err(ValidationError::new(
2875                    1001,
2876                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
2877                ));
2878            }
2879            if val.chars().count() > 35 {
2880                return Err(ValidationError::new(
2881                    1002,
2882                    "dstrct_nm exceeds the maximum length of 35".to_string(),
2883                ));
2884            }
2885        }
2886        if let Some(ref val) = self.ctry_sub_dvsn {
2887            if val.chars().count() < 1 {
2888                return Err(ValidationError::new(
2889                    1001,
2890                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
2891                ));
2892            }
2893            if val.chars().count() > 35 {
2894                return Err(ValidationError::new(
2895                    1002,
2896                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
2897                ));
2898            }
2899        }
2900        if let Some(ref val) = self.ctry {
2901            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2902            if !pattern.is_match(val) {
2903                return Err(ValidationError::new(
2904                    1005,
2905                    "ctry does not match the required pattern".to_string(),
2906                ));
2907            }
2908        }
2909        if let Some(ref vec) = self.adr_line {
2910            for item in vec {
2911                if item.chars().count() < 1 {
2912                    return Err(ValidationError::new(
2913                        1001,
2914                        "adr_line is shorter than the minimum length of 1".to_string(),
2915                    ));
2916                }
2917                if item.chars().count() > 70 {
2918                    return Err(ValidationError::new(
2919                        1002,
2920                        "adr_line exceeds the maximum length of 70".to_string(),
2921                    ));
2922                }
2923            }
2924        }
2925        Ok(())
2926    }
2927}
2928
2929// PreferredContactMethod1Code ...
2930#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2931pub enum PreferredContactMethod1Code {
2932    #[default]
2933    #[serde(rename = "LETT")]
2934    CodeLETT,
2935    #[serde(rename = "MAIL")]
2936    CodeMAIL,
2937    #[serde(rename = "PHON")]
2938    CodePHON,
2939    #[serde(rename = "FAXX")]
2940    CodeFAXX,
2941    #[serde(rename = "CELL")]
2942    CodeCELL,
2943}
2944
2945impl PreferredContactMethod1Code {
2946    pub fn validate(&self) -> Result<(), ValidationError> {
2947        Ok(())
2948    }
2949}
2950
2951// Priority2Code ...
2952#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2953pub enum Priority2Code {
2954    #[default]
2955    #[serde(rename = "HIGH")]
2956    CodeHIGH,
2957    #[serde(rename = "NORM")]
2958    CodeNORM,
2959}
2960
2961impl Priority2Code {
2962    pub fn validate(&self) -> Result<(), ValidationError> {
2963        Ok(())
2964    }
2965}
2966
2967// Priority3Code ...
2968#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2969pub enum Priority3Code {
2970    #[default]
2971    #[serde(rename = "URGT")]
2972    CodeURGT,
2973    #[serde(rename = "HIGH")]
2974    CodeHIGH,
2975    #[serde(rename = "NORM")]
2976    CodeNORM,
2977}
2978
2979impl Priority3Code {
2980    pub fn validate(&self) -> Result<(), ValidationError> {
2981        Ok(())
2982    }
2983}
2984
2985// ProxyAccountIdentification1 ...
2986#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2987pub struct ProxyAccountIdentification1 {
2988    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2989    pub tp: Option<ProxyAccountType1Choice>,
2990    #[serde(rename = "Id")]
2991    pub id: String,
2992}
2993
2994impl ProxyAccountIdentification1 {
2995    pub fn validate(&self) -> Result<(), ValidationError> {
2996        if let Some(ref val) = self.tp {
2997            val.validate()?
2998        }
2999        if self.id.chars().count() < 1 {
3000            return Err(ValidationError::new(
3001                1001,
3002                "id is shorter than the minimum length of 1".to_string(),
3003            ));
3004        }
3005        if self.id.chars().count() > 2048 {
3006            return Err(ValidationError::new(
3007                1002,
3008                "id exceeds the maximum length of 2048".to_string(),
3009            ));
3010        }
3011        Ok(())
3012    }
3013}
3014
3015// ProxyAccountType1Choice ...
3016#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3017pub struct ProxyAccountType1Choice {
3018    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3019    pub cd: Option<String>,
3020    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3021    pub prtry: Option<String>,
3022}
3023
3024impl ProxyAccountType1Choice {
3025    pub fn validate(&self) -> Result<(), ValidationError> {
3026        if let Some(ref val) = self.cd {
3027            if val.chars().count() < 1 {
3028                return Err(ValidationError::new(
3029                    1001,
3030                    "cd is shorter than the minimum length of 1".to_string(),
3031                ));
3032            }
3033            if val.chars().count() > 4 {
3034                return Err(ValidationError::new(
3035                    1002,
3036                    "cd exceeds the maximum length of 4".to_string(),
3037                ));
3038            }
3039        }
3040        if let Some(ref val) = self.prtry {
3041            if val.chars().count() < 1 {
3042                return Err(ValidationError::new(
3043                    1001,
3044                    "prtry is shorter than the minimum length of 1".to_string(),
3045                ));
3046            }
3047            if val.chars().count() > 35 {
3048                return Err(ValidationError::new(
3049                    1002,
3050                    "prtry exceeds the maximum length of 35".to_string(),
3051                ));
3052            }
3053        }
3054        Ok(())
3055    }
3056}
3057
3058// Purpose2Choice ...
3059#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3060pub struct Purpose2Choice {
3061    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3062    pub cd: Option<String>,
3063    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3064    pub prtry: Option<String>,
3065}
3066
3067impl Purpose2Choice {
3068    pub fn validate(&self) -> Result<(), ValidationError> {
3069        if let Some(ref val) = self.cd {
3070            if val.chars().count() < 1 {
3071                return Err(ValidationError::new(
3072                    1001,
3073                    "cd is shorter than the minimum length of 1".to_string(),
3074                ));
3075            }
3076            if val.chars().count() > 4 {
3077                return Err(ValidationError::new(
3078                    1002,
3079                    "cd exceeds the maximum length of 4".to_string(),
3080                ));
3081            }
3082        }
3083        if let Some(ref val) = self.prtry {
3084            if val.chars().count() < 1 {
3085                return Err(ValidationError::new(
3086                    1001,
3087                    "prtry is shorter than the minimum length of 1".to_string(),
3088                ));
3089            }
3090            if val.chars().count() > 35 {
3091                return Err(ValidationError::new(
3092                    1002,
3093                    "prtry exceeds the maximum length of 35".to_string(),
3094                ));
3095            }
3096        }
3097        Ok(())
3098    }
3099}
3100
3101// ReferredDocumentInformation7 ...
3102#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3103pub struct ReferredDocumentInformation7 {
3104    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3105    pub tp: Option<ReferredDocumentType4>,
3106    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
3107    pub nb: Option<String>,
3108    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
3109    pub rltd_dt: Option<String>,
3110    #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
3111    pub line_dtls: Option<Vec<DocumentLineInformation1>>,
3112}
3113
3114impl ReferredDocumentInformation7 {
3115    pub fn validate(&self) -> Result<(), ValidationError> {
3116        if let Some(ref val) = self.tp {
3117            val.validate()?
3118        }
3119        if let Some(ref val) = self.nb {
3120            if val.chars().count() < 1 {
3121                return Err(ValidationError::new(
3122                    1001,
3123                    "nb is shorter than the minimum length of 1".to_string(),
3124                ));
3125            }
3126            if val.chars().count() > 35 {
3127                return Err(ValidationError::new(
3128                    1002,
3129                    "nb exceeds the maximum length of 35".to_string(),
3130                ));
3131            }
3132        }
3133        if let Some(ref vec) = self.line_dtls {
3134            for item in vec {
3135                item.validate()?
3136            }
3137        }
3138        Ok(())
3139    }
3140}
3141
3142// ReferredDocumentType3Choice ...
3143#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3144pub struct ReferredDocumentType3Choice {
3145    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3146    pub cd: Option<DocumentType6Code>,
3147    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3148    pub prtry: Option<String>,
3149}
3150
3151impl ReferredDocumentType3Choice {
3152    pub fn validate(&self) -> Result<(), ValidationError> {
3153        if let Some(ref val) = self.cd {
3154            val.validate()?
3155        }
3156        if let Some(ref val) = self.prtry {
3157            if val.chars().count() < 1 {
3158                return Err(ValidationError::new(
3159                    1001,
3160                    "prtry is shorter than the minimum length of 1".to_string(),
3161                ));
3162            }
3163            if val.chars().count() > 35 {
3164                return Err(ValidationError::new(
3165                    1002,
3166                    "prtry exceeds the maximum length of 35".to_string(),
3167                ));
3168            }
3169        }
3170        Ok(())
3171    }
3172}
3173
3174// ReferredDocumentType4 ...
3175#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3176pub struct ReferredDocumentType4 {
3177    #[serde(rename = "CdOrPrtry")]
3178    pub cd_or_prtry: ReferredDocumentType3Choice,
3179    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3180    pub issr: Option<String>,
3181}
3182
3183impl ReferredDocumentType4 {
3184    pub fn validate(&self) -> Result<(), ValidationError> {
3185        self.cd_or_prtry.validate()?;
3186        if let Some(ref val) = self.issr {
3187            if val.chars().count() < 1 {
3188                return Err(ValidationError::new(
3189                    1001,
3190                    "issr is shorter than the minimum length of 1".to_string(),
3191                ));
3192            }
3193            if val.chars().count() > 35 {
3194                return Err(ValidationError::new(
3195                    1002,
3196                    "issr exceeds the maximum length of 35".to_string(),
3197                ));
3198            }
3199        }
3200        Ok(())
3201    }
3202}
3203
3204// RemittanceAmount2 ...
3205#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3206pub struct RemittanceAmount2 {
3207    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
3208    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3209    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
3210    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
3211    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
3212    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3213    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3214    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
3215    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
3216    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
3217    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3218    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3219}
3220
3221impl RemittanceAmount2 {
3222    pub fn validate(&self) -> Result<(), ValidationError> {
3223        if let Some(ref val) = self.due_pybl_amt {
3224            val.validate()?
3225        }
3226        if let Some(ref vec) = self.dscnt_apld_amt {
3227            for item in vec {
3228                item.validate()?
3229            }
3230        }
3231        if let Some(ref val) = self.cdt_note_amt {
3232            val.validate()?
3233        }
3234        if let Some(ref vec) = self.tax_amt {
3235            for item in vec {
3236                item.validate()?
3237            }
3238        }
3239        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
3240            for item in vec {
3241                item.validate()?
3242            }
3243        }
3244        if let Some(ref val) = self.rmtd_amt {
3245            val.validate()?
3246        }
3247        Ok(())
3248    }
3249}
3250
3251// RemittanceAmount3 ...
3252#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3253pub struct RemittanceAmount3 {
3254    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
3255    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3256    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
3257    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
3258    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
3259    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3260    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3261    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
3262    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
3263    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
3264    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3265    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3266}
3267
3268impl RemittanceAmount3 {
3269    pub fn validate(&self) -> Result<(), ValidationError> {
3270        if let Some(ref val) = self.due_pybl_amt {
3271            val.validate()?
3272        }
3273        if let Some(ref vec) = self.dscnt_apld_amt {
3274            for item in vec {
3275                item.validate()?
3276            }
3277        }
3278        if let Some(ref val) = self.cdt_note_amt {
3279            val.validate()?
3280        }
3281        if let Some(ref vec) = self.tax_amt {
3282            for item in vec {
3283                item.validate()?
3284            }
3285        }
3286        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
3287            for item in vec {
3288                item.validate()?
3289            }
3290        }
3291        if let Some(ref val) = self.rmtd_amt {
3292            val.validate()?
3293        }
3294        Ok(())
3295    }
3296}
3297
3298// RemittanceInformation16 ...
3299#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3300pub struct RemittanceInformation16 {
3301    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
3302    pub ustrd: Option<Vec<String>>,
3303    #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
3304    pub strd: Option<Vec<StructuredRemittanceInformation16>>,
3305}
3306
3307impl RemittanceInformation16 {
3308    pub fn validate(&self) -> Result<(), ValidationError> {
3309        if let Some(ref vec) = self.ustrd {
3310            for item in vec {
3311                if item.chars().count() < 1 {
3312                    return Err(ValidationError::new(
3313                        1001,
3314                        "ustrd is shorter than the minimum length of 1".to_string(),
3315                    ));
3316                }
3317                if item.chars().count() > 140 {
3318                    return Err(ValidationError::new(
3319                        1002,
3320                        "ustrd exceeds the maximum length of 140".to_string(),
3321                    ));
3322                }
3323            }
3324        }
3325        if let Some(ref vec) = self.strd {
3326            for item in vec {
3327                item.validate()?
3328            }
3329        }
3330        Ok(())
3331    }
3332}
3333
3334// RemittanceInformation2 ...
3335#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3336pub struct RemittanceInformation2 {
3337    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
3338    pub ustrd: Option<Vec<String>>,
3339}
3340
3341impl RemittanceInformation2 {
3342    pub fn validate(&self) -> Result<(), ValidationError> {
3343        if let Some(ref vec) = self.ustrd {
3344            for item in vec {
3345                if item.chars().count() < 1 {
3346                    return Err(ValidationError::new(
3347                        1001,
3348                        "ustrd is shorter than the minimum length of 1".to_string(),
3349                    ));
3350                }
3351                if item.chars().count() > 140 {
3352                    return Err(ValidationError::new(
3353                        1002,
3354                        "ustrd exceeds the maximum length of 140".to_string(),
3355                    ));
3356                }
3357            }
3358        }
3359        Ok(())
3360    }
3361}
3362
3363// ServiceLevel8Choice ...
3364#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3365pub struct ServiceLevel8Choice {
3366    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3367    pub cd: Option<String>,
3368    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3369    pub prtry: Option<String>,
3370}
3371
3372impl ServiceLevel8Choice {
3373    pub fn validate(&self) -> Result<(), ValidationError> {
3374        if let Some(ref val) = self.cd {
3375            if val.chars().count() < 1 {
3376                return Err(ValidationError::new(
3377                    1001,
3378                    "cd is shorter than the minimum length of 1".to_string(),
3379                ));
3380            }
3381            if val.chars().count() > 4 {
3382                return Err(ValidationError::new(
3383                    1002,
3384                    "cd exceeds the maximum length of 4".to_string(),
3385                ));
3386            }
3387        }
3388        if let Some(ref val) = self.prtry {
3389            if val.chars().count() < 1 {
3390                return Err(ValidationError::new(
3391                    1001,
3392                    "prtry is shorter than the minimum length of 1".to_string(),
3393                ));
3394            }
3395            if val.chars().count() > 35 {
3396                return Err(ValidationError::new(
3397                    1002,
3398                    "prtry exceeds the maximum length of 35".to_string(),
3399                ));
3400            }
3401        }
3402        Ok(())
3403    }
3404}
3405
3406// SettlementDateTimeIndication1 ...
3407#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3408pub struct SettlementDateTimeIndication1 {
3409    #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
3410    pub dbt_dt_tm: Option<String>,
3411    #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
3412    pub cdt_dt_tm: Option<String>,
3413}
3414
3415impl SettlementDateTimeIndication1 {
3416    pub fn validate(&self) -> Result<(), ValidationError> {
3417        Ok(())
3418    }
3419}
3420
3421// SettlementInstruction7 ...
3422#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3423pub struct SettlementInstruction7 {
3424    #[serde(rename = "SttlmMtd")]
3425    pub sttlm_mtd: SettlementMethod1Code,
3426    #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
3427    pub sttlm_acct: Option<CashAccount38>,
3428    #[serde(rename = "ClrSys", skip_serializing_if = "Option::is_none")]
3429    pub clr_sys: Option<ClearingSystemIdentification3Choice>,
3430    #[serde(rename = "InstgRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3431    pub instg_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3432    #[serde(
3433        rename = "InstgRmbrsmntAgtAcct",
3434        skip_serializing_if = "Option::is_none"
3435    )]
3436    pub instg_rmbrsmnt_agt_acct: Option<CashAccount38>,
3437    #[serde(rename = "InstdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3438    pub instd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3439    #[serde(
3440        rename = "InstdRmbrsmntAgtAcct",
3441        skip_serializing_if = "Option::is_none"
3442    )]
3443    pub instd_rmbrsmnt_agt_acct: Option<CashAccount38>,
3444    #[serde(rename = "ThrdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3445    pub thrd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3446    #[serde(
3447        rename = "ThrdRmbrsmntAgtAcct",
3448        skip_serializing_if = "Option::is_none"
3449    )]
3450    pub thrd_rmbrsmnt_agt_acct: Option<CashAccount38>,
3451}
3452
3453impl SettlementInstruction7 {
3454    pub fn validate(&self) -> Result<(), ValidationError> {
3455        self.sttlm_mtd.validate()?;
3456        if let Some(ref val) = self.sttlm_acct {
3457            val.validate()?
3458        }
3459        if let Some(ref val) = self.clr_sys {
3460            val.validate()?
3461        }
3462        if let Some(ref val) = self.instg_rmbrsmnt_agt {
3463            val.validate()?
3464        }
3465        if let Some(ref val) = self.instg_rmbrsmnt_agt_acct {
3466            val.validate()?
3467        }
3468        if let Some(ref val) = self.instd_rmbrsmnt_agt {
3469            val.validate()?
3470        }
3471        if let Some(ref val) = self.instd_rmbrsmnt_agt_acct {
3472            val.validate()?
3473        }
3474        if let Some(ref val) = self.thrd_rmbrsmnt_agt {
3475            val.validate()?
3476        }
3477        if let Some(ref val) = self.thrd_rmbrsmnt_agt_acct {
3478            val.validate()?
3479        }
3480        Ok(())
3481    }
3482}
3483
3484// SettlementMethod1Code ...
3485#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3486pub enum SettlementMethod1Code {
3487    #[default]
3488    #[serde(rename = "INDA")]
3489    CodeINDA,
3490    #[serde(rename = "INGA")]
3491    CodeINGA,
3492    #[serde(rename = "COVE")]
3493    CodeCOVE,
3494    #[serde(rename = "CLRG")]
3495    CodeCLRG,
3496}
3497
3498impl SettlementMethod1Code {
3499    pub fn validate(&self) -> Result<(), ValidationError> {
3500        Ok(())
3501    }
3502}
3503
3504// SettlementTimeRequest2 ...
3505#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3506pub struct SettlementTimeRequest2 {
3507    #[serde(rename = "CLSTm", skip_serializing_if = "Option::is_none")]
3508    pub cls_tm: Option<String>,
3509    #[serde(rename = "TillTm", skip_serializing_if = "Option::is_none")]
3510    pub till_tm: Option<String>,
3511    #[serde(rename = "FrTm", skip_serializing_if = "Option::is_none")]
3512    pub fr_tm: Option<String>,
3513    #[serde(rename = "RjctTm", skip_serializing_if = "Option::is_none")]
3514    pub rjct_tm: Option<String>,
3515}
3516
3517impl SettlementTimeRequest2 {
3518    pub fn validate(&self) -> Result<(), ValidationError> {
3519        Ok(())
3520    }
3521}
3522
3523// StructuredRemittanceInformation16 ...
3524#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3525pub struct StructuredRemittanceInformation16 {
3526    #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
3527    pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation7>>,
3528    #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
3529    pub rfrd_doc_amt: Option<RemittanceAmount2>,
3530    #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
3531    pub cdtr_ref_inf: Option<CreditorReferenceInformation2>,
3532    #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
3533    pub invcr: Option<PartyIdentification135>,
3534    #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
3535    pub invcee: Option<PartyIdentification135>,
3536    #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
3537    pub tax_rmt: Option<TaxInformation7>,
3538    #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
3539    pub grnshmt_rmt: Option<Garnishment3>,
3540    #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
3541    pub addtl_rmt_inf: Option<Vec<String>>,
3542}
3543
3544impl StructuredRemittanceInformation16 {
3545    pub fn validate(&self) -> Result<(), ValidationError> {
3546        if let Some(ref vec) = self.rfrd_doc_inf {
3547            for item in vec {
3548                item.validate()?
3549            }
3550        }
3551        if let Some(ref val) = self.rfrd_doc_amt {
3552            val.validate()?
3553        }
3554        if let Some(ref val) = self.cdtr_ref_inf {
3555            val.validate()?
3556        }
3557        if let Some(ref val) = self.invcr {
3558            val.validate()?
3559        }
3560        if let Some(ref val) = self.invcee {
3561            val.validate()?
3562        }
3563        if let Some(ref val) = self.tax_rmt {
3564            val.validate()?
3565        }
3566        if let Some(ref val) = self.grnshmt_rmt {
3567            val.validate()?
3568        }
3569        if let Some(ref vec) = self.addtl_rmt_inf {
3570            for item in vec {
3571                if item.chars().count() < 1 {
3572                    return Err(ValidationError::new(
3573                        1001,
3574                        "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
3575                    ));
3576                }
3577                if item.chars().count() > 140 {
3578                    return Err(ValidationError::new(
3579                        1002,
3580                        "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
3581                    ));
3582                }
3583            }
3584        }
3585        Ok(())
3586    }
3587}
3588
3589// SupplementaryData1 ...
3590#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3591pub struct SupplementaryData1 {
3592    #[serde(rename = "PlcAndNm", skip_serializing_if = "Option::is_none")]
3593    pub plc_and_nm: Option<String>,
3594    #[serde(rename = "Envlp")]
3595    pub envlp: SupplementaryDataEnvelope1,
3596}
3597
3598impl SupplementaryData1 {
3599    pub fn validate(&self) -> Result<(), ValidationError> {
3600        if let Some(ref val) = self.plc_and_nm {
3601            if val.chars().count() < 1 {
3602                return Err(ValidationError::new(
3603                    1001,
3604                    "plc_and_nm is shorter than the minimum length of 1".to_string(),
3605                ));
3606            }
3607            if val.chars().count() > 350 {
3608                return Err(ValidationError::new(
3609                    1002,
3610                    "plc_and_nm exceeds the maximum length of 350".to_string(),
3611                ));
3612            }
3613        }
3614        self.envlp.validate()?;
3615        Ok(())
3616    }
3617}
3618
3619// SupplementaryDataEnvelope1 ...
3620#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3621pub struct SupplementaryDataEnvelope1 {}
3622
3623impl SupplementaryDataEnvelope1 {
3624    pub fn validate(&self) -> Result<(), ValidationError> {
3625        Ok(())
3626    }
3627}
3628
3629// TaxAmount2 ...
3630#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3631pub struct TaxAmount2 {
3632    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
3633    pub rate: Option<f64>,
3634    #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3635    pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3636    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
3637    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3638    #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
3639    pub dtls: Option<Vec<TaxRecordDetails2>>,
3640}
3641
3642impl TaxAmount2 {
3643    pub fn validate(&self) -> Result<(), ValidationError> {
3644        if let Some(ref val) = self.taxbl_base_amt {
3645            val.validate()?
3646        }
3647        if let Some(ref val) = self.ttl_amt {
3648            val.validate()?
3649        }
3650        if let Some(ref vec) = self.dtls {
3651            for item in vec {
3652                item.validate()?
3653            }
3654        }
3655        Ok(())
3656    }
3657}
3658
3659// TaxAmountAndType1 ...
3660#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3661pub struct TaxAmountAndType1 {
3662    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3663    pub tp: Option<TaxAmountType1Choice>,
3664    #[serde(rename = "Amt")]
3665    pub amt: ActiveOrHistoricCurrencyAndAmount,
3666}
3667
3668impl TaxAmountAndType1 {
3669    pub fn validate(&self) -> Result<(), ValidationError> {
3670        if let Some(ref val) = self.tp {
3671            val.validate()?
3672        }
3673        self.amt.validate()?;
3674        Ok(())
3675    }
3676}
3677
3678// TaxAmountType1Choice ...
3679#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3680pub struct TaxAmountType1Choice {
3681    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3682    pub cd: Option<String>,
3683    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3684    pub prtry: Option<String>,
3685}
3686
3687impl TaxAmountType1Choice {
3688    pub fn validate(&self) -> Result<(), ValidationError> {
3689        if let Some(ref val) = self.cd {
3690            if val.chars().count() < 1 {
3691                return Err(ValidationError::new(
3692                    1001,
3693                    "cd is shorter than the minimum length of 1".to_string(),
3694                ));
3695            }
3696            if val.chars().count() > 4 {
3697                return Err(ValidationError::new(
3698                    1002,
3699                    "cd exceeds the maximum length of 4".to_string(),
3700                ));
3701            }
3702        }
3703        if let Some(ref val) = self.prtry {
3704            if val.chars().count() < 1 {
3705                return Err(ValidationError::new(
3706                    1001,
3707                    "prtry is shorter than the minimum length of 1".to_string(),
3708                ));
3709            }
3710            if val.chars().count() > 35 {
3711                return Err(ValidationError::new(
3712                    1002,
3713                    "prtry exceeds the maximum length of 35".to_string(),
3714                ));
3715            }
3716        }
3717        Ok(())
3718    }
3719}
3720
3721// TaxAuthorisation1 ...
3722#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3723pub struct TaxAuthorisation1 {
3724    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
3725    pub titl: Option<String>,
3726    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3727    pub nm: Option<String>,
3728}
3729
3730impl TaxAuthorisation1 {
3731    pub fn validate(&self) -> Result<(), ValidationError> {
3732        if let Some(ref val) = self.titl {
3733            if val.chars().count() < 1 {
3734                return Err(ValidationError::new(
3735                    1001,
3736                    "titl is shorter than the minimum length of 1".to_string(),
3737                ));
3738            }
3739            if val.chars().count() > 35 {
3740                return Err(ValidationError::new(
3741                    1002,
3742                    "titl exceeds the maximum length of 35".to_string(),
3743                ));
3744            }
3745        }
3746        if let Some(ref val) = self.nm {
3747            if val.chars().count() < 1 {
3748                return Err(ValidationError::new(
3749                    1001,
3750                    "nm is shorter than the minimum length of 1".to_string(),
3751                ));
3752            }
3753            if val.chars().count() > 140 {
3754                return Err(ValidationError::new(
3755                    1002,
3756                    "nm exceeds the maximum length of 140".to_string(),
3757                ));
3758            }
3759        }
3760        Ok(())
3761    }
3762}
3763
3764// TaxInformation7 ...
3765#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3766pub struct TaxInformation7 {
3767    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3768    pub cdtr: Option<TaxParty1>,
3769    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3770    pub dbtr: Option<TaxParty2>,
3771    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
3772    pub ultmt_dbtr: Option<TaxParty2>,
3773    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
3774    pub admstn_zone: Option<String>,
3775    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3776    pub ref_nb: Option<String>,
3777    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
3778    pub mtd: Option<String>,
3779    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3780    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3781    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
3782    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3783    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3784    pub dt: Option<String>,
3785    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
3786    pub seq_nb: Option<f64>,
3787    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
3788    pub rcrd: Option<Vec<TaxRecord2>>,
3789}
3790
3791impl TaxInformation7 {
3792    pub fn validate(&self) -> Result<(), ValidationError> {
3793        if let Some(ref val) = self.cdtr {
3794            val.validate()?
3795        }
3796        if let Some(ref val) = self.dbtr {
3797            val.validate()?
3798        }
3799        if let Some(ref val) = self.ultmt_dbtr {
3800            val.validate()?
3801        }
3802        if let Some(ref val) = self.admstn_zone {
3803            if val.chars().count() < 1 {
3804                return Err(ValidationError::new(
3805                    1001,
3806                    "admstn_zone is shorter than the minimum length of 1".to_string(),
3807                ));
3808            }
3809            if val.chars().count() > 35 {
3810                return Err(ValidationError::new(
3811                    1002,
3812                    "admstn_zone exceeds the maximum length of 35".to_string(),
3813                ));
3814            }
3815        }
3816        if let Some(ref val) = self.ref_nb {
3817            if val.chars().count() < 1 {
3818                return Err(ValidationError::new(
3819                    1001,
3820                    "ref_nb is shorter than the minimum length of 1".to_string(),
3821                ));
3822            }
3823            if val.chars().count() > 140 {
3824                return Err(ValidationError::new(
3825                    1002,
3826                    "ref_nb exceeds the maximum length of 140".to_string(),
3827                ));
3828            }
3829        }
3830        if let Some(ref val) = self.mtd {
3831            if val.chars().count() < 1 {
3832                return Err(ValidationError::new(
3833                    1001,
3834                    "mtd is shorter than the minimum length of 1".to_string(),
3835                ));
3836            }
3837            if val.chars().count() > 35 {
3838                return Err(ValidationError::new(
3839                    1002,
3840                    "mtd exceeds the maximum length of 35".to_string(),
3841                ));
3842            }
3843        }
3844        if let Some(ref val) = self.ttl_taxbl_base_amt {
3845            val.validate()?
3846        }
3847        if let Some(ref val) = self.ttl_tax_amt {
3848            val.validate()?
3849        }
3850        if let Some(ref vec) = self.rcrd {
3851            for item in vec {
3852                item.validate()?
3853            }
3854        }
3855        Ok(())
3856    }
3857}
3858
3859// TaxInformation8 ...
3860#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3861pub struct TaxInformation8 {
3862    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3863    pub cdtr: Option<TaxParty1>,
3864    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3865    pub dbtr: Option<TaxParty2>,
3866    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
3867    pub admstn_zone: Option<String>,
3868    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3869    pub ref_nb: Option<String>,
3870    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
3871    pub mtd: Option<String>,
3872    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3873    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3874    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
3875    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3876    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3877    pub dt: Option<String>,
3878    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
3879    pub seq_nb: Option<f64>,
3880    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
3881    pub rcrd: Option<Vec<TaxRecord2>>,
3882}
3883
3884impl TaxInformation8 {
3885    pub fn validate(&self) -> Result<(), ValidationError> {
3886        if let Some(ref val) = self.cdtr {
3887            val.validate()?
3888        }
3889        if let Some(ref val) = self.dbtr {
3890            val.validate()?
3891        }
3892        if let Some(ref val) = self.admstn_zone {
3893            if val.chars().count() < 1 {
3894                return Err(ValidationError::new(
3895                    1001,
3896                    "admstn_zone is shorter than the minimum length of 1".to_string(),
3897                ));
3898            }
3899            if val.chars().count() > 35 {
3900                return Err(ValidationError::new(
3901                    1002,
3902                    "admstn_zone exceeds the maximum length of 35".to_string(),
3903                ));
3904            }
3905        }
3906        if let Some(ref val) = self.ref_nb {
3907            if val.chars().count() < 1 {
3908                return Err(ValidationError::new(
3909                    1001,
3910                    "ref_nb is shorter than the minimum length of 1".to_string(),
3911                ));
3912            }
3913            if val.chars().count() > 140 {
3914                return Err(ValidationError::new(
3915                    1002,
3916                    "ref_nb exceeds the maximum length of 140".to_string(),
3917                ));
3918            }
3919        }
3920        if let Some(ref val) = self.mtd {
3921            if val.chars().count() < 1 {
3922                return Err(ValidationError::new(
3923                    1001,
3924                    "mtd is shorter than the minimum length of 1".to_string(),
3925                ));
3926            }
3927            if val.chars().count() > 35 {
3928                return Err(ValidationError::new(
3929                    1002,
3930                    "mtd exceeds the maximum length of 35".to_string(),
3931                ));
3932            }
3933        }
3934        if let Some(ref val) = self.ttl_taxbl_base_amt {
3935            val.validate()?
3936        }
3937        if let Some(ref val) = self.ttl_tax_amt {
3938            val.validate()?
3939        }
3940        if let Some(ref vec) = self.rcrd {
3941            for item in vec {
3942                item.validate()?
3943            }
3944        }
3945        Ok(())
3946    }
3947}
3948
3949// TaxParty1 ...
3950#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3951pub struct TaxParty1 {
3952    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
3953    pub tax_id: Option<String>,
3954    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
3955    pub regn_id: Option<String>,
3956    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
3957    pub tax_tp: Option<String>,
3958}
3959
3960impl TaxParty1 {
3961    pub fn validate(&self) -> Result<(), ValidationError> {
3962        if let Some(ref val) = self.tax_id {
3963            if val.chars().count() < 1 {
3964                return Err(ValidationError::new(
3965                    1001,
3966                    "tax_id is shorter than the minimum length of 1".to_string(),
3967                ));
3968            }
3969            if val.chars().count() > 35 {
3970                return Err(ValidationError::new(
3971                    1002,
3972                    "tax_id exceeds the maximum length of 35".to_string(),
3973                ));
3974            }
3975        }
3976        if let Some(ref val) = self.regn_id {
3977            if val.chars().count() < 1 {
3978                return Err(ValidationError::new(
3979                    1001,
3980                    "regn_id is shorter than the minimum length of 1".to_string(),
3981                ));
3982            }
3983            if val.chars().count() > 35 {
3984                return Err(ValidationError::new(
3985                    1002,
3986                    "regn_id exceeds the maximum length of 35".to_string(),
3987                ));
3988            }
3989        }
3990        if let Some(ref val) = self.tax_tp {
3991            if val.chars().count() < 1 {
3992                return Err(ValidationError::new(
3993                    1001,
3994                    "tax_tp is shorter than the minimum length of 1".to_string(),
3995                ));
3996            }
3997            if val.chars().count() > 35 {
3998                return Err(ValidationError::new(
3999                    1002,
4000                    "tax_tp exceeds the maximum length of 35".to_string(),
4001                ));
4002            }
4003        }
4004        Ok(())
4005    }
4006}
4007
4008// TaxParty2 ...
4009#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4010pub struct TaxParty2 {
4011    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
4012    pub tax_id: Option<String>,
4013    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
4014    pub regn_id: Option<String>,
4015    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
4016    pub tax_tp: Option<String>,
4017    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
4018    pub authstn: Option<TaxAuthorisation1>,
4019}
4020
4021impl TaxParty2 {
4022    pub fn validate(&self) -> Result<(), ValidationError> {
4023        if let Some(ref val) = self.tax_id {
4024            if val.chars().count() < 1 {
4025                return Err(ValidationError::new(
4026                    1001,
4027                    "tax_id is shorter than the minimum length of 1".to_string(),
4028                ));
4029            }
4030            if val.chars().count() > 35 {
4031                return Err(ValidationError::new(
4032                    1002,
4033                    "tax_id exceeds the maximum length of 35".to_string(),
4034                ));
4035            }
4036        }
4037        if let Some(ref val) = self.regn_id {
4038            if val.chars().count() < 1 {
4039                return Err(ValidationError::new(
4040                    1001,
4041                    "regn_id is shorter than the minimum length of 1".to_string(),
4042                ));
4043            }
4044            if val.chars().count() > 35 {
4045                return Err(ValidationError::new(
4046                    1002,
4047                    "regn_id exceeds the maximum length of 35".to_string(),
4048                ));
4049            }
4050        }
4051        if let Some(ref val) = self.tax_tp {
4052            if val.chars().count() < 1 {
4053                return Err(ValidationError::new(
4054                    1001,
4055                    "tax_tp is shorter than the minimum length of 1".to_string(),
4056                ));
4057            }
4058            if val.chars().count() > 35 {
4059                return Err(ValidationError::new(
4060                    1002,
4061                    "tax_tp exceeds the maximum length of 35".to_string(),
4062                ));
4063            }
4064        }
4065        if let Some(ref val) = self.authstn {
4066            val.validate()?
4067        }
4068        Ok(())
4069    }
4070}
4071
4072// TaxPeriod2 ...
4073#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4074pub struct TaxPeriod2 {
4075    #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
4076    pub yr: Option<String>,
4077    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4078    pub tp: Option<TaxRecordPeriod1Code>,
4079    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
4080    pub fr_to_dt: Option<DatePeriod2>,
4081}
4082
4083impl TaxPeriod2 {
4084    pub fn validate(&self) -> Result<(), ValidationError> {
4085        if let Some(ref val) = self.tp {
4086            val.validate()?
4087        }
4088        if let Some(ref val) = self.fr_to_dt {
4089            val.validate()?
4090        }
4091        Ok(())
4092    }
4093}
4094
4095// TaxRecord2 ...
4096#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4097pub struct TaxRecord2 {
4098    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4099    pub tp: Option<String>,
4100    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
4101    pub ctgy: Option<String>,
4102    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
4103    pub ctgy_dtls: Option<String>,
4104    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
4105    pub dbtr_sts: Option<String>,
4106    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
4107    pub cert_id: Option<String>,
4108    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
4109    pub frms_cd: Option<String>,
4110    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
4111    pub prd: Option<TaxPeriod2>,
4112    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
4113    pub tax_amt: Option<TaxAmount2>,
4114    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
4115    pub addtl_inf: Option<String>,
4116}
4117
4118impl TaxRecord2 {
4119    pub fn validate(&self) -> Result<(), ValidationError> {
4120        if let Some(ref val) = self.tp {
4121            if val.chars().count() < 1 {
4122                return Err(ValidationError::new(
4123                    1001,
4124                    "tp is shorter than the minimum length of 1".to_string(),
4125                ));
4126            }
4127            if val.chars().count() > 35 {
4128                return Err(ValidationError::new(
4129                    1002,
4130                    "tp exceeds the maximum length of 35".to_string(),
4131                ));
4132            }
4133        }
4134        if let Some(ref val) = self.ctgy {
4135            if val.chars().count() < 1 {
4136                return Err(ValidationError::new(
4137                    1001,
4138                    "ctgy is shorter than the minimum length of 1".to_string(),
4139                ));
4140            }
4141            if val.chars().count() > 35 {
4142                return Err(ValidationError::new(
4143                    1002,
4144                    "ctgy exceeds the maximum length of 35".to_string(),
4145                ));
4146            }
4147        }
4148        if let Some(ref val) = self.ctgy_dtls {
4149            if val.chars().count() < 1 {
4150                return Err(ValidationError::new(
4151                    1001,
4152                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
4153                ));
4154            }
4155            if val.chars().count() > 35 {
4156                return Err(ValidationError::new(
4157                    1002,
4158                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
4159                ));
4160            }
4161        }
4162        if let Some(ref val) = self.dbtr_sts {
4163            if val.chars().count() < 1 {
4164                return Err(ValidationError::new(
4165                    1001,
4166                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
4167                ));
4168            }
4169            if val.chars().count() > 35 {
4170                return Err(ValidationError::new(
4171                    1002,
4172                    "dbtr_sts exceeds the maximum length of 35".to_string(),
4173                ));
4174            }
4175        }
4176        if let Some(ref val) = self.cert_id {
4177            if val.chars().count() < 1 {
4178                return Err(ValidationError::new(
4179                    1001,
4180                    "cert_id is shorter than the minimum length of 1".to_string(),
4181                ));
4182            }
4183            if val.chars().count() > 35 {
4184                return Err(ValidationError::new(
4185                    1002,
4186                    "cert_id exceeds the maximum length of 35".to_string(),
4187                ));
4188            }
4189        }
4190        if let Some(ref val) = self.frms_cd {
4191            if val.chars().count() < 1 {
4192                return Err(ValidationError::new(
4193                    1001,
4194                    "frms_cd is shorter than the minimum length of 1".to_string(),
4195                ));
4196            }
4197            if val.chars().count() > 35 {
4198                return Err(ValidationError::new(
4199                    1002,
4200                    "frms_cd exceeds the maximum length of 35".to_string(),
4201                ));
4202            }
4203        }
4204        if let Some(ref val) = self.prd {
4205            val.validate()?
4206        }
4207        if let Some(ref val) = self.tax_amt {
4208            val.validate()?
4209        }
4210        if let Some(ref val) = self.addtl_inf {
4211            if val.chars().count() < 1 {
4212                return Err(ValidationError::new(
4213                    1001,
4214                    "addtl_inf is shorter than the minimum length of 1".to_string(),
4215                ));
4216            }
4217            if val.chars().count() > 140 {
4218                return Err(ValidationError::new(
4219                    1002,
4220                    "addtl_inf exceeds the maximum length of 140".to_string(),
4221                ));
4222            }
4223        }
4224        Ok(())
4225    }
4226}
4227
4228// TaxRecordDetails2 ...
4229#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4230pub struct TaxRecordDetails2 {
4231    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
4232    pub prd: Option<TaxPeriod2>,
4233    #[serde(rename = "Amt")]
4234    pub amt: ActiveOrHistoricCurrencyAndAmount,
4235}
4236
4237impl TaxRecordDetails2 {
4238    pub fn validate(&self) -> Result<(), ValidationError> {
4239        if let Some(ref val) = self.prd {
4240            val.validate()?
4241        }
4242        self.amt.validate()?;
4243        Ok(())
4244    }
4245}
4246
4247// TaxRecordPeriod1Code ...
4248#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4249pub enum TaxRecordPeriod1Code {
4250    #[default]
4251    #[serde(rename = "MM01")]
4252    CodeMM01,
4253    #[serde(rename = "MM02")]
4254    CodeMM02,
4255    #[serde(rename = "MM03")]
4256    CodeMM03,
4257    #[serde(rename = "MM04")]
4258    CodeMM04,
4259    #[serde(rename = "MM05")]
4260    CodeMM05,
4261    #[serde(rename = "MM06")]
4262    CodeMM06,
4263    #[serde(rename = "MM07")]
4264    CodeMM07,
4265    #[serde(rename = "MM08")]
4266    CodeMM08,
4267    #[serde(rename = "MM09")]
4268    CodeMM09,
4269    #[serde(rename = "MM10")]
4270    CodeMM10,
4271    #[serde(rename = "MM11")]
4272    CodeMM11,
4273    #[serde(rename = "MM12")]
4274    CodeMM12,
4275    #[serde(rename = "QTR1")]
4276    CodeQTR1,
4277    #[serde(rename = "QTR2")]
4278    CodeQTR2,
4279    #[serde(rename = "QTR3")]
4280    CodeQTR3,
4281    #[serde(rename = "QTR4")]
4282    CodeQTR4,
4283    #[serde(rename = "HLF1")]
4284    CodeHLF1,
4285    #[serde(rename = "HLF2")]
4286    CodeHLF2,
4287}
4288
4289impl TaxRecordPeriod1Code {
4290    pub fn validate(&self) -> Result<(), ValidationError> {
4291        Ok(())
4292    }
4293}