mx_message/
camt_057_001_06.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// AccountNotification16 ...
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountNotification16 {
54    #[serde(rename = "Id")]
55    pub id: String,
56    #[serde(rename = "Acct", skip_serializing_if = "Option::is_none")]
57    pub acct: Option<CashAccount38>,
58    #[serde(rename = "AcctOwnr", skip_serializing_if = "Option::is_none")]
59    pub acct_ownr: Option<Party40Choice>,
60    #[serde(rename = "AcctSvcr", skip_serializing_if = "Option::is_none")]
61    pub acct_svcr: Option<BranchAndFinancialInstitutionIdentification6>,
62    #[serde(rename = "RltdAcct", skip_serializing_if = "Option::is_none")]
63    pub rltd_acct: Option<CashAccount38>,
64    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
65    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
66    #[serde(rename = "XpctdValDt", skip_serializing_if = "Option::is_none")]
67    pub xpctd_val_dt: Option<String>,
68    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
69    pub dbtr: Option<Party40Choice>,
70    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
71    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
72    #[serde(rename = "IntrmyAgt", skip_serializing_if = "Option::is_none")]
73    pub intrmy_agt: Option<BranchAndFinancialInstitutionIdentification6>,
74    #[serde(rename = "Itm")]
75    pub itm: Vec<NotificationItem7>,
76}
77
78impl AccountNotification16 {
79    pub fn validate(&self) -> Result<(), ValidationError> {
80        if self.id.chars().count() < 1 {
81            return Err(ValidationError::new(
82                1001,
83                "id is shorter than the minimum length of 1".to_string(),
84            ));
85        }
86        if self.id.chars().count() > 35 {
87            return Err(ValidationError::new(
88                1002,
89                "id exceeds the maximum length of 35".to_string(),
90            ));
91        }
92        if let Some(ref val) = self.acct {
93            val.validate()?
94        }
95        if let Some(ref val) = self.acct_ownr {
96            val.validate()?
97        }
98        if let Some(ref val) = self.acct_svcr {
99            val.validate()?
100        }
101        if let Some(ref val) = self.rltd_acct {
102            val.validate()?
103        }
104        if let Some(ref val) = self.ttl_amt {
105            val.validate()?
106        }
107        if let Some(ref val) = self.dbtr {
108            val.validate()?
109        }
110        if let Some(ref val) = self.dbtr_agt {
111            val.validate()?
112        }
113        if let Some(ref val) = self.intrmy_agt {
114            val.validate()?
115        }
116        for item in &self.itm {
117            item.validate()?
118        }
119        Ok(())
120    }
121}
122
123// AccountSchemeName1Choice ...
124#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
125pub struct AccountSchemeName1Choice {
126    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
127    pub cd: Option<String>,
128    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
129    pub prtry: Option<String>,
130}
131
132impl AccountSchemeName1Choice {
133    pub fn validate(&self) -> Result<(), ValidationError> {
134        if let Some(ref val) = self.cd {
135            if val.chars().count() < 1 {
136                return Err(ValidationError::new(
137                    1001,
138                    "cd is shorter than the minimum length of 1".to_string(),
139                ));
140            }
141            if val.chars().count() > 4 {
142                return Err(ValidationError::new(
143                    1002,
144                    "cd exceeds the maximum length of 4".to_string(),
145                ));
146            }
147        }
148        if let Some(ref val) = self.prtry {
149            if val.chars().count() < 1 {
150                return Err(ValidationError::new(
151                    1001,
152                    "prtry is shorter than the minimum length of 1".to_string(),
153                ));
154            }
155            if val.chars().count() > 35 {
156                return Err(ValidationError::new(
157                    1002,
158                    "prtry exceeds the maximum length of 35".to_string(),
159                ));
160            }
161        }
162        Ok(())
163    }
164}
165
166// ActiveOrHistoricCurrencyAndAmount ...
167#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
168pub struct ActiveOrHistoricCurrencyAndAmount {
169    #[serde(rename = "@Ccy")]
170    pub ccy: String,
171    #[serde(rename = "$value")]
172    pub value: f64,
173}
174
175impl ActiveOrHistoricCurrencyAndAmount {
176    pub fn validate(&self) -> Result<(), ValidationError> {
177        Ok(())
178    }
179}
180
181// AddressType2Code ...
182#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
183pub enum AddressType2Code {
184    #[default]
185    #[serde(rename = "ADDR")]
186    CodeADDR,
187    #[serde(rename = "PBOX")]
188    CodePBOX,
189    #[serde(rename = "HOME")]
190    CodeHOME,
191    #[serde(rename = "BIZZ")]
192    CodeBIZZ,
193    #[serde(rename = "MLTO")]
194    CodeMLTO,
195    #[serde(rename = "DLVY")]
196    CodeDLVY,
197}
198
199impl AddressType2Code {
200    pub fn validate(&self) -> Result<(), ValidationError> {
201        Ok(())
202    }
203}
204
205// AddressType3Choice ...
206#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
207pub struct AddressType3Choice {
208    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
209    pub cd: Option<AddressType2Code>,
210    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
211    pub prtry: Option<GenericIdentification30>,
212}
213
214impl AddressType3Choice {
215    pub fn validate(&self) -> Result<(), ValidationError> {
216        if let Some(ref val) = self.cd {
217            val.validate()?
218        }
219        if let Some(ref val) = self.prtry {
220            val.validate()?
221        }
222        Ok(())
223    }
224}
225
226// BranchAndFinancialInstitutionIdentification6 ...
227#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
228pub struct BranchAndFinancialInstitutionIdentification6 {
229    #[serde(rename = "FinInstnId")]
230    pub fin_instn_id: FinancialInstitutionIdentification18,
231    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
232    pub brnch_id: Option<BranchData3>,
233}
234
235impl BranchAndFinancialInstitutionIdentification6 {
236    pub fn validate(&self) -> Result<(), ValidationError> {
237        self.fin_instn_id.validate()?;
238        if let Some(ref val) = self.brnch_id {
239            val.validate()?
240        }
241        Ok(())
242    }
243}
244
245// BranchData3 ...
246#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
247pub struct BranchData3 {
248    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
249    pub id: Option<String>,
250    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
251    pub lei: Option<String>,
252    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
253    pub nm: Option<String>,
254    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
255    pub pstl_adr: Option<PostalAddress24>,
256}
257
258impl BranchData3 {
259    pub fn validate(&self) -> Result<(), ValidationError> {
260        if let Some(ref val) = self.id {
261            if val.chars().count() < 1 {
262                return Err(ValidationError::new(
263                    1001,
264                    "id is shorter than the minimum length of 1".to_string(),
265                ));
266            }
267            if val.chars().count() > 35 {
268                return Err(ValidationError::new(
269                    1002,
270                    "id exceeds the maximum length of 35".to_string(),
271                ));
272            }
273        }
274        if let Some(ref val) = self.lei {
275            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
276            if !pattern.is_match(val) {
277                return Err(ValidationError::new(
278                    1005,
279                    "lei does not match the required pattern".to_string(),
280                ));
281            }
282        }
283        if let Some(ref val) = self.nm {
284            if val.chars().count() < 1 {
285                return Err(ValidationError::new(
286                    1001,
287                    "nm is shorter than the minimum length of 1".to_string(),
288                ));
289            }
290            if val.chars().count() > 140 {
291                return Err(ValidationError::new(
292                    1002,
293                    "nm exceeds the maximum length of 140".to_string(),
294                ));
295            }
296        }
297        if let Some(ref val) = self.pstl_adr {
298            val.validate()?
299        }
300        Ok(())
301    }
302}
303
304// CashAccount38 ...
305#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
306pub struct CashAccount38 {
307    #[serde(rename = "Id")]
308    pub id: AccountIdentification4Choice,
309    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
310    pub tp: Option<CashAccountType2Choice>,
311    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
312    pub ccy: Option<String>,
313    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
314    pub nm: Option<String>,
315    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
316    pub prxy: Option<ProxyAccountIdentification1>,
317}
318
319impl CashAccount38 {
320    pub fn validate(&self) -> Result<(), ValidationError> {
321        self.id.validate()?;
322        if let Some(ref val) = self.tp {
323            val.validate()?
324        }
325        if let Some(ref val) = self.ccy {
326            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
327            if !pattern.is_match(val) {
328                return Err(ValidationError::new(
329                    1005,
330                    "ccy does not match the required pattern".to_string(),
331                ));
332            }
333        }
334        if let Some(ref val) = self.nm {
335            if val.chars().count() < 1 {
336                return Err(ValidationError::new(
337                    1001,
338                    "nm is shorter than the minimum length of 1".to_string(),
339                ));
340            }
341            if val.chars().count() > 70 {
342                return Err(ValidationError::new(
343                    1002,
344                    "nm exceeds the maximum length of 70".to_string(),
345                ));
346            }
347        }
348        if let Some(ref val) = self.prxy {
349            val.validate()?
350        }
351        Ok(())
352    }
353}
354
355// CashAccountType2Choice ...
356#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
357pub struct CashAccountType2Choice {
358    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
359    pub cd: Option<String>,
360    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
361    pub prtry: Option<String>,
362}
363
364impl CashAccountType2Choice {
365    pub fn validate(&self) -> Result<(), ValidationError> {
366        if let Some(ref val) = self.cd {
367            if val.chars().count() < 1 {
368                return Err(ValidationError::new(
369                    1001,
370                    "cd is shorter than the minimum length of 1".to_string(),
371                ));
372            }
373            if val.chars().count() > 4 {
374                return Err(ValidationError::new(
375                    1002,
376                    "cd exceeds the maximum length of 4".to_string(),
377                ));
378            }
379        }
380        if let Some(ref val) = self.prtry {
381            if val.chars().count() < 1 {
382                return Err(ValidationError::new(
383                    1001,
384                    "prtry is shorter than the minimum length of 1".to_string(),
385                ));
386            }
387            if val.chars().count() > 35 {
388                return Err(ValidationError::new(
389                    1002,
390                    "prtry exceeds the maximum length of 35".to_string(),
391                ));
392            }
393        }
394        Ok(())
395    }
396}
397
398// ClearingSystemIdentification2Choice ...
399#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
400pub struct ClearingSystemIdentification2Choice {
401    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
402    pub cd: Option<String>,
403    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
404    pub prtry: Option<String>,
405}
406
407impl ClearingSystemIdentification2Choice {
408    pub fn validate(&self) -> Result<(), ValidationError> {
409        if let Some(ref val) = self.cd {
410            if val.chars().count() < 1 {
411                return Err(ValidationError::new(
412                    1001,
413                    "cd is shorter than the minimum length of 1".to_string(),
414                ));
415            }
416            if val.chars().count() > 5 {
417                return Err(ValidationError::new(
418                    1002,
419                    "cd exceeds the maximum length of 5".to_string(),
420                ));
421            }
422        }
423        if let Some(ref val) = self.prtry {
424            if val.chars().count() < 1 {
425                return Err(ValidationError::new(
426                    1001,
427                    "prtry is shorter than the minimum length of 1".to_string(),
428                ));
429            }
430            if val.chars().count() > 35 {
431                return Err(ValidationError::new(
432                    1002,
433                    "prtry exceeds the maximum length of 35".to_string(),
434                ));
435            }
436        }
437        Ok(())
438    }
439}
440
441// ClearingSystemMemberIdentification2 ...
442#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
443pub struct ClearingSystemMemberIdentification2 {
444    #[serde(rename = "ClrSysId", skip_serializing_if = "Option::is_none")]
445    pub clr_sys_id: Option<ClearingSystemIdentification2Choice>,
446    #[serde(rename = "MmbId")]
447    pub mmb_id: String,
448}
449
450impl ClearingSystemMemberIdentification2 {
451    pub fn validate(&self) -> Result<(), ValidationError> {
452        if let Some(ref val) = self.clr_sys_id {
453            val.validate()?
454        }
455        if self.mmb_id.chars().count() < 1 {
456            return Err(ValidationError::new(
457                1001,
458                "mmb_id is shorter than the minimum length of 1".to_string(),
459            ));
460        }
461        if self.mmb_id.chars().count() > 35 {
462            return Err(ValidationError::new(
463                1002,
464                "mmb_id exceeds the maximum length of 35".to_string(),
465            ));
466        }
467        Ok(())
468    }
469}
470
471// Contact4 ...
472#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
473pub struct Contact4 {
474    #[serde(rename = "NmPrfx", skip_serializing_if = "Option::is_none")]
475    pub nm_prfx: Option<NamePrefix2Code>,
476    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
477    pub nm: Option<String>,
478    #[serde(rename = "PhneNb", skip_serializing_if = "Option::is_none")]
479    pub phne_nb: Option<String>,
480    #[serde(rename = "MobNb", skip_serializing_if = "Option::is_none")]
481    pub mob_nb: Option<String>,
482    #[serde(rename = "FaxNb", skip_serializing_if = "Option::is_none")]
483    pub fax_nb: Option<String>,
484    #[serde(rename = "EmailAdr", skip_serializing_if = "Option::is_none")]
485    pub email_adr: Option<String>,
486    #[serde(rename = "EmailPurp", skip_serializing_if = "Option::is_none")]
487    pub email_purp: Option<String>,
488    #[serde(rename = "JobTitl", skip_serializing_if = "Option::is_none")]
489    pub job_titl: Option<String>,
490    #[serde(rename = "Rspnsblty", skip_serializing_if = "Option::is_none")]
491    pub rspnsblty: Option<String>,
492    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
493    pub dept: Option<String>,
494    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
495    pub othr: Option<Vec<OtherContact1>>,
496    #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
497    pub prefrd_mtd: Option<PreferredContactMethod1Code>,
498}
499
500impl Contact4 {
501    pub fn validate(&self) -> Result<(), ValidationError> {
502        if let Some(ref val) = self.nm_prfx {
503            val.validate()?
504        }
505        if let Some(ref val) = self.nm {
506            if val.chars().count() < 1 {
507                return Err(ValidationError::new(
508                    1001,
509                    "nm is shorter than the minimum length of 1".to_string(),
510                ));
511            }
512            if val.chars().count() > 140 {
513                return Err(ValidationError::new(
514                    1002,
515                    "nm exceeds the maximum length of 140".to_string(),
516                ));
517            }
518        }
519        if let Some(ref val) = self.phne_nb {
520            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
521            if !pattern.is_match(val) {
522                return Err(ValidationError::new(
523                    1005,
524                    "phne_nb does not match the required pattern".to_string(),
525                ));
526            }
527        }
528        if let Some(ref val) = self.mob_nb {
529            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
530            if !pattern.is_match(val) {
531                return Err(ValidationError::new(
532                    1005,
533                    "mob_nb does not match the required pattern".to_string(),
534                ));
535            }
536        }
537        if let Some(ref val) = self.fax_nb {
538            let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
539            if !pattern.is_match(val) {
540                return Err(ValidationError::new(
541                    1005,
542                    "fax_nb does not match the required pattern".to_string(),
543                ));
544            }
545        }
546        if let Some(ref val) = self.email_adr {
547            if val.chars().count() < 1 {
548                return Err(ValidationError::new(
549                    1001,
550                    "email_adr is shorter than the minimum length of 1".to_string(),
551                ));
552            }
553            if val.chars().count() > 2048 {
554                return Err(ValidationError::new(
555                    1002,
556                    "email_adr exceeds the maximum length of 2048".to_string(),
557                ));
558            }
559        }
560        if let Some(ref val) = self.email_purp {
561            if val.chars().count() < 1 {
562                return Err(ValidationError::new(
563                    1001,
564                    "email_purp is shorter than the minimum length of 1".to_string(),
565                ));
566            }
567            if val.chars().count() > 35 {
568                return Err(ValidationError::new(
569                    1002,
570                    "email_purp exceeds the maximum length of 35".to_string(),
571                ));
572            }
573        }
574        if let Some(ref val) = self.job_titl {
575            if val.chars().count() < 1 {
576                return Err(ValidationError::new(
577                    1001,
578                    "job_titl is shorter than the minimum length of 1".to_string(),
579                ));
580            }
581            if val.chars().count() > 35 {
582                return Err(ValidationError::new(
583                    1002,
584                    "job_titl exceeds the maximum length of 35".to_string(),
585                ));
586            }
587        }
588        if let Some(ref val) = self.rspnsblty {
589            if val.chars().count() < 1 {
590                return Err(ValidationError::new(
591                    1001,
592                    "rspnsblty is shorter than the minimum length of 1".to_string(),
593                ));
594            }
595            if val.chars().count() > 35 {
596                return Err(ValidationError::new(
597                    1002,
598                    "rspnsblty exceeds the maximum length of 35".to_string(),
599                ));
600            }
601        }
602        if let Some(ref val) = self.dept {
603            if val.chars().count() < 1 {
604                return Err(ValidationError::new(
605                    1001,
606                    "dept is shorter than the minimum length of 1".to_string(),
607                ));
608            }
609            if val.chars().count() > 70 {
610                return Err(ValidationError::new(
611                    1002,
612                    "dept exceeds the maximum length of 70".to_string(),
613                ));
614            }
615        }
616        if let Some(ref vec) = self.othr {
617            for item in vec {
618                item.validate()?
619            }
620        }
621        if let Some(ref val) = self.prefrd_mtd {
622            val.validate()?
623        }
624        Ok(())
625    }
626}
627
628// CreditDebitCode ...
629#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
630pub enum CreditDebitCode {
631    #[default]
632    #[serde(rename = "CRDT")]
633    CodeCRDT,
634    #[serde(rename = "DBIT")]
635    CodeDBIT,
636}
637
638impl CreditDebitCode {
639    pub fn validate(&self) -> Result<(), ValidationError> {
640        Ok(())
641    }
642}
643
644// CreditorReferenceInformation2 ...
645#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
646pub struct CreditorReferenceInformation2 {
647    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
648    pub tp: Option<CreditorReferenceType2>,
649    #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
650    pub ref_attr: Option<String>,
651}
652
653impl CreditorReferenceInformation2 {
654    pub fn validate(&self) -> Result<(), ValidationError> {
655        if let Some(ref val) = self.tp {
656            val.validate()?
657        }
658        if let Some(ref val) = self.ref_attr {
659            if val.chars().count() < 1 {
660                return Err(ValidationError::new(
661                    1001,
662                    "ref_attr is shorter than the minimum length of 1".to_string(),
663                ));
664            }
665            if val.chars().count() > 35 {
666                return Err(ValidationError::new(
667                    1002,
668                    "ref_attr exceeds the maximum length of 35".to_string(),
669                ));
670            }
671        }
672        Ok(())
673    }
674}
675
676// CreditorReferenceType1Choice ...
677#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
678pub struct CreditorReferenceType1Choice {
679    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
680    pub cd: Option<DocumentType3Code>,
681    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
682    pub prtry: Option<String>,
683}
684
685impl CreditorReferenceType1Choice {
686    pub fn validate(&self) -> Result<(), ValidationError> {
687        if let Some(ref val) = self.cd {
688            val.validate()?
689        }
690        if let Some(ref val) = self.prtry {
691            if val.chars().count() < 1 {
692                return Err(ValidationError::new(
693                    1001,
694                    "prtry is shorter than the minimum length of 1".to_string(),
695                ));
696            }
697            if val.chars().count() > 35 {
698                return Err(ValidationError::new(
699                    1002,
700                    "prtry exceeds the maximum length of 35".to_string(),
701                ));
702            }
703        }
704        Ok(())
705    }
706}
707
708// CreditorReferenceType2 ...
709#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
710pub struct CreditorReferenceType2 {
711    #[serde(rename = "CdOrPrtry")]
712    pub cd_or_prtry: CreditorReferenceType1Choice,
713    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
714    pub issr: Option<String>,
715}
716
717impl CreditorReferenceType2 {
718    pub fn validate(&self) -> Result<(), ValidationError> {
719        self.cd_or_prtry.validate()?;
720        if let Some(ref val) = self.issr {
721            if val.chars().count() < 1 {
722                return Err(ValidationError::new(
723                    1001,
724                    "issr is shorter than the minimum length of 1".to_string(),
725                ));
726            }
727            if val.chars().count() > 35 {
728                return Err(ValidationError::new(
729                    1002,
730                    "issr exceeds the maximum length of 35".to_string(),
731                ));
732            }
733        }
734        Ok(())
735    }
736}
737
738// DateAndPlaceOfBirth1 ...
739#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
740pub struct DateAndPlaceOfBirth1 {
741    #[serde(rename = "BirthDt")]
742    pub birth_dt: String,
743    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
744    pub prvc_of_birth: Option<String>,
745    #[serde(rename = "CityOfBirth")]
746    pub city_of_birth: String,
747    #[serde(rename = "CtryOfBirth")]
748    pub ctry_of_birth: String,
749}
750
751impl DateAndPlaceOfBirth1 {
752    pub fn validate(&self) -> Result<(), ValidationError> {
753        if let Some(ref val) = self.prvc_of_birth {
754            if val.chars().count() < 1 {
755                return Err(ValidationError::new(
756                    1001,
757                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
758                ));
759            }
760            if val.chars().count() > 35 {
761                return Err(ValidationError::new(
762                    1002,
763                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
764                ));
765            }
766        }
767        if self.city_of_birth.chars().count() < 1 {
768            return Err(ValidationError::new(
769                1001,
770                "city_of_birth is shorter than the minimum length of 1".to_string(),
771            ));
772        }
773        if self.city_of_birth.chars().count() > 35 {
774            return Err(ValidationError::new(
775                1002,
776                "city_of_birth exceeds the maximum length of 35".to_string(),
777            ));
778        }
779        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
780        if !pattern.is_match(&self.ctry_of_birth) {
781            return Err(ValidationError::new(
782                1005,
783                "ctry_of_birth does not match the required pattern".to_string(),
784            ));
785        }
786        Ok(())
787    }
788}
789
790// DatePeriod2 ...
791#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
792pub struct DatePeriod2 {
793    #[serde(rename = "FrDt")]
794    pub fr_dt: String,
795    #[serde(rename = "ToDt")]
796    pub to_dt: String,
797}
798
799impl DatePeriod2 {
800    pub fn validate(&self) -> Result<(), ValidationError> {
801        Ok(())
802    }
803}
804
805// DiscountAmountAndType1 ...
806#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
807pub struct DiscountAmountAndType1 {
808    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
809    pub tp: Option<DiscountAmountType1Choice>,
810    #[serde(rename = "Amt")]
811    pub amt: ActiveOrHistoricCurrencyAndAmount,
812}
813
814impl DiscountAmountAndType1 {
815    pub fn validate(&self) -> Result<(), ValidationError> {
816        if let Some(ref val) = self.tp {
817            val.validate()?
818        }
819        self.amt.validate()?;
820        Ok(())
821    }
822}
823
824// DiscountAmountType1Choice ...
825#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
826pub struct DiscountAmountType1Choice {
827    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
828    pub cd: Option<String>,
829    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
830    pub prtry: Option<String>,
831}
832
833impl DiscountAmountType1Choice {
834    pub fn validate(&self) -> Result<(), ValidationError> {
835        if let Some(ref val) = self.cd {
836            if val.chars().count() < 1 {
837                return Err(ValidationError::new(
838                    1001,
839                    "cd is shorter than the minimum length of 1".to_string(),
840                ));
841            }
842            if val.chars().count() > 4 {
843                return Err(ValidationError::new(
844                    1002,
845                    "cd exceeds the maximum length of 4".to_string(),
846                ));
847            }
848        }
849        if let Some(ref val) = self.prtry {
850            if val.chars().count() < 1 {
851                return Err(ValidationError::new(
852                    1001,
853                    "prtry is shorter than the minimum length of 1".to_string(),
854                ));
855            }
856            if val.chars().count() > 35 {
857                return Err(ValidationError::new(
858                    1002,
859                    "prtry exceeds the maximum length of 35".to_string(),
860                ));
861            }
862        }
863        Ok(())
864    }
865}
866
867// DocumentAdjustment1 ...
868#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
869pub struct DocumentAdjustment1 {
870    #[serde(rename = "Amt")]
871    pub amt: ActiveOrHistoricCurrencyAndAmount,
872    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
873    pub cdt_dbt_ind: Option<CreditDebitCode>,
874    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
875    pub rsn: Option<String>,
876    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
877    pub addtl_inf: Option<String>,
878}
879
880impl DocumentAdjustment1 {
881    pub fn validate(&self) -> Result<(), ValidationError> {
882        self.amt.validate()?;
883        if let Some(ref val) = self.cdt_dbt_ind {
884            val.validate()?
885        }
886        if let Some(ref val) = self.rsn {
887            if val.chars().count() < 1 {
888                return Err(ValidationError::new(
889                    1001,
890                    "rsn is shorter than the minimum length of 1".to_string(),
891                ));
892            }
893            if val.chars().count() > 4 {
894                return Err(ValidationError::new(
895                    1002,
896                    "rsn exceeds the maximum length of 4".to_string(),
897                ));
898            }
899        }
900        if let Some(ref val) = self.addtl_inf {
901            if val.chars().count() < 1 {
902                return Err(ValidationError::new(
903                    1001,
904                    "addtl_inf is shorter than the minimum length of 1".to_string(),
905                ));
906            }
907            if val.chars().count() > 140 {
908                return Err(ValidationError::new(
909                    1002,
910                    "addtl_inf exceeds the maximum length of 140".to_string(),
911                ));
912            }
913        }
914        Ok(())
915    }
916}
917
918// DocumentLineIdentification1 ...
919#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
920pub struct DocumentLineIdentification1 {
921    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
922    pub tp: Option<DocumentLineType1>,
923    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
924    pub nb: Option<String>,
925    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
926    pub rltd_dt: Option<String>,
927}
928
929impl DocumentLineIdentification1 {
930    pub fn validate(&self) -> Result<(), ValidationError> {
931        if let Some(ref val) = self.tp {
932            val.validate()?
933        }
934        if let Some(ref val) = self.nb {
935            if val.chars().count() < 1 {
936                return Err(ValidationError::new(
937                    1001,
938                    "nb is shorter than the minimum length of 1".to_string(),
939                ));
940            }
941            if val.chars().count() > 35 {
942                return Err(ValidationError::new(
943                    1002,
944                    "nb exceeds the maximum length of 35".to_string(),
945                ));
946            }
947        }
948        Ok(())
949    }
950}
951
952// DocumentLineInformation1 ...
953#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
954pub struct DocumentLineInformation1 {
955    #[serde(rename = "Id")]
956    pub id: Vec<DocumentLineIdentification1>,
957    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
958    pub desc: Option<String>,
959    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
960    pub amt: Option<RemittanceAmount3>,
961}
962
963impl DocumentLineInformation1 {
964    pub fn validate(&self) -> Result<(), ValidationError> {
965        for item in &self.id {
966            item.validate()?
967        }
968        if let Some(ref val) = self.desc {
969            if val.chars().count() < 1 {
970                return Err(ValidationError::new(
971                    1001,
972                    "desc is shorter than the minimum length of 1".to_string(),
973                ));
974            }
975            if val.chars().count() > 2048 {
976                return Err(ValidationError::new(
977                    1002,
978                    "desc exceeds the maximum length of 2048".to_string(),
979                ));
980            }
981        }
982        if let Some(ref val) = self.amt {
983            val.validate()?
984        }
985        Ok(())
986    }
987}
988
989// DocumentLineType1 ...
990#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
991pub struct DocumentLineType1 {
992    #[serde(rename = "CdOrPrtry")]
993    pub cd_or_prtry: DocumentLineType1Choice,
994    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
995    pub issr: Option<String>,
996}
997
998impl DocumentLineType1 {
999    pub fn validate(&self) -> Result<(), ValidationError> {
1000        self.cd_or_prtry.validate()?;
1001        if let Some(ref val) = self.issr {
1002            if val.chars().count() < 1 {
1003                return Err(ValidationError::new(
1004                    1001,
1005                    "issr is shorter than the minimum length of 1".to_string(),
1006                ));
1007            }
1008            if val.chars().count() > 35 {
1009                return Err(ValidationError::new(
1010                    1002,
1011                    "issr exceeds the maximum length of 35".to_string(),
1012                ));
1013            }
1014        }
1015        Ok(())
1016    }
1017}
1018
1019// DocumentLineType1Choice ...
1020#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1021pub struct DocumentLineType1Choice {
1022    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1023    pub cd: Option<String>,
1024    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1025    pub prtry: Option<String>,
1026}
1027
1028impl DocumentLineType1Choice {
1029    pub fn validate(&self) -> Result<(), ValidationError> {
1030        if let Some(ref val) = self.cd {
1031            if val.chars().count() < 1 {
1032                return Err(ValidationError::new(
1033                    1001,
1034                    "cd is shorter than the minimum length of 1".to_string(),
1035                ));
1036            }
1037            if val.chars().count() > 4 {
1038                return Err(ValidationError::new(
1039                    1002,
1040                    "cd exceeds the maximum length of 4".to_string(),
1041                ));
1042            }
1043        }
1044        if let Some(ref val) = self.prtry {
1045            if val.chars().count() < 1 {
1046                return Err(ValidationError::new(
1047                    1001,
1048                    "prtry is shorter than the minimum length of 1".to_string(),
1049                ));
1050            }
1051            if val.chars().count() > 35 {
1052                return Err(ValidationError::new(
1053                    1002,
1054                    "prtry exceeds the maximum length of 35".to_string(),
1055                ));
1056            }
1057        }
1058        Ok(())
1059    }
1060}
1061
1062// DocumentType3Code ...
1063#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1064pub enum DocumentType3Code {
1065    #[default]
1066    #[serde(rename = "RADM")]
1067    CodeRADM,
1068    #[serde(rename = "RPIN")]
1069    CodeRPIN,
1070    #[serde(rename = "FXDR")]
1071    CodeFXDR,
1072    #[serde(rename = "DISP")]
1073    CodeDISP,
1074    #[serde(rename = "PUOR")]
1075    CodePUOR,
1076    #[serde(rename = "SCOR")]
1077    CodeSCOR,
1078}
1079
1080impl DocumentType3Code {
1081    pub fn validate(&self) -> Result<(), ValidationError> {
1082        Ok(())
1083    }
1084}
1085
1086// DocumentType6Code ...
1087#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1088pub enum DocumentType6Code {
1089    #[default]
1090    #[serde(rename = "MSIN")]
1091    CodeMSIN,
1092    #[serde(rename = "CNFA")]
1093    CodeCNFA,
1094    #[serde(rename = "DNFA")]
1095    CodeDNFA,
1096    #[serde(rename = "CINV")]
1097    CodeCINV,
1098    #[serde(rename = "CREN")]
1099    CodeCREN,
1100    #[serde(rename = "DEBN")]
1101    CodeDEBN,
1102    #[serde(rename = "HIRI")]
1103    CodeHIRI,
1104    #[serde(rename = "SBIN")]
1105    CodeSBIN,
1106    #[serde(rename = "CMCN")]
1107    CodeCMCN,
1108    #[serde(rename = "SOAC")]
1109    CodeSOAC,
1110    #[serde(rename = "DISP")]
1111    CodeDISP,
1112    #[serde(rename = "BOLD")]
1113    CodeBOLD,
1114    #[serde(rename = "VCHR")]
1115    CodeVCHR,
1116    #[serde(rename = "AROI")]
1117    CodeAROI,
1118    #[serde(rename = "TSUT")]
1119    CodeTSUT,
1120    #[serde(rename = "PUOR")]
1121    CodePUOR,
1122}
1123
1124impl DocumentType6Code {
1125    pub fn validate(&self) -> Result<(), ValidationError> {
1126        Ok(())
1127    }
1128}
1129
1130// FinancialIdentificationSchemeName1Choice ...
1131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1132pub struct FinancialIdentificationSchemeName1Choice {
1133    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1134    pub cd: Option<String>,
1135    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1136    pub prtry: Option<String>,
1137}
1138
1139impl FinancialIdentificationSchemeName1Choice {
1140    pub fn validate(&self) -> Result<(), ValidationError> {
1141        if let Some(ref val) = self.cd {
1142            if val.chars().count() < 1 {
1143                return Err(ValidationError::new(
1144                    1001,
1145                    "cd is shorter than the minimum length of 1".to_string(),
1146                ));
1147            }
1148            if val.chars().count() > 4 {
1149                return Err(ValidationError::new(
1150                    1002,
1151                    "cd exceeds the maximum length of 4".to_string(),
1152                ));
1153            }
1154        }
1155        if let Some(ref val) = self.prtry {
1156            if val.chars().count() < 1 {
1157                return Err(ValidationError::new(
1158                    1001,
1159                    "prtry is shorter than the minimum length of 1".to_string(),
1160                ));
1161            }
1162            if val.chars().count() > 35 {
1163                return Err(ValidationError::new(
1164                    1002,
1165                    "prtry exceeds the maximum length of 35".to_string(),
1166                ));
1167            }
1168        }
1169        Ok(())
1170    }
1171}
1172
1173// FinancialInstitutionIdentification18 ...
1174#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1175pub struct FinancialInstitutionIdentification18 {
1176    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1177    pub bicfi: Option<String>,
1178    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1179    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification2>,
1180    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1181    pub lei: Option<String>,
1182    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1183    pub nm: Option<String>,
1184    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1185    pub pstl_adr: Option<PostalAddress24>,
1186    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1187    pub othr: Option<GenericFinancialIdentification1>,
1188}
1189
1190impl FinancialInstitutionIdentification18 {
1191    pub fn validate(&self) -> Result<(), ValidationError> {
1192        if let Some(ref val) = self.bicfi {
1193            let pattern =
1194                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1195            if !pattern.is_match(val) {
1196                return Err(ValidationError::new(
1197                    1005,
1198                    "bicfi does not match the required pattern".to_string(),
1199                ));
1200            }
1201        }
1202        if let Some(ref val) = self.clr_sys_mmb_id {
1203            val.validate()?
1204        }
1205        if let Some(ref val) = self.lei {
1206            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1207            if !pattern.is_match(val) {
1208                return Err(ValidationError::new(
1209                    1005,
1210                    "lei does not match the required pattern".to_string(),
1211                ));
1212            }
1213        }
1214        if let Some(ref val) = self.nm {
1215            if val.chars().count() < 1 {
1216                return Err(ValidationError::new(
1217                    1001,
1218                    "nm is shorter than the minimum length of 1".to_string(),
1219                ));
1220            }
1221            if val.chars().count() > 140 {
1222                return Err(ValidationError::new(
1223                    1002,
1224                    "nm exceeds the maximum length of 140".to_string(),
1225                ));
1226            }
1227        }
1228        if let Some(ref val) = self.pstl_adr {
1229            val.validate()?
1230        }
1231        if let Some(ref val) = self.othr {
1232            val.validate()?
1233        }
1234        Ok(())
1235    }
1236}
1237
1238// Garnishment3 ...
1239#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1240pub struct Garnishment3 {
1241    #[serde(rename = "Tp")]
1242    pub tp: GarnishmentType1,
1243    #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
1244    pub grnshee: Option<PartyIdentification135>,
1245    #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
1246    pub grnshmt_admstr: Option<PartyIdentification135>,
1247    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
1248    pub ref_nb: Option<String>,
1249    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
1250    pub dt: Option<String>,
1251    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
1252    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1253    #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
1254    pub fmly_mdcl_insrnc_ind: Option<bool>,
1255    #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
1256    pub mplyee_termntn_ind: Option<bool>,
1257}
1258
1259impl Garnishment3 {
1260    pub fn validate(&self) -> Result<(), ValidationError> {
1261        self.tp.validate()?;
1262        if let Some(ref val) = self.grnshee {
1263            val.validate()?
1264        }
1265        if let Some(ref val) = self.grnshmt_admstr {
1266            val.validate()?
1267        }
1268        if let Some(ref val) = self.ref_nb {
1269            if val.chars().count() < 1 {
1270                return Err(ValidationError::new(
1271                    1001,
1272                    "ref_nb is shorter than the minimum length of 1".to_string(),
1273                ));
1274            }
1275            if val.chars().count() > 140 {
1276                return Err(ValidationError::new(
1277                    1002,
1278                    "ref_nb exceeds the maximum length of 140".to_string(),
1279                ));
1280            }
1281        }
1282        if let Some(ref val) = self.rmtd_amt {
1283            val.validate()?
1284        }
1285        Ok(())
1286    }
1287}
1288
1289// GarnishmentType1 ...
1290#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1291pub struct GarnishmentType1 {
1292    #[serde(rename = "CdOrPrtry")]
1293    pub cd_or_prtry: GarnishmentType1Choice,
1294    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1295    pub issr: Option<String>,
1296}
1297
1298impl GarnishmentType1 {
1299    pub fn validate(&self) -> Result<(), ValidationError> {
1300        self.cd_or_prtry.validate()?;
1301        if let Some(ref val) = self.issr {
1302            if val.chars().count() < 1 {
1303                return Err(ValidationError::new(
1304                    1001,
1305                    "issr is shorter than the minimum length of 1".to_string(),
1306                ));
1307            }
1308            if val.chars().count() > 35 {
1309                return Err(ValidationError::new(
1310                    1002,
1311                    "issr exceeds the maximum length of 35".to_string(),
1312                ));
1313            }
1314        }
1315        Ok(())
1316    }
1317}
1318
1319// GarnishmentType1Choice ...
1320#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1321pub struct GarnishmentType1Choice {
1322    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1323    pub cd: Option<String>,
1324    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1325    pub prtry: Option<String>,
1326}
1327
1328impl GarnishmentType1Choice {
1329    pub fn validate(&self) -> Result<(), ValidationError> {
1330        if let Some(ref val) = self.cd {
1331            if val.chars().count() < 1 {
1332                return Err(ValidationError::new(
1333                    1001,
1334                    "cd is shorter than the minimum length of 1".to_string(),
1335                ));
1336            }
1337            if val.chars().count() > 4 {
1338                return Err(ValidationError::new(
1339                    1002,
1340                    "cd exceeds the maximum length of 4".to_string(),
1341                ));
1342            }
1343        }
1344        if let Some(ref val) = self.prtry {
1345            if val.chars().count() < 1 {
1346                return Err(ValidationError::new(
1347                    1001,
1348                    "prtry is shorter than the minimum length of 1".to_string(),
1349                ));
1350            }
1351            if val.chars().count() > 35 {
1352                return Err(ValidationError::new(
1353                    1002,
1354                    "prtry exceeds the maximum length of 35".to_string(),
1355                ));
1356            }
1357        }
1358        Ok(())
1359    }
1360}
1361
1362// GenericAccountIdentification1 ...
1363#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1364pub struct GenericAccountIdentification1 {
1365    #[serde(rename = "Id")]
1366    pub id: String,
1367    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1368    pub schme_nm: Option<AccountSchemeName1Choice>,
1369    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1370    pub issr: Option<String>,
1371}
1372
1373impl GenericAccountIdentification1 {
1374    pub fn validate(&self) -> Result<(), ValidationError> {
1375        if self.id.chars().count() < 1 {
1376            return Err(ValidationError::new(
1377                1001,
1378                "id is shorter than the minimum length of 1".to_string(),
1379            ));
1380        }
1381        if self.id.chars().count() > 34 {
1382            return Err(ValidationError::new(
1383                1002,
1384                "id exceeds the maximum length of 34".to_string(),
1385            ));
1386        }
1387        if let Some(ref val) = self.schme_nm {
1388            val.validate()?
1389        }
1390        if let Some(ref val) = self.issr {
1391            if val.chars().count() < 1 {
1392                return Err(ValidationError::new(
1393                    1001,
1394                    "issr is shorter than the minimum length of 1".to_string(),
1395                ));
1396            }
1397            if val.chars().count() > 35 {
1398                return Err(ValidationError::new(
1399                    1002,
1400                    "issr exceeds the maximum length of 35".to_string(),
1401                ));
1402            }
1403        }
1404        Ok(())
1405    }
1406}
1407
1408// GenericFinancialIdentification1 ...
1409#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1410pub struct GenericFinancialIdentification1 {
1411    #[serde(rename = "Id")]
1412    pub id: String,
1413    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1414    pub schme_nm: Option<FinancialIdentificationSchemeName1Choice>,
1415    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1416    pub issr: Option<String>,
1417}
1418
1419impl GenericFinancialIdentification1 {
1420    pub fn validate(&self) -> Result<(), ValidationError> {
1421        if self.id.chars().count() < 1 {
1422            return Err(ValidationError::new(
1423                1001,
1424                "id is shorter than the minimum length of 1".to_string(),
1425            ));
1426        }
1427        if self.id.chars().count() > 35 {
1428            return Err(ValidationError::new(
1429                1002,
1430                "id exceeds the maximum length of 35".to_string(),
1431            ));
1432        }
1433        if let Some(ref val) = self.schme_nm {
1434            val.validate()?
1435        }
1436        if let Some(ref val) = self.issr {
1437            if val.chars().count() < 1 {
1438                return Err(ValidationError::new(
1439                    1001,
1440                    "issr is shorter than the minimum length of 1".to_string(),
1441                ));
1442            }
1443            if val.chars().count() > 35 {
1444                return Err(ValidationError::new(
1445                    1002,
1446                    "issr exceeds the maximum length of 35".to_string(),
1447                ));
1448            }
1449        }
1450        Ok(())
1451    }
1452}
1453
1454// GenericIdentification30 ...
1455#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1456pub struct GenericIdentification30 {
1457    #[serde(rename = "Id")]
1458    pub id: String,
1459    #[serde(rename = "Issr")]
1460    pub issr: String,
1461    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1462    pub schme_nm: Option<String>,
1463}
1464
1465impl GenericIdentification30 {
1466    pub fn validate(&self) -> Result<(), ValidationError> {
1467        let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
1468        if !pattern.is_match(&self.id) {
1469            return Err(ValidationError::new(
1470                1005,
1471                "id does not match the required pattern".to_string(),
1472            ));
1473        }
1474        if self.issr.chars().count() < 1 {
1475            return Err(ValidationError::new(
1476                1001,
1477                "issr is shorter than the minimum length of 1".to_string(),
1478            ));
1479        }
1480        if self.issr.chars().count() > 35 {
1481            return Err(ValidationError::new(
1482                1002,
1483                "issr exceeds the maximum length of 35".to_string(),
1484            ));
1485        }
1486        if let Some(ref val) = self.schme_nm {
1487            if val.chars().count() < 1 {
1488                return Err(ValidationError::new(
1489                    1001,
1490                    "schme_nm is shorter than the minimum length of 1".to_string(),
1491                ));
1492            }
1493            if val.chars().count() > 35 {
1494                return Err(ValidationError::new(
1495                    1002,
1496                    "schme_nm exceeds the maximum length of 35".to_string(),
1497                ));
1498            }
1499        }
1500        Ok(())
1501    }
1502}
1503
1504// GenericOrganisationIdentification1 ...
1505#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1506pub struct GenericOrganisationIdentification1 {
1507    #[serde(rename = "Id")]
1508    pub id: String,
1509    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1510    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
1511    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1512    pub issr: Option<String>,
1513}
1514
1515impl GenericOrganisationIdentification1 {
1516    pub fn validate(&self) -> Result<(), ValidationError> {
1517        if self.id.chars().count() < 1 {
1518            return Err(ValidationError::new(
1519                1001,
1520                "id is shorter than the minimum length of 1".to_string(),
1521            ));
1522        }
1523        if self.id.chars().count() > 35 {
1524            return Err(ValidationError::new(
1525                1002,
1526                "id exceeds the maximum length of 35".to_string(),
1527            ));
1528        }
1529        if let Some(ref val) = self.schme_nm {
1530            val.validate()?
1531        }
1532        if let Some(ref val) = self.issr {
1533            if val.chars().count() < 1 {
1534                return Err(ValidationError::new(
1535                    1001,
1536                    "issr is shorter than the minimum length of 1".to_string(),
1537                ));
1538            }
1539            if val.chars().count() > 35 {
1540                return Err(ValidationError::new(
1541                    1002,
1542                    "issr exceeds the maximum length of 35".to_string(),
1543                ));
1544            }
1545        }
1546        Ok(())
1547    }
1548}
1549
1550// GenericPersonIdentification1 ...
1551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1552pub struct GenericPersonIdentification1 {
1553    #[serde(rename = "Id")]
1554    pub id: String,
1555    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1556    pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
1557    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1558    pub issr: Option<String>,
1559}
1560
1561impl GenericPersonIdentification1 {
1562    pub fn validate(&self) -> Result<(), ValidationError> {
1563        if self.id.chars().count() < 1 {
1564            return Err(ValidationError::new(
1565                1001,
1566                "id is shorter than the minimum length of 1".to_string(),
1567            ));
1568        }
1569        if self.id.chars().count() > 35 {
1570            return Err(ValidationError::new(
1571                1002,
1572                "id exceeds the maximum length of 35".to_string(),
1573            ));
1574        }
1575        if let Some(ref val) = self.schme_nm {
1576            val.validate()?
1577        }
1578        if let Some(ref val) = self.issr {
1579            if val.chars().count() < 1 {
1580                return Err(ValidationError::new(
1581                    1001,
1582                    "issr is shorter than the minimum length of 1".to_string(),
1583                ));
1584            }
1585            if val.chars().count() > 35 {
1586                return Err(ValidationError::new(
1587                    1002,
1588                    "issr exceeds the maximum length of 35".to_string(),
1589                ));
1590            }
1591        }
1592        Ok(())
1593    }
1594}
1595
1596// GroupHeader77 ...
1597#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1598pub struct GroupHeader77 {
1599    #[serde(rename = "MsgId")]
1600    pub msg_id: String,
1601    #[serde(rename = "CreDtTm")]
1602    pub cre_dt_tm: String,
1603    #[serde(rename = "MsgSndr", skip_serializing_if = "Option::is_none")]
1604    pub msg_sndr: Option<Party40Choice>,
1605}
1606
1607impl GroupHeader77 {
1608    pub fn validate(&self) -> Result<(), ValidationError> {
1609        if self.msg_id.chars().count() < 1 {
1610            return Err(ValidationError::new(
1611                1001,
1612                "msg_id is shorter than the minimum length of 1".to_string(),
1613            ));
1614        }
1615        if self.msg_id.chars().count() > 35 {
1616            return Err(ValidationError::new(
1617                1002,
1618                "msg_id exceeds the maximum length of 35".to_string(),
1619            ));
1620        }
1621        if let Some(ref val) = self.msg_sndr {
1622            val.validate()?
1623        }
1624        Ok(())
1625    }
1626}
1627
1628// NameAndAddress16 ...
1629#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1630pub struct NameAndAddress16 {
1631    #[serde(rename = "Nm")]
1632    pub nm: String,
1633    #[serde(rename = "Adr")]
1634    pub adr: PostalAddress24,
1635}
1636
1637impl NameAndAddress16 {
1638    pub fn validate(&self) -> Result<(), ValidationError> {
1639        if self.nm.chars().count() < 1 {
1640            return Err(ValidationError::new(
1641                1001,
1642                "nm is shorter than the minimum length of 1".to_string(),
1643            ));
1644        }
1645        if self.nm.chars().count() > 140 {
1646            return Err(ValidationError::new(
1647                1002,
1648                "nm exceeds the maximum length of 140".to_string(),
1649            ));
1650        }
1651        self.adr.validate()?;
1652        Ok(())
1653    }
1654}
1655
1656// NamePrefix2Code ...
1657#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1658pub enum NamePrefix2Code {
1659    #[default]
1660    #[serde(rename = "DOCT")]
1661    CodeDOCT,
1662    #[serde(rename = "MADM")]
1663    CodeMADM,
1664    #[serde(rename = "MISS")]
1665    CodeMISS,
1666    #[serde(rename = "MIST")]
1667    CodeMIST,
1668    #[serde(rename = "MIKS")]
1669    CodeMIKS,
1670}
1671
1672impl NamePrefix2Code {
1673    pub fn validate(&self) -> Result<(), ValidationError> {
1674        Ok(())
1675    }
1676}
1677
1678// NotificationItem7 ...
1679#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1680pub struct NotificationItem7 {
1681    #[serde(rename = "Id")]
1682    pub id: String,
1683    #[serde(rename = "EndToEndId", skip_serializing_if = "Option::is_none")]
1684    pub end_to_end_id: Option<String>,
1685    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
1686    pub uetr: Option<String>,
1687    #[serde(rename = "Acct", skip_serializing_if = "Option::is_none")]
1688    pub acct: Option<CashAccount38>,
1689    #[serde(rename = "AcctOwnr", skip_serializing_if = "Option::is_none")]
1690    pub acct_ownr: Option<Party40Choice>,
1691    #[serde(rename = "AcctSvcr", skip_serializing_if = "Option::is_none")]
1692    pub acct_svcr: Option<BranchAndFinancialInstitutionIdentification6>,
1693    #[serde(rename = "RltdAcct", skip_serializing_if = "Option::is_none")]
1694    pub rltd_acct: Option<CashAccount38>,
1695    #[serde(rename = "Amt")]
1696    pub amt: ActiveOrHistoricCurrencyAndAmount,
1697    #[serde(rename = "XpctdValDt", skip_serializing_if = "Option::is_none")]
1698    pub xpctd_val_dt: Option<String>,
1699    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
1700    pub dbtr: Option<Party40Choice>,
1701    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
1702    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification6>,
1703    #[serde(rename = "IntrmyAgt", skip_serializing_if = "Option::is_none")]
1704    pub intrmy_agt: Option<BranchAndFinancialInstitutionIdentification6>,
1705    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
1706    pub purp: Option<Purpose2Choice>,
1707    #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
1708    pub rltd_rmt_inf: Option<RemittanceLocation7>,
1709    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
1710    pub rmt_inf: Option<RemittanceInformation16>,
1711}
1712
1713impl NotificationItem7 {
1714    pub fn validate(&self) -> Result<(), ValidationError> {
1715        if self.id.chars().count() < 1 {
1716            return Err(ValidationError::new(
1717                1001,
1718                "id is shorter than the minimum length of 1".to_string(),
1719            ));
1720        }
1721        if self.id.chars().count() > 35 {
1722            return Err(ValidationError::new(
1723                1002,
1724                "id exceeds the maximum length of 35".to_string(),
1725            ));
1726        }
1727        if let Some(ref val) = self.end_to_end_id {
1728            if val.chars().count() < 1 {
1729                return Err(ValidationError::new(
1730                    1001,
1731                    "end_to_end_id is shorter than the minimum length of 1".to_string(),
1732                ));
1733            }
1734            if val.chars().count() > 35 {
1735                return Err(ValidationError::new(
1736                    1002,
1737                    "end_to_end_id exceeds the maximum length of 35".to_string(),
1738                ));
1739            }
1740        }
1741        if let Some(ref val) = self.uetr {
1742            let pattern =
1743                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
1744                    .unwrap();
1745            if !pattern.is_match(val) {
1746                return Err(ValidationError::new(
1747                    1005,
1748                    "uetr does not match the required pattern".to_string(),
1749                ));
1750            }
1751        }
1752        if let Some(ref val) = self.acct {
1753            val.validate()?
1754        }
1755        if let Some(ref val) = self.acct_ownr {
1756            val.validate()?
1757        }
1758        if let Some(ref val) = self.acct_svcr {
1759            val.validate()?
1760        }
1761        if let Some(ref val) = self.rltd_acct {
1762            val.validate()?
1763        }
1764        self.amt.validate()?;
1765        if let Some(ref val) = self.dbtr {
1766            val.validate()?
1767        }
1768        if let Some(ref val) = self.dbtr_agt {
1769            val.validate()?
1770        }
1771        if let Some(ref val) = self.intrmy_agt {
1772            val.validate()?
1773        }
1774        if let Some(ref val) = self.purp {
1775            val.validate()?
1776        }
1777        if let Some(ref val) = self.rltd_rmt_inf {
1778            val.validate()?
1779        }
1780        if let Some(ref val) = self.rmt_inf {
1781            val.validate()?
1782        }
1783        Ok(())
1784    }
1785}
1786
1787// NotificationToReceiveV06 ...
1788#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1789pub struct NotificationToReceiveV06 {
1790    #[serde(rename = "GrpHdr")]
1791    pub grp_hdr: GroupHeader77,
1792    #[serde(rename = "Ntfctn")]
1793    pub ntfctn: AccountNotification16,
1794    #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
1795    pub splmtry_data: Option<Vec<SupplementaryData1>>,
1796}
1797
1798impl NotificationToReceiveV06 {
1799    pub fn validate(&self) -> Result<(), ValidationError> {
1800        self.grp_hdr.validate()?;
1801        self.ntfctn.validate()?;
1802        if let Some(ref vec) = self.splmtry_data {
1803            for item in vec {
1804                item.validate()?
1805            }
1806        }
1807        Ok(())
1808    }
1809}
1810
1811// OrganisationIdentification29 ...
1812#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1813pub struct OrganisationIdentification29 {
1814    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
1815    pub any_bic: Option<String>,
1816    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1817    pub lei: Option<String>,
1818    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1819    pub othr: Option<Vec<GenericOrganisationIdentification1>>,
1820}
1821
1822impl OrganisationIdentification29 {
1823    pub fn validate(&self) -> Result<(), ValidationError> {
1824        if let Some(ref val) = self.any_bic {
1825            let pattern =
1826                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1827            if !pattern.is_match(val) {
1828                return Err(ValidationError::new(
1829                    1005,
1830                    "any_bic does not match the required pattern".to_string(),
1831                ));
1832            }
1833        }
1834        if let Some(ref val) = self.lei {
1835            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1836            if !pattern.is_match(val) {
1837                return Err(ValidationError::new(
1838                    1005,
1839                    "lei does not match the required pattern".to_string(),
1840                ));
1841            }
1842        }
1843        if let Some(ref vec) = self.othr {
1844            for item in vec {
1845                item.validate()?
1846            }
1847        }
1848        Ok(())
1849    }
1850}
1851
1852// OrganisationIdentificationSchemeName1Choice ...
1853#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1854pub struct OrganisationIdentificationSchemeName1Choice {
1855    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1856    pub cd: Option<String>,
1857    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1858    pub prtry: Option<String>,
1859}
1860
1861impl OrganisationIdentificationSchemeName1Choice {
1862    pub fn validate(&self) -> Result<(), ValidationError> {
1863        if let Some(ref val) = self.cd {
1864            if val.chars().count() < 1 {
1865                return Err(ValidationError::new(
1866                    1001,
1867                    "cd is shorter than the minimum length of 1".to_string(),
1868                ));
1869            }
1870            if val.chars().count() > 4 {
1871                return Err(ValidationError::new(
1872                    1002,
1873                    "cd exceeds the maximum length of 4".to_string(),
1874                ));
1875            }
1876        }
1877        if let Some(ref val) = self.prtry {
1878            if val.chars().count() < 1 {
1879                return Err(ValidationError::new(
1880                    1001,
1881                    "prtry is shorter than the minimum length of 1".to_string(),
1882                ));
1883            }
1884            if val.chars().count() > 35 {
1885                return Err(ValidationError::new(
1886                    1002,
1887                    "prtry exceeds the maximum length of 35".to_string(),
1888                ));
1889            }
1890        }
1891        Ok(())
1892    }
1893}
1894
1895// OtherContact1 ...
1896#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1897pub struct OtherContact1 {
1898    #[serde(rename = "ChanlTp")]
1899    pub chanl_tp: String,
1900    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1901    pub id: Option<String>,
1902}
1903
1904impl OtherContact1 {
1905    pub fn validate(&self) -> Result<(), ValidationError> {
1906        if self.chanl_tp.chars().count() < 1 {
1907            return Err(ValidationError::new(
1908                1001,
1909                "chanl_tp is shorter than the minimum length of 1".to_string(),
1910            ));
1911        }
1912        if self.chanl_tp.chars().count() > 4 {
1913            return Err(ValidationError::new(
1914                1002,
1915                "chanl_tp exceeds the maximum length of 4".to_string(),
1916            ));
1917        }
1918        if let Some(ref val) = self.id {
1919            if val.chars().count() < 1 {
1920                return Err(ValidationError::new(
1921                    1001,
1922                    "id is shorter than the minimum length of 1".to_string(),
1923                ));
1924            }
1925            if val.chars().count() > 128 {
1926                return Err(ValidationError::new(
1927                    1002,
1928                    "id exceeds the maximum length of 128".to_string(),
1929                ));
1930            }
1931        }
1932        Ok(())
1933    }
1934}
1935
1936// Party38Choice ...
1937#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1938pub struct Party38Choice {
1939    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
1940    pub org_id: Option<OrganisationIdentification29>,
1941    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
1942    pub prvt_id: Option<PersonIdentification13>,
1943}
1944
1945impl Party38Choice {
1946    pub fn validate(&self) -> Result<(), ValidationError> {
1947        if let Some(ref val) = self.org_id {
1948            val.validate()?
1949        }
1950        if let Some(ref val) = self.prvt_id {
1951            val.validate()?
1952        }
1953        Ok(())
1954    }
1955}
1956
1957// Party40Choice ...
1958#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1959pub struct Party40Choice {
1960    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
1961    pub pty: Option<PartyIdentification135>,
1962    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
1963    pub agt: Option<BranchAndFinancialInstitutionIdentification6>,
1964}
1965
1966impl Party40Choice {
1967    pub fn validate(&self) -> Result<(), ValidationError> {
1968        if let Some(ref val) = self.pty {
1969            val.validate()?
1970        }
1971        if let Some(ref val) = self.agt {
1972            val.validate()?
1973        }
1974        Ok(())
1975    }
1976}
1977
1978// PartyIdentification135 ...
1979#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1980pub struct PartyIdentification135 {
1981    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1982    pub nm: Option<String>,
1983    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1984    pub pstl_adr: Option<PostalAddress24>,
1985    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1986    pub id: Option<Party38Choice>,
1987    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
1988    pub ctry_of_res: Option<String>,
1989    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
1990    pub ctct_dtls: Option<Contact4>,
1991}
1992
1993impl PartyIdentification135 {
1994    pub fn validate(&self) -> Result<(), ValidationError> {
1995        if let Some(ref val) = self.nm {
1996            if val.chars().count() < 1 {
1997                return Err(ValidationError::new(
1998                    1001,
1999                    "nm is shorter than the minimum length of 1".to_string(),
2000                ));
2001            }
2002            if val.chars().count() > 140 {
2003                return Err(ValidationError::new(
2004                    1002,
2005                    "nm exceeds the maximum length of 140".to_string(),
2006                ));
2007            }
2008        }
2009        if let Some(ref val) = self.pstl_adr {
2010            val.validate()?
2011        }
2012        if let Some(ref val) = self.id {
2013            val.validate()?
2014        }
2015        if let Some(ref val) = self.ctry_of_res {
2016            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2017            if !pattern.is_match(val) {
2018                return Err(ValidationError::new(
2019                    1005,
2020                    "ctry_of_res does not match the required pattern".to_string(),
2021                ));
2022            }
2023        }
2024        if let Some(ref val) = self.ctct_dtls {
2025            val.validate()?
2026        }
2027        Ok(())
2028    }
2029}
2030
2031// PersonIdentification13 ...
2032#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2033pub struct PersonIdentification13 {
2034    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
2035    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
2036    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2037    pub othr: Option<Vec<GenericPersonIdentification1>>,
2038}
2039
2040impl PersonIdentification13 {
2041    pub fn validate(&self) -> Result<(), ValidationError> {
2042        if let Some(ref val) = self.dt_and_plc_of_birth {
2043            val.validate()?
2044        }
2045        if let Some(ref vec) = self.othr {
2046            for item in vec {
2047                item.validate()?
2048            }
2049        }
2050        Ok(())
2051    }
2052}
2053
2054// PersonIdentificationSchemeName1Choice ...
2055#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2056pub struct PersonIdentificationSchemeName1Choice {
2057    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2058    pub cd: Option<String>,
2059    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2060    pub prtry: Option<String>,
2061}
2062
2063impl PersonIdentificationSchemeName1Choice {
2064    pub fn validate(&self) -> Result<(), ValidationError> {
2065        if let Some(ref val) = self.cd {
2066            if val.chars().count() < 1 {
2067                return Err(ValidationError::new(
2068                    1001,
2069                    "cd is shorter than the minimum length of 1".to_string(),
2070                ));
2071            }
2072            if val.chars().count() > 4 {
2073                return Err(ValidationError::new(
2074                    1002,
2075                    "cd exceeds the maximum length of 4".to_string(),
2076                ));
2077            }
2078        }
2079        if let Some(ref val) = self.prtry {
2080            if val.chars().count() < 1 {
2081                return Err(ValidationError::new(
2082                    1001,
2083                    "prtry is shorter than the minimum length of 1".to_string(),
2084                ));
2085            }
2086            if val.chars().count() > 35 {
2087                return Err(ValidationError::new(
2088                    1002,
2089                    "prtry exceeds the maximum length of 35".to_string(),
2090                ));
2091            }
2092        }
2093        Ok(())
2094    }
2095}
2096
2097// PostalAddress24 ...
2098#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2099pub struct PostalAddress24 {
2100    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
2101    pub adr_tp: Option<AddressType3Choice>,
2102    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
2103    pub dept: Option<String>,
2104    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
2105    pub sub_dept: Option<String>,
2106    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
2107    pub strt_nm: Option<String>,
2108    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
2109    pub bldg_nb: Option<String>,
2110    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
2111    pub bldg_nm: Option<String>,
2112    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
2113    pub flr: Option<String>,
2114    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
2115    pub pst_bx: Option<String>,
2116    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
2117    pub room: Option<String>,
2118    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
2119    pub pst_cd: Option<String>,
2120    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
2121    pub twn_nm: Option<String>,
2122    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
2123    pub twn_lctn_nm: Option<String>,
2124    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
2125    pub dstrct_nm: Option<String>,
2126    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
2127    pub ctry_sub_dvsn: Option<String>,
2128    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
2129    pub ctry: Option<String>,
2130    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
2131    pub adr_line: Option<Vec<String>>,
2132}
2133
2134impl PostalAddress24 {
2135    pub fn validate(&self) -> Result<(), ValidationError> {
2136        if let Some(ref val) = self.adr_tp {
2137            val.validate()?
2138        }
2139        if let Some(ref val) = self.dept {
2140            if val.chars().count() < 1 {
2141                return Err(ValidationError::new(
2142                    1001,
2143                    "dept is shorter than the minimum length of 1".to_string(),
2144                ));
2145            }
2146            if val.chars().count() > 70 {
2147                return Err(ValidationError::new(
2148                    1002,
2149                    "dept exceeds the maximum length of 70".to_string(),
2150                ));
2151            }
2152        }
2153        if let Some(ref val) = self.sub_dept {
2154            if val.chars().count() < 1 {
2155                return Err(ValidationError::new(
2156                    1001,
2157                    "sub_dept is shorter than the minimum length of 1".to_string(),
2158                ));
2159            }
2160            if val.chars().count() > 70 {
2161                return Err(ValidationError::new(
2162                    1002,
2163                    "sub_dept exceeds the maximum length of 70".to_string(),
2164                ));
2165            }
2166        }
2167        if let Some(ref val) = self.strt_nm {
2168            if val.chars().count() < 1 {
2169                return Err(ValidationError::new(
2170                    1001,
2171                    "strt_nm is shorter than the minimum length of 1".to_string(),
2172                ));
2173            }
2174            if val.chars().count() > 70 {
2175                return Err(ValidationError::new(
2176                    1002,
2177                    "strt_nm exceeds the maximum length of 70".to_string(),
2178                ));
2179            }
2180        }
2181        if let Some(ref val) = self.bldg_nb {
2182            if val.chars().count() < 1 {
2183                return Err(ValidationError::new(
2184                    1001,
2185                    "bldg_nb is shorter than the minimum length of 1".to_string(),
2186                ));
2187            }
2188            if val.chars().count() > 16 {
2189                return Err(ValidationError::new(
2190                    1002,
2191                    "bldg_nb exceeds the maximum length of 16".to_string(),
2192                ));
2193            }
2194        }
2195        if let Some(ref val) = self.bldg_nm {
2196            if val.chars().count() < 1 {
2197                return Err(ValidationError::new(
2198                    1001,
2199                    "bldg_nm is shorter than the minimum length of 1".to_string(),
2200                ));
2201            }
2202            if val.chars().count() > 35 {
2203                return Err(ValidationError::new(
2204                    1002,
2205                    "bldg_nm exceeds the maximum length of 35".to_string(),
2206                ));
2207            }
2208        }
2209        if let Some(ref val) = self.flr {
2210            if val.chars().count() < 1 {
2211                return Err(ValidationError::new(
2212                    1001,
2213                    "flr is shorter than the minimum length of 1".to_string(),
2214                ));
2215            }
2216            if val.chars().count() > 70 {
2217                return Err(ValidationError::new(
2218                    1002,
2219                    "flr exceeds the maximum length of 70".to_string(),
2220                ));
2221            }
2222        }
2223        if let Some(ref val) = self.pst_bx {
2224            if val.chars().count() < 1 {
2225                return Err(ValidationError::new(
2226                    1001,
2227                    "pst_bx is shorter than the minimum length of 1".to_string(),
2228                ));
2229            }
2230            if val.chars().count() > 16 {
2231                return Err(ValidationError::new(
2232                    1002,
2233                    "pst_bx exceeds the maximum length of 16".to_string(),
2234                ));
2235            }
2236        }
2237        if let Some(ref val) = self.room {
2238            if val.chars().count() < 1 {
2239                return Err(ValidationError::new(
2240                    1001,
2241                    "room is shorter than the minimum length of 1".to_string(),
2242                ));
2243            }
2244            if val.chars().count() > 70 {
2245                return Err(ValidationError::new(
2246                    1002,
2247                    "room exceeds the maximum length of 70".to_string(),
2248                ));
2249            }
2250        }
2251        if let Some(ref val) = self.pst_cd {
2252            if val.chars().count() < 1 {
2253                return Err(ValidationError::new(
2254                    1001,
2255                    "pst_cd is shorter than the minimum length of 1".to_string(),
2256                ));
2257            }
2258            if val.chars().count() > 16 {
2259                return Err(ValidationError::new(
2260                    1002,
2261                    "pst_cd exceeds the maximum length of 16".to_string(),
2262                ));
2263            }
2264        }
2265        if let Some(ref val) = self.twn_nm {
2266            if val.chars().count() < 1 {
2267                return Err(ValidationError::new(
2268                    1001,
2269                    "twn_nm is shorter than the minimum length of 1".to_string(),
2270                ));
2271            }
2272            if val.chars().count() > 35 {
2273                return Err(ValidationError::new(
2274                    1002,
2275                    "twn_nm exceeds the maximum length of 35".to_string(),
2276                ));
2277            }
2278        }
2279        if let Some(ref val) = self.twn_lctn_nm {
2280            if val.chars().count() < 1 {
2281                return Err(ValidationError::new(
2282                    1001,
2283                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
2284                ));
2285            }
2286            if val.chars().count() > 35 {
2287                return Err(ValidationError::new(
2288                    1002,
2289                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
2290                ));
2291            }
2292        }
2293        if let Some(ref val) = self.dstrct_nm {
2294            if val.chars().count() < 1 {
2295                return Err(ValidationError::new(
2296                    1001,
2297                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
2298                ));
2299            }
2300            if val.chars().count() > 35 {
2301                return Err(ValidationError::new(
2302                    1002,
2303                    "dstrct_nm exceeds the maximum length of 35".to_string(),
2304                ));
2305            }
2306        }
2307        if let Some(ref val) = self.ctry_sub_dvsn {
2308            if val.chars().count() < 1 {
2309                return Err(ValidationError::new(
2310                    1001,
2311                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
2312                ));
2313            }
2314            if val.chars().count() > 35 {
2315                return Err(ValidationError::new(
2316                    1002,
2317                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
2318                ));
2319            }
2320        }
2321        if let Some(ref val) = self.ctry {
2322            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2323            if !pattern.is_match(val) {
2324                return Err(ValidationError::new(
2325                    1005,
2326                    "ctry does not match the required pattern".to_string(),
2327                ));
2328            }
2329        }
2330        if let Some(ref vec) = self.adr_line {
2331            for item in vec {
2332                if item.chars().count() < 1 {
2333                    return Err(ValidationError::new(
2334                        1001,
2335                        "adr_line is shorter than the minimum length of 1".to_string(),
2336                    ));
2337                }
2338                if item.chars().count() > 70 {
2339                    return Err(ValidationError::new(
2340                        1002,
2341                        "adr_line exceeds the maximum length of 70".to_string(),
2342                    ));
2343                }
2344            }
2345        }
2346        Ok(())
2347    }
2348}
2349
2350// PreferredContactMethod1Code ...
2351#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2352pub enum PreferredContactMethod1Code {
2353    #[default]
2354    #[serde(rename = "LETT")]
2355    CodeLETT,
2356    #[serde(rename = "MAIL")]
2357    CodeMAIL,
2358    #[serde(rename = "PHON")]
2359    CodePHON,
2360    #[serde(rename = "FAXX")]
2361    CodeFAXX,
2362    #[serde(rename = "CELL")]
2363    CodeCELL,
2364}
2365
2366impl PreferredContactMethod1Code {
2367    pub fn validate(&self) -> Result<(), ValidationError> {
2368        Ok(())
2369    }
2370}
2371
2372// ProxyAccountIdentification1 ...
2373#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2374pub struct ProxyAccountIdentification1 {
2375    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2376    pub tp: Option<ProxyAccountType1Choice>,
2377    #[serde(rename = "Id")]
2378    pub id: String,
2379}
2380
2381impl ProxyAccountIdentification1 {
2382    pub fn validate(&self) -> Result<(), ValidationError> {
2383        if let Some(ref val) = self.tp {
2384            val.validate()?
2385        }
2386        if self.id.chars().count() < 1 {
2387            return Err(ValidationError::new(
2388                1001,
2389                "id is shorter than the minimum length of 1".to_string(),
2390            ));
2391        }
2392        if self.id.chars().count() > 2048 {
2393            return Err(ValidationError::new(
2394                1002,
2395                "id exceeds the maximum length of 2048".to_string(),
2396            ));
2397        }
2398        Ok(())
2399    }
2400}
2401
2402// ProxyAccountType1Choice ...
2403#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2404pub struct ProxyAccountType1Choice {
2405    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2406    pub cd: Option<String>,
2407    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2408    pub prtry: Option<String>,
2409}
2410
2411impl ProxyAccountType1Choice {
2412    pub fn validate(&self) -> Result<(), ValidationError> {
2413        if let Some(ref val) = self.cd {
2414            if val.chars().count() < 1 {
2415                return Err(ValidationError::new(
2416                    1001,
2417                    "cd is shorter than the minimum length of 1".to_string(),
2418                ));
2419            }
2420            if val.chars().count() > 4 {
2421                return Err(ValidationError::new(
2422                    1002,
2423                    "cd exceeds the maximum length of 4".to_string(),
2424                ));
2425            }
2426        }
2427        if let Some(ref val) = self.prtry {
2428            if val.chars().count() < 1 {
2429                return Err(ValidationError::new(
2430                    1001,
2431                    "prtry is shorter than the minimum length of 1".to_string(),
2432                ));
2433            }
2434            if val.chars().count() > 35 {
2435                return Err(ValidationError::new(
2436                    1002,
2437                    "prtry exceeds the maximum length of 35".to_string(),
2438                ));
2439            }
2440        }
2441        Ok(())
2442    }
2443}
2444
2445// Purpose2Choice ...
2446#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2447pub struct Purpose2Choice {
2448    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2449    pub cd: Option<String>,
2450    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2451    pub prtry: Option<String>,
2452}
2453
2454impl Purpose2Choice {
2455    pub fn validate(&self) -> Result<(), ValidationError> {
2456        if let Some(ref val) = self.cd {
2457            if val.chars().count() < 1 {
2458                return Err(ValidationError::new(
2459                    1001,
2460                    "cd is shorter than the minimum length of 1".to_string(),
2461                ));
2462            }
2463            if val.chars().count() > 4 {
2464                return Err(ValidationError::new(
2465                    1002,
2466                    "cd exceeds the maximum length of 4".to_string(),
2467                ));
2468            }
2469        }
2470        if let Some(ref val) = self.prtry {
2471            if val.chars().count() < 1 {
2472                return Err(ValidationError::new(
2473                    1001,
2474                    "prtry is shorter than the minimum length of 1".to_string(),
2475                ));
2476            }
2477            if val.chars().count() > 35 {
2478                return Err(ValidationError::new(
2479                    1002,
2480                    "prtry exceeds the maximum length of 35".to_string(),
2481                ));
2482            }
2483        }
2484        Ok(())
2485    }
2486}
2487
2488// ReferredDocumentInformation7 ...
2489#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2490pub struct ReferredDocumentInformation7 {
2491    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2492    pub tp: Option<ReferredDocumentType4>,
2493    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
2494    pub nb: Option<String>,
2495    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
2496    pub rltd_dt: Option<String>,
2497    #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
2498    pub line_dtls: Option<Vec<DocumentLineInformation1>>,
2499}
2500
2501impl ReferredDocumentInformation7 {
2502    pub fn validate(&self) -> Result<(), ValidationError> {
2503        if let Some(ref val) = self.tp {
2504            val.validate()?
2505        }
2506        if let Some(ref val) = self.nb {
2507            if val.chars().count() < 1 {
2508                return Err(ValidationError::new(
2509                    1001,
2510                    "nb is shorter than the minimum length of 1".to_string(),
2511                ));
2512            }
2513            if val.chars().count() > 35 {
2514                return Err(ValidationError::new(
2515                    1002,
2516                    "nb exceeds the maximum length of 35".to_string(),
2517                ));
2518            }
2519        }
2520        if let Some(ref vec) = self.line_dtls {
2521            for item in vec {
2522                item.validate()?
2523            }
2524        }
2525        Ok(())
2526    }
2527}
2528
2529// ReferredDocumentType3Choice ...
2530#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2531pub struct ReferredDocumentType3Choice {
2532    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2533    pub cd: Option<DocumentType6Code>,
2534    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2535    pub prtry: Option<String>,
2536}
2537
2538impl ReferredDocumentType3Choice {
2539    pub fn validate(&self) -> Result<(), ValidationError> {
2540        if let Some(ref val) = self.cd {
2541            val.validate()?
2542        }
2543        if let Some(ref val) = self.prtry {
2544            if val.chars().count() < 1 {
2545                return Err(ValidationError::new(
2546                    1001,
2547                    "prtry is shorter than the minimum length of 1".to_string(),
2548                ));
2549            }
2550            if val.chars().count() > 35 {
2551                return Err(ValidationError::new(
2552                    1002,
2553                    "prtry exceeds the maximum length of 35".to_string(),
2554                ));
2555            }
2556        }
2557        Ok(())
2558    }
2559}
2560
2561// ReferredDocumentType4 ...
2562#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2563pub struct ReferredDocumentType4 {
2564    #[serde(rename = "CdOrPrtry")]
2565    pub cd_or_prtry: ReferredDocumentType3Choice,
2566    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2567    pub issr: Option<String>,
2568}
2569
2570impl ReferredDocumentType4 {
2571    pub fn validate(&self) -> Result<(), ValidationError> {
2572        self.cd_or_prtry.validate()?;
2573        if let Some(ref val) = self.issr {
2574            if val.chars().count() < 1 {
2575                return Err(ValidationError::new(
2576                    1001,
2577                    "issr is shorter than the minimum length of 1".to_string(),
2578                ));
2579            }
2580            if val.chars().count() > 35 {
2581                return Err(ValidationError::new(
2582                    1002,
2583                    "issr exceeds the maximum length of 35".to_string(),
2584                ));
2585            }
2586        }
2587        Ok(())
2588    }
2589}
2590
2591// RemittanceAmount2 ...
2592#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2593pub struct RemittanceAmount2 {
2594    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
2595    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2596    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
2597    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
2598    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
2599    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2600    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
2601    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
2602    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
2603    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
2604    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
2605    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2606}
2607
2608impl RemittanceAmount2 {
2609    pub fn validate(&self) -> Result<(), ValidationError> {
2610        if let Some(ref val) = self.due_pybl_amt {
2611            val.validate()?
2612        }
2613        if let Some(ref vec) = self.dscnt_apld_amt {
2614            for item in vec {
2615                item.validate()?
2616            }
2617        }
2618        if let Some(ref val) = self.cdt_note_amt {
2619            val.validate()?
2620        }
2621        if let Some(ref vec) = self.tax_amt {
2622            for item in vec {
2623                item.validate()?
2624            }
2625        }
2626        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
2627            for item in vec {
2628                item.validate()?
2629            }
2630        }
2631        if let Some(ref val) = self.rmtd_amt {
2632            val.validate()?
2633        }
2634        Ok(())
2635    }
2636}
2637
2638// RemittanceAmount3 ...
2639#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2640pub struct RemittanceAmount3 {
2641    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
2642    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2643    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
2644    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
2645    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
2646    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2647    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
2648    pub tax_amt: Option<Vec<TaxAmountAndType1>>,
2649    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
2650    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
2651    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
2652    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2653}
2654
2655impl RemittanceAmount3 {
2656    pub fn validate(&self) -> Result<(), ValidationError> {
2657        if let Some(ref val) = self.due_pybl_amt {
2658            val.validate()?
2659        }
2660        if let Some(ref vec) = self.dscnt_apld_amt {
2661            for item in vec {
2662                item.validate()?
2663            }
2664        }
2665        if let Some(ref val) = self.cdt_note_amt {
2666            val.validate()?
2667        }
2668        if let Some(ref vec) = self.tax_amt {
2669            for item in vec {
2670                item.validate()?
2671            }
2672        }
2673        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
2674            for item in vec {
2675                item.validate()?
2676            }
2677        }
2678        if let Some(ref val) = self.rmtd_amt {
2679            val.validate()?
2680        }
2681        Ok(())
2682    }
2683}
2684
2685// RemittanceInformation16 ...
2686#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2687pub struct RemittanceInformation16 {
2688    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
2689    pub ustrd: Option<Vec<String>>,
2690    #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
2691    pub strd: Option<Vec<StructuredRemittanceInformation16>>,
2692}
2693
2694impl RemittanceInformation16 {
2695    pub fn validate(&self) -> Result<(), ValidationError> {
2696        if let Some(ref vec) = self.ustrd {
2697            for item in vec {
2698                if item.chars().count() < 1 {
2699                    return Err(ValidationError::new(
2700                        1001,
2701                        "ustrd is shorter than the minimum length of 1".to_string(),
2702                    ));
2703                }
2704                if item.chars().count() > 140 {
2705                    return Err(ValidationError::new(
2706                        1002,
2707                        "ustrd exceeds the maximum length of 140".to_string(),
2708                    ));
2709                }
2710            }
2711        }
2712        if let Some(ref vec) = self.strd {
2713            for item in vec {
2714                item.validate()?
2715            }
2716        }
2717        Ok(())
2718    }
2719}
2720
2721// RemittanceLocation7 ...
2722#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2723pub struct RemittanceLocation7 {
2724    #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
2725    pub rmt_id: Option<String>,
2726    #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
2727    pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData1>>,
2728}
2729
2730impl RemittanceLocation7 {
2731    pub fn validate(&self) -> Result<(), ValidationError> {
2732        if let Some(ref val) = self.rmt_id {
2733            if val.chars().count() < 1 {
2734                return Err(ValidationError::new(
2735                    1001,
2736                    "rmt_id is shorter than the minimum length of 1".to_string(),
2737                ));
2738            }
2739            if val.chars().count() > 35 {
2740                return Err(ValidationError::new(
2741                    1002,
2742                    "rmt_id exceeds the maximum length of 35".to_string(),
2743                ));
2744            }
2745        }
2746        if let Some(ref vec) = self.rmt_lctn_dtls {
2747            for item in vec {
2748                item.validate()?
2749            }
2750        }
2751        Ok(())
2752    }
2753}
2754
2755// RemittanceLocationData1 ...
2756#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2757pub struct RemittanceLocationData1 {
2758    #[serde(rename = "Mtd")]
2759    pub mtd: RemittanceLocationMethod2Code,
2760    #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
2761    pub elctrnc_adr: Option<String>,
2762    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2763    pub pstl_adr: Option<NameAndAddress16>,
2764}
2765
2766impl RemittanceLocationData1 {
2767    pub fn validate(&self) -> Result<(), ValidationError> {
2768        self.mtd.validate()?;
2769        if let Some(ref val) = self.elctrnc_adr {
2770            if val.chars().count() < 1 {
2771                return Err(ValidationError::new(
2772                    1001,
2773                    "elctrnc_adr is shorter than the minimum length of 1".to_string(),
2774                ));
2775            }
2776            if val.chars().count() > 2048 {
2777                return Err(ValidationError::new(
2778                    1002,
2779                    "elctrnc_adr exceeds the maximum length of 2048".to_string(),
2780                ));
2781            }
2782        }
2783        if let Some(ref val) = self.pstl_adr {
2784            val.validate()?
2785        }
2786        Ok(())
2787    }
2788}
2789
2790// RemittanceLocationMethod2Code ...
2791#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2792pub enum RemittanceLocationMethod2Code {
2793    #[default]
2794    #[serde(rename = "FAXI")]
2795    CodeFAXI,
2796    #[serde(rename = "EDIC")]
2797    CodeEDIC,
2798    #[serde(rename = "URID")]
2799    CodeURID,
2800    #[serde(rename = "EMAL")]
2801    CodeEMAL,
2802    #[serde(rename = "POST")]
2803    CodePOST,
2804    #[serde(rename = "SMSM")]
2805    CodeSMSM,
2806}
2807
2808impl RemittanceLocationMethod2Code {
2809    pub fn validate(&self) -> Result<(), ValidationError> {
2810        Ok(())
2811    }
2812}
2813
2814// StructuredRemittanceInformation16 ...
2815#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2816pub struct StructuredRemittanceInformation16 {
2817    #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
2818    pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation7>>,
2819    #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
2820    pub rfrd_doc_amt: Option<RemittanceAmount2>,
2821    #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
2822    pub cdtr_ref_inf: Option<CreditorReferenceInformation2>,
2823    #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
2824    pub invcr: Option<PartyIdentification135>,
2825    #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
2826    pub invcee: Option<PartyIdentification135>,
2827    #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
2828    pub tax_rmt: Option<TaxInformation7>,
2829    #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
2830    pub grnshmt_rmt: Option<Garnishment3>,
2831    #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
2832    pub addtl_rmt_inf: Option<Vec<String>>,
2833}
2834
2835impl StructuredRemittanceInformation16 {
2836    pub fn validate(&self) -> Result<(), ValidationError> {
2837        if let Some(ref vec) = self.rfrd_doc_inf {
2838            for item in vec {
2839                item.validate()?
2840            }
2841        }
2842        if let Some(ref val) = self.rfrd_doc_amt {
2843            val.validate()?
2844        }
2845        if let Some(ref val) = self.cdtr_ref_inf {
2846            val.validate()?
2847        }
2848        if let Some(ref val) = self.invcr {
2849            val.validate()?
2850        }
2851        if let Some(ref val) = self.invcee {
2852            val.validate()?
2853        }
2854        if let Some(ref val) = self.tax_rmt {
2855            val.validate()?
2856        }
2857        if let Some(ref val) = self.grnshmt_rmt {
2858            val.validate()?
2859        }
2860        if let Some(ref vec) = self.addtl_rmt_inf {
2861            for item in vec {
2862                if item.chars().count() < 1 {
2863                    return Err(ValidationError::new(
2864                        1001,
2865                        "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
2866                    ));
2867                }
2868                if item.chars().count() > 140 {
2869                    return Err(ValidationError::new(
2870                        1002,
2871                        "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
2872                    ));
2873                }
2874            }
2875        }
2876        Ok(())
2877    }
2878}
2879
2880// SupplementaryData1 ...
2881#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2882pub struct SupplementaryData1 {
2883    #[serde(rename = "PlcAndNm", skip_serializing_if = "Option::is_none")]
2884    pub plc_and_nm: Option<String>,
2885    #[serde(rename = "Envlp")]
2886    pub envlp: SupplementaryDataEnvelope1,
2887}
2888
2889impl SupplementaryData1 {
2890    pub fn validate(&self) -> Result<(), ValidationError> {
2891        if let Some(ref val) = self.plc_and_nm {
2892            if val.chars().count() < 1 {
2893                return Err(ValidationError::new(
2894                    1001,
2895                    "plc_and_nm is shorter than the minimum length of 1".to_string(),
2896                ));
2897            }
2898            if val.chars().count() > 350 {
2899                return Err(ValidationError::new(
2900                    1002,
2901                    "plc_and_nm exceeds the maximum length of 350".to_string(),
2902                ));
2903            }
2904        }
2905        self.envlp.validate()?;
2906        Ok(())
2907    }
2908}
2909
2910// SupplementaryDataEnvelope1 ...
2911#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2912pub struct SupplementaryDataEnvelope1 {}
2913
2914impl SupplementaryDataEnvelope1 {
2915    pub fn validate(&self) -> Result<(), ValidationError> {
2916        Ok(())
2917    }
2918}
2919
2920// TaxAmount2 ...
2921#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2922pub struct TaxAmount2 {
2923    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
2924    pub rate: Option<f64>,
2925    #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
2926    pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2927    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
2928    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2929    #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
2930    pub dtls: Option<Vec<TaxRecordDetails2>>,
2931}
2932
2933impl TaxAmount2 {
2934    pub fn validate(&self) -> Result<(), ValidationError> {
2935        if let Some(ref val) = self.taxbl_base_amt {
2936            val.validate()?
2937        }
2938        if let Some(ref val) = self.ttl_amt {
2939            val.validate()?
2940        }
2941        if let Some(ref vec) = self.dtls {
2942            for item in vec {
2943                item.validate()?
2944            }
2945        }
2946        Ok(())
2947    }
2948}
2949
2950// TaxAmountAndType1 ...
2951#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2952pub struct TaxAmountAndType1 {
2953    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2954    pub tp: Option<TaxAmountType1Choice>,
2955    #[serde(rename = "Amt")]
2956    pub amt: ActiveOrHistoricCurrencyAndAmount,
2957}
2958
2959impl TaxAmountAndType1 {
2960    pub fn validate(&self) -> Result<(), ValidationError> {
2961        if let Some(ref val) = self.tp {
2962            val.validate()?
2963        }
2964        self.amt.validate()?;
2965        Ok(())
2966    }
2967}
2968
2969// TaxAmountType1Choice ...
2970#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2971pub struct TaxAmountType1Choice {
2972    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2973    pub cd: Option<String>,
2974    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2975    pub prtry: Option<String>,
2976}
2977
2978impl TaxAmountType1Choice {
2979    pub fn validate(&self) -> Result<(), ValidationError> {
2980        if let Some(ref val) = self.cd {
2981            if val.chars().count() < 1 {
2982                return Err(ValidationError::new(
2983                    1001,
2984                    "cd is shorter than the minimum length of 1".to_string(),
2985                ));
2986            }
2987            if val.chars().count() > 4 {
2988                return Err(ValidationError::new(
2989                    1002,
2990                    "cd exceeds the maximum length of 4".to_string(),
2991                ));
2992            }
2993        }
2994        if let Some(ref val) = self.prtry {
2995            if val.chars().count() < 1 {
2996                return Err(ValidationError::new(
2997                    1001,
2998                    "prtry is shorter than the minimum length of 1".to_string(),
2999                ));
3000            }
3001            if val.chars().count() > 35 {
3002                return Err(ValidationError::new(
3003                    1002,
3004                    "prtry exceeds the maximum length of 35".to_string(),
3005                ));
3006            }
3007        }
3008        Ok(())
3009    }
3010}
3011
3012// TaxAuthorisation1 ...
3013#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3014pub struct TaxAuthorisation1 {
3015    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
3016    pub titl: Option<String>,
3017    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3018    pub nm: Option<String>,
3019}
3020
3021impl TaxAuthorisation1 {
3022    pub fn validate(&self) -> Result<(), ValidationError> {
3023        if let Some(ref val) = self.titl {
3024            if val.chars().count() < 1 {
3025                return Err(ValidationError::new(
3026                    1001,
3027                    "titl is shorter than the minimum length of 1".to_string(),
3028                ));
3029            }
3030            if val.chars().count() > 35 {
3031                return Err(ValidationError::new(
3032                    1002,
3033                    "titl exceeds the maximum length of 35".to_string(),
3034                ));
3035            }
3036        }
3037        if let Some(ref val) = self.nm {
3038            if val.chars().count() < 1 {
3039                return Err(ValidationError::new(
3040                    1001,
3041                    "nm is shorter than the minimum length of 1".to_string(),
3042                ));
3043            }
3044            if val.chars().count() > 140 {
3045                return Err(ValidationError::new(
3046                    1002,
3047                    "nm exceeds the maximum length of 140".to_string(),
3048                ));
3049            }
3050        }
3051        Ok(())
3052    }
3053}
3054
3055// TaxInformation7 ...
3056#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3057pub struct TaxInformation7 {
3058    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3059    pub cdtr: Option<TaxParty1>,
3060    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3061    pub dbtr: Option<TaxParty2>,
3062    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
3063    pub ultmt_dbtr: Option<TaxParty2>,
3064    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
3065    pub admstn_zone: Option<String>,
3066    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3067    pub ref_nb: Option<String>,
3068    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
3069    pub mtd: Option<String>,
3070    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3071    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3072    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
3073    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3074    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3075    pub dt: Option<String>,
3076    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
3077    pub seq_nb: Option<f64>,
3078    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
3079    pub rcrd: Option<Vec<TaxRecord2>>,
3080}
3081
3082impl TaxInformation7 {
3083    pub fn validate(&self) -> Result<(), ValidationError> {
3084        if let Some(ref val) = self.cdtr {
3085            val.validate()?
3086        }
3087        if let Some(ref val) = self.dbtr {
3088            val.validate()?
3089        }
3090        if let Some(ref val) = self.ultmt_dbtr {
3091            val.validate()?
3092        }
3093        if let Some(ref val) = self.admstn_zone {
3094            if val.chars().count() < 1 {
3095                return Err(ValidationError::new(
3096                    1001,
3097                    "admstn_zone is shorter than the minimum length of 1".to_string(),
3098                ));
3099            }
3100            if val.chars().count() > 35 {
3101                return Err(ValidationError::new(
3102                    1002,
3103                    "admstn_zone exceeds the maximum length of 35".to_string(),
3104                ));
3105            }
3106        }
3107        if let Some(ref val) = self.ref_nb {
3108            if val.chars().count() < 1 {
3109                return Err(ValidationError::new(
3110                    1001,
3111                    "ref_nb is shorter than the minimum length of 1".to_string(),
3112                ));
3113            }
3114            if val.chars().count() > 140 {
3115                return Err(ValidationError::new(
3116                    1002,
3117                    "ref_nb exceeds the maximum length of 140".to_string(),
3118                ));
3119            }
3120        }
3121        if let Some(ref val) = self.mtd {
3122            if val.chars().count() < 1 {
3123                return Err(ValidationError::new(
3124                    1001,
3125                    "mtd is shorter than the minimum length of 1".to_string(),
3126                ));
3127            }
3128            if val.chars().count() > 35 {
3129                return Err(ValidationError::new(
3130                    1002,
3131                    "mtd exceeds the maximum length of 35".to_string(),
3132                ));
3133            }
3134        }
3135        if let Some(ref val) = self.ttl_taxbl_base_amt {
3136            val.validate()?
3137        }
3138        if let Some(ref val) = self.ttl_tax_amt {
3139            val.validate()?
3140        }
3141        if let Some(ref vec) = self.rcrd {
3142            for item in vec {
3143                item.validate()?
3144            }
3145        }
3146        Ok(())
3147    }
3148}
3149
3150// TaxParty1 ...
3151#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3152pub struct TaxParty1 {
3153    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
3154    pub tax_id: Option<String>,
3155    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
3156    pub regn_id: Option<String>,
3157    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
3158    pub tax_tp: Option<String>,
3159}
3160
3161impl TaxParty1 {
3162    pub fn validate(&self) -> Result<(), ValidationError> {
3163        if let Some(ref val) = self.tax_id {
3164            if val.chars().count() < 1 {
3165                return Err(ValidationError::new(
3166                    1001,
3167                    "tax_id is shorter than the minimum length of 1".to_string(),
3168                ));
3169            }
3170            if val.chars().count() > 35 {
3171                return Err(ValidationError::new(
3172                    1002,
3173                    "tax_id exceeds the maximum length of 35".to_string(),
3174                ));
3175            }
3176        }
3177        if let Some(ref val) = self.regn_id {
3178            if val.chars().count() < 1 {
3179                return Err(ValidationError::new(
3180                    1001,
3181                    "regn_id is shorter than the minimum length of 1".to_string(),
3182                ));
3183            }
3184            if val.chars().count() > 35 {
3185                return Err(ValidationError::new(
3186                    1002,
3187                    "regn_id exceeds the maximum length of 35".to_string(),
3188                ));
3189            }
3190        }
3191        if let Some(ref val) = self.tax_tp {
3192            if val.chars().count() < 1 {
3193                return Err(ValidationError::new(
3194                    1001,
3195                    "tax_tp is shorter than the minimum length of 1".to_string(),
3196                ));
3197            }
3198            if val.chars().count() > 35 {
3199                return Err(ValidationError::new(
3200                    1002,
3201                    "tax_tp exceeds the maximum length of 35".to_string(),
3202                ));
3203            }
3204        }
3205        Ok(())
3206    }
3207}
3208
3209// TaxParty2 ...
3210#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3211pub struct TaxParty2 {
3212    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
3213    pub tax_id: Option<String>,
3214    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
3215    pub regn_id: Option<String>,
3216    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
3217    pub tax_tp: Option<String>,
3218    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
3219    pub authstn: Option<TaxAuthorisation1>,
3220}
3221
3222impl TaxParty2 {
3223    pub fn validate(&self) -> Result<(), ValidationError> {
3224        if let Some(ref val) = self.tax_id {
3225            if val.chars().count() < 1 {
3226                return Err(ValidationError::new(
3227                    1001,
3228                    "tax_id is shorter than the minimum length of 1".to_string(),
3229                ));
3230            }
3231            if val.chars().count() > 35 {
3232                return Err(ValidationError::new(
3233                    1002,
3234                    "tax_id exceeds the maximum length of 35".to_string(),
3235                ));
3236            }
3237        }
3238        if let Some(ref val) = self.regn_id {
3239            if val.chars().count() < 1 {
3240                return Err(ValidationError::new(
3241                    1001,
3242                    "regn_id is shorter than the minimum length of 1".to_string(),
3243                ));
3244            }
3245            if val.chars().count() > 35 {
3246                return Err(ValidationError::new(
3247                    1002,
3248                    "regn_id exceeds the maximum length of 35".to_string(),
3249                ));
3250            }
3251        }
3252        if let Some(ref val) = self.tax_tp {
3253            if val.chars().count() < 1 {
3254                return Err(ValidationError::new(
3255                    1001,
3256                    "tax_tp is shorter than the minimum length of 1".to_string(),
3257                ));
3258            }
3259            if val.chars().count() > 35 {
3260                return Err(ValidationError::new(
3261                    1002,
3262                    "tax_tp exceeds the maximum length of 35".to_string(),
3263                ));
3264            }
3265        }
3266        if let Some(ref val) = self.authstn {
3267            val.validate()?
3268        }
3269        Ok(())
3270    }
3271}
3272
3273// TaxPeriod2 ...
3274#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3275pub struct TaxPeriod2 {
3276    #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
3277    pub yr: Option<String>,
3278    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3279    pub tp: Option<TaxRecordPeriod1Code>,
3280    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
3281    pub fr_to_dt: Option<DatePeriod2>,
3282}
3283
3284impl TaxPeriod2 {
3285    pub fn validate(&self) -> Result<(), ValidationError> {
3286        if let Some(ref val) = self.tp {
3287            val.validate()?
3288        }
3289        if let Some(ref val) = self.fr_to_dt {
3290            val.validate()?
3291        }
3292        Ok(())
3293    }
3294}
3295
3296// TaxRecord2 ...
3297#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3298pub struct TaxRecord2 {
3299    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3300    pub tp: Option<String>,
3301    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
3302    pub ctgy: Option<String>,
3303    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
3304    pub ctgy_dtls: Option<String>,
3305    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
3306    pub dbtr_sts: Option<String>,
3307    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
3308    pub cert_id: Option<String>,
3309    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
3310    pub frms_cd: Option<String>,
3311    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
3312    pub prd: Option<TaxPeriod2>,
3313    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3314    pub tax_amt: Option<TaxAmount2>,
3315    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
3316    pub addtl_inf: Option<String>,
3317}
3318
3319impl TaxRecord2 {
3320    pub fn validate(&self) -> Result<(), ValidationError> {
3321        if let Some(ref val) = self.tp {
3322            if val.chars().count() < 1 {
3323                return Err(ValidationError::new(
3324                    1001,
3325                    "tp is shorter than the minimum length of 1".to_string(),
3326                ));
3327            }
3328            if val.chars().count() > 35 {
3329                return Err(ValidationError::new(
3330                    1002,
3331                    "tp exceeds the maximum length of 35".to_string(),
3332                ));
3333            }
3334        }
3335        if let Some(ref val) = self.ctgy {
3336            if val.chars().count() < 1 {
3337                return Err(ValidationError::new(
3338                    1001,
3339                    "ctgy is shorter than the minimum length of 1".to_string(),
3340                ));
3341            }
3342            if val.chars().count() > 35 {
3343                return Err(ValidationError::new(
3344                    1002,
3345                    "ctgy exceeds the maximum length of 35".to_string(),
3346                ));
3347            }
3348        }
3349        if let Some(ref val) = self.ctgy_dtls {
3350            if val.chars().count() < 1 {
3351                return Err(ValidationError::new(
3352                    1001,
3353                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
3354                ));
3355            }
3356            if val.chars().count() > 35 {
3357                return Err(ValidationError::new(
3358                    1002,
3359                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
3360                ));
3361            }
3362        }
3363        if let Some(ref val) = self.dbtr_sts {
3364            if val.chars().count() < 1 {
3365                return Err(ValidationError::new(
3366                    1001,
3367                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
3368                ));
3369            }
3370            if val.chars().count() > 35 {
3371                return Err(ValidationError::new(
3372                    1002,
3373                    "dbtr_sts exceeds the maximum length of 35".to_string(),
3374                ));
3375            }
3376        }
3377        if let Some(ref val) = self.cert_id {
3378            if val.chars().count() < 1 {
3379                return Err(ValidationError::new(
3380                    1001,
3381                    "cert_id is shorter than the minimum length of 1".to_string(),
3382                ));
3383            }
3384            if val.chars().count() > 35 {
3385                return Err(ValidationError::new(
3386                    1002,
3387                    "cert_id exceeds the maximum length of 35".to_string(),
3388                ));
3389            }
3390        }
3391        if let Some(ref val) = self.frms_cd {
3392            if val.chars().count() < 1 {
3393                return Err(ValidationError::new(
3394                    1001,
3395                    "frms_cd is shorter than the minimum length of 1".to_string(),
3396                ));
3397            }
3398            if val.chars().count() > 35 {
3399                return Err(ValidationError::new(
3400                    1002,
3401                    "frms_cd exceeds the maximum length of 35".to_string(),
3402                ));
3403            }
3404        }
3405        if let Some(ref val) = self.prd {
3406            val.validate()?
3407        }
3408        if let Some(ref val) = self.tax_amt {
3409            val.validate()?
3410        }
3411        if let Some(ref val) = self.addtl_inf {
3412            if val.chars().count() < 1 {
3413                return Err(ValidationError::new(
3414                    1001,
3415                    "addtl_inf is shorter than the minimum length of 1".to_string(),
3416                ));
3417            }
3418            if val.chars().count() > 140 {
3419                return Err(ValidationError::new(
3420                    1002,
3421                    "addtl_inf exceeds the maximum length of 140".to_string(),
3422                ));
3423            }
3424        }
3425        Ok(())
3426    }
3427}
3428
3429// TaxRecordDetails2 ...
3430#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3431pub struct TaxRecordDetails2 {
3432    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
3433    pub prd: Option<TaxPeriod2>,
3434    #[serde(rename = "Amt")]
3435    pub amt: ActiveOrHistoricCurrencyAndAmount,
3436}
3437
3438impl TaxRecordDetails2 {
3439    pub fn validate(&self) -> Result<(), ValidationError> {
3440        if let Some(ref val) = self.prd {
3441            val.validate()?
3442        }
3443        self.amt.validate()?;
3444        Ok(())
3445    }
3446}
3447
3448// TaxRecordPeriod1Code ...
3449#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3450pub enum TaxRecordPeriod1Code {
3451    #[default]
3452    #[serde(rename = "MM01")]
3453    CodeMM01,
3454    #[serde(rename = "MM02")]
3455    CodeMM02,
3456    #[serde(rename = "MM03")]
3457    CodeMM03,
3458    #[serde(rename = "MM04")]
3459    CodeMM04,
3460    #[serde(rename = "MM05")]
3461    CodeMM05,
3462    #[serde(rename = "MM06")]
3463    CodeMM06,
3464    #[serde(rename = "MM07")]
3465    CodeMM07,
3466    #[serde(rename = "MM08")]
3467    CodeMM08,
3468    #[serde(rename = "MM09")]
3469    CodeMM09,
3470    #[serde(rename = "MM10")]
3471    CodeMM10,
3472    #[serde(rename = "MM11")]
3473    CodeMM11,
3474    #[serde(rename = "MM12")]
3475    CodeMM12,
3476    #[serde(rename = "QTR1")]
3477    CodeQTR1,
3478    #[serde(rename = "QTR2")]
3479    CodeQTR2,
3480    #[serde(rename = "QTR3")]
3481    CodeQTR3,
3482    #[serde(rename = "QTR4")]
3483    CodeQTR4,
3484    #[serde(rename = "HLF1")]
3485    CodeHLF1,
3486    #[serde(rename = "HLF2")]
3487    CodeHLF2,
3488}
3489
3490impl TaxRecordPeriod1Code {
3491    pub fn validate(&self) -> Result<(), ValidationError> {
3492        Ok(())
3493    }
3494}