mx_message/document/
pacs_009_001_08_cov.rs

1// Plasmatic MX Message Parsing Library
2// https://github.com/GoPlasmatic/MXMessage
3//
4// Copyright (c) 2025 Plasmatic
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//     http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// You may obtain a copy of this library at
18// https://github.com/GoPlasmatic/MXMessage
19
20use crate::error::*;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24// AccountIdentification4Choice1: Unique identification of an account, as assigned by the account servicer, using an identification scheme.
25#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice1 {
27    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
28    pub iban: Option<String>,
29    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
30    pub othr: Option<GenericAccountIdentification11>,
31}
32
33impl AccountIdentification4Choice1 {
34    pub fn validate(&self) -> Result<(), ValidationError> {
35        if let Some(ref val) = self.iban {
36            let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
37            if !pattern.is_match(val) {
38                return Err(ValidationError::new(
39                    1005,
40                    "iban does not match the required pattern".to_string(),
41                ));
42            }
43        }
44        if let Some(ref val) = self.othr {
45            val.validate()?
46        }
47        Ok(())
48    }
49}
50
51// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountSchemeName1Choice1 {
54    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55    pub cd: Option<String>,
56    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57    pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice1 {
61    pub fn validate(&self) -> Result<(), ValidationError> {
62        if let Some(ref val) = self.cd {
63            if val.chars().count() < 1 {
64                return Err(ValidationError::new(
65                    1001,
66                    "cd is shorter than the minimum length of 1".to_string(),
67                ));
68            }
69            if val.chars().count() > 4 {
70                return Err(ValidationError::new(
71                    1002,
72                    "cd exceeds the maximum length of 4".to_string(),
73                ));
74            }
75        }
76        if let Some(ref val) = self.prtry {
77            if val.chars().count() < 1 {
78                return Err(ValidationError::new(
79                    1001,
80                    "prtry is shorter than the minimum length of 1".to_string(),
81                ));
82            }
83            if val.chars().count() > 35 {
84                return Err(ValidationError::new(
85                    1002,
86                    "prtry exceeds the maximum length of 35".to_string(),
87                ));
88            }
89            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
90            if !pattern.is_match(val) {
91                return Err(ValidationError::new(
92                    1005,
93                    "prtry does not match the required pattern".to_string(),
94                ));
95            }
96        }
97        Ok(())
98    }
99}
100
101// ActiveOrHistoricCurrencyAndAmount: A number of monetary units specified in an active or a historic currency where the unit of currency is explicit and compliant with ISO 4217.
102#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
103pub struct ActiveOrHistoricCurrencyAndAmount {
104    #[serde(rename = "@Ccy")]
105    pub ccy: String,
106    #[serde(rename = "$value")]
107    pub value: f64,
108}
109
110impl ActiveOrHistoricCurrencyAndAmount {
111    pub fn validate(&self) -> Result<(), ValidationError> {
112        Ok(())
113    }
114}
115
116// BranchAndFinancialInstitutionIdentification61: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
117#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
118pub struct BranchAndFinancialInstitutionIdentification61 {
119    #[serde(rename = "FinInstnId")]
120    pub fin_instn_id: FinancialInstitutionIdentification181,
121}
122
123impl BranchAndFinancialInstitutionIdentification61 {
124    pub fn validate(&self) -> Result<(), ValidationError> {
125        self.fin_instn_id.validate()?;
126        Ok(())
127    }
128}
129
130// BranchAndFinancialInstitutionIdentification62: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
132pub struct BranchAndFinancialInstitutionIdentification62 {
133    #[serde(rename = "FinInstnId")]
134    pub fin_instn_id: FinancialInstitutionIdentification182,
135}
136
137impl BranchAndFinancialInstitutionIdentification62 {
138    pub fn validate(&self) -> Result<(), ValidationError> {
139        self.fin_instn_id.validate()?;
140        Ok(())
141    }
142}
143
144// BranchAndFinancialInstitutionIdentification63: Identifies a specific branch of a financial institution.
145//
146// Usage: This component should be used in case the identification information in the financial institution component does not provide identification up to branch level.
147#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
148pub struct BranchAndFinancialInstitutionIdentification63 {
149    #[serde(rename = "FinInstnId")]
150    pub fin_instn_id: FinancialInstitutionIdentification181,
151    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
152    pub brnch_id: Option<BranchData31>,
153}
154
155impl BranchAndFinancialInstitutionIdentification63 {
156    pub fn validate(&self) -> Result<(), ValidationError> {
157        self.fin_instn_id.validate()?;
158        if let Some(ref val) = self.brnch_id {
159            val.validate()?
160        }
161        Ok(())
162    }
163}
164
165// BranchData31: Unique and unambiguous identification of a branch of a financial institution.
166#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
167pub struct BranchData31 {
168    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
169    pub id: Option<String>,
170}
171
172impl BranchData31 {
173    pub fn validate(&self) -> Result<(), ValidationError> {
174        if let Some(ref val) = self.id {
175            if val.chars().count() < 1 {
176                return Err(ValidationError::new(
177                    1001,
178                    "id is shorter than the minimum length of 1".to_string(),
179                ));
180            }
181            if val.chars().count() > 35 {
182                return Err(ValidationError::new(
183                    1002,
184                    "id exceeds the maximum length of 35".to_string(),
185                ));
186            }
187            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
188            if !pattern.is_match(val) {
189                return Err(ValidationError::new(
190                    1005,
191                    "id does not match the required pattern".to_string(),
192                ));
193            }
194        }
195        Ok(())
196    }
197}
198
199// CBPRAmount1: CBPR_Amount__1
200#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
201pub struct CBPRAmount1 {
202    #[serde(rename = "@Ccy")]
203    pub ccy: String,
204    #[serde(rename = "$value")]
205    pub value: f64,
206}
207
208impl CBPRAmount1 {
209    pub fn validate(&self) -> Result<(), ValidationError> {
210        Ok(())
211    }
212}
213
214// CashAccount381: Specifies an alternate assumed name for the identification of the account.
215#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
216pub struct CashAccount381 {
217    #[serde(rename = "Id")]
218    pub id: AccountIdentification4Choice1,
219    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
220    pub tp: Option<CashAccountType2Choice1>,
221    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
222    pub ccy: Option<String>,
223    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
224    pub nm: Option<String>,
225    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
226    pub prxy: Option<ProxyAccountIdentification11>,
227}
228
229impl CashAccount381 {
230    pub fn validate(&self) -> Result<(), ValidationError> {
231        self.id.validate()?;
232        if let Some(ref val) = self.tp {
233            val.validate()?
234        }
235        if let Some(ref val) = self.ccy {
236            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
237            if !pattern.is_match(val) {
238                return Err(ValidationError::new(
239                    1005,
240                    "ccy does not match the required pattern".to_string(),
241                ));
242            }
243        }
244        if let Some(ref val) = self.nm {
245            if val.chars().count() < 1 {
246                return Err(ValidationError::new(
247                    1001,
248                    "nm is shorter than the minimum length of 1".to_string(),
249                ));
250            }
251            if val.chars().count() > 70 {
252                return Err(ValidationError::new(
253                    1002,
254                    "nm exceeds the maximum length of 70".to_string(),
255                ));
256            }
257            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
258            if !pattern.is_match(val) {
259                return Err(ValidationError::new(
260                    1005,
261                    "nm does not match the required pattern".to_string(),
262                ));
263            }
264        }
265        if let Some(ref val) = self.prxy {
266            val.validate()?
267        }
268        Ok(())
269    }
270}
271
272// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
273#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
274pub struct CashAccountType2Choice1 {
275    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
276    pub cd: Option<String>,
277    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
278    pub prtry: Option<String>,
279}
280
281impl CashAccountType2Choice1 {
282    pub fn validate(&self) -> Result<(), ValidationError> {
283        if let Some(ref val) = self.cd {
284            if val.chars().count() < 1 {
285                return Err(ValidationError::new(
286                    1001,
287                    "cd is shorter than the minimum length of 1".to_string(),
288                ));
289            }
290            if val.chars().count() > 4 {
291                return Err(ValidationError::new(
292                    1002,
293                    "cd exceeds the maximum length of 4".to_string(),
294                ));
295            }
296        }
297        if let Some(ref val) = self.prtry {
298            if val.chars().count() < 1 {
299                return Err(ValidationError::new(
300                    1001,
301                    "prtry is shorter than the minimum length of 1".to_string(),
302                ));
303            }
304            if val.chars().count() > 35 {
305                return Err(ValidationError::new(
306                    1002,
307                    "prtry exceeds the maximum length of 35".to_string(),
308                ));
309            }
310            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
311            if !pattern.is_match(val) {
312                return Err(ValidationError::new(
313                    1005,
314                    "prtry does not match the required pattern".to_string(),
315                ));
316            }
317        }
318        Ok(())
319    }
320}
321
322// CategoryPurpose1Choice1: Category purpose, in a proprietary form.
323#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
324pub struct CategoryPurpose1Choice1 {
325    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
326    pub cd: Option<String>,
327    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
328    pub prtry: Option<String>,
329}
330
331impl CategoryPurpose1Choice1 {
332    pub fn validate(&self) -> Result<(), ValidationError> {
333        if let Some(ref val) = self.cd {
334            if val.chars().count() < 1 {
335                return Err(ValidationError::new(
336                    1001,
337                    "cd is shorter than the minimum length of 1".to_string(),
338                ));
339            }
340            if val.chars().count() > 4 {
341                return Err(ValidationError::new(
342                    1002,
343                    "cd exceeds the maximum length of 4".to_string(),
344                ));
345            }
346        }
347        if let Some(ref val) = self.prtry {
348            if val.chars().count() < 1 {
349                return Err(ValidationError::new(
350                    1001,
351                    "prtry is shorter than the minimum length of 1".to_string(),
352                ));
353            }
354            if val.chars().count() > 35 {
355                return Err(ValidationError::new(
356                    1002,
357                    "prtry exceeds the maximum length of 35".to_string(),
358                ));
359            }
360            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
361            if !pattern.is_match(val) {
362                return Err(ValidationError::new(
363                    1005,
364                    "prtry does not match the required pattern".to_string(),
365                ));
366            }
367        }
368        Ok(())
369    }
370}
371
372// ClearingChannel2Code: Payment through internal book transfer.
373#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
374pub enum ClearingChannel2Code {
375    #[default]
376    #[serde(rename = "RTGS")]
377    CodeRTGS,
378    #[serde(rename = "RTNS")]
379    CodeRTNS,
380    #[serde(rename = "MPNS")]
381    CodeMPNS,
382    #[serde(rename = "BOOK")]
383    CodeBOOK,
384}
385
386impl ClearingChannel2Code {
387    pub fn validate(&self) -> Result<(), ValidationError> {
388        Ok(())
389    }
390}
391
392// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
393#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
394pub struct ClearingSystemIdentification2Choice1 {
395    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
396    pub cd: Option<String>,
397}
398
399impl ClearingSystemIdentification2Choice1 {
400    pub fn validate(&self) -> Result<(), ValidationError> {
401        if let Some(ref val) = self.cd {
402            if val.chars().count() < 1 {
403                return Err(ValidationError::new(
404                    1001,
405                    "cd is shorter than the minimum length of 1".to_string(),
406                ));
407            }
408            if val.chars().count() > 5 {
409                return Err(ValidationError::new(
410                    1002,
411                    "cd exceeds the maximum length of 5".to_string(),
412                ));
413            }
414        }
415        Ok(())
416    }
417}
418
419// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
420#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
421pub struct ClearingSystemMemberIdentification21 {
422    #[serde(rename = "ClrSysId")]
423    pub clr_sys_id: ClearingSystemIdentification2Choice1,
424    #[serde(rename = "MmbId")]
425    pub mmb_id: String,
426}
427
428impl ClearingSystemMemberIdentification21 {
429    pub fn validate(&self) -> Result<(), ValidationError> {
430        self.clr_sys_id.validate()?;
431        if self.mmb_id.chars().count() < 1 {
432            return Err(ValidationError::new(
433                1001,
434                "mmb_id is shorter than the minimum length of 1".to_string(),
435            ));
436        }
437        if self.mmb_id.chars().count() > 28 {
438            return Err(ValidationError::new(
439                1002,
440                "mmb_id exceeds the maximum length of 28".to_string(),
441            ));
442        }
443        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
444        if !pattern.is_match(&self.mmb_id) {
445            return Err(ValidationError::new(
446                1005,
447                "mmb_id does not match the required pattern".to_string(),
448            ));
449        }
450        Ok(())
451    }
452}
453
454// CreditDebitCode: Operation is a decrease.
455#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
456pub enum CreditDebitCode {
457    #[default]
458    #[serde(rename = "CRDT")]
459    CodeCRDT,
460    #[serde(rename = "DBIT")]
461    CodeDBIT,
462}
463
464impl CreditDebitCode {
465    pub fn validate(&self) -> Result<(), ValidationError> {
466        Ok(())
467    }
468}
469
470// CreditTransferTransaction361: Provides information on the underlying customer credit transfer for which cover is provided.
471#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
472pub struct CreditTransferTransaction361 {
473    #[serde(rename = "PmtId")]
474    pub pmt_id: PaymentIdentification71,
475    #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
476    pub pmt_tp_inf: Option<PaymentTypeInformation281>,
477    #[serde(rename = "IntrBkSttlmAmt")]
478    pub intr_bk_sttlm_amt: CBPRAmount1,
479    #[serde(rename = "IntrBkSttlmDt")]
480    pub intr_bk_sttlm_dt: String,
481    #[serde(rename = "SttlmPrty", skip_serializing_if = "Option::is_none")]
482    pub sttlm_prty: Option<Priority3Code>,
483    #[serde(rename = "SttlmTmIndctn", skip_serializing_if = "Option::is_none")]
484    pub sttlm_tm_indctn: Option<SettlementDateTimeIndication11>,
485    #[serde(rename = "SttlmTmReq", skip_serializing_if = "Option::is_none")]
486    pub sttlm_tm_req: Option<SettlementTimeRequest21>,
487    #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
488    pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification61>,
489    #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
490    pub prvs_instg_agt1_acct: Option<CashAccount381>,
491    #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
492    pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
493    #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
494    pub prvs_instg_agt2_acct: Option<CashAccount381>,
495    #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
496    pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
497    #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
498    pub prvs_instg_agt3_acct: Option<CashAccount381>,
499    #[serde(rename = "InstgAgt")]
500    pub instg_agt: BranchAndFinancialInstitutionIdentification62,
501    #[serde(rename = "InstdAgt")]
502    pub instd_agt: BranchAndFinancialInstitutionIdentification62,
503    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
504    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification61>,
505    #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
506    pub intrmy_agt1_acct: Option<CashAccount381>,
507    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
508    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
509    #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
510    pub intrmy_agt2_acct: Option<CashAccount381>,
511    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
512    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
513    #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
514    pub intrmy_agt3_acct: Option<CashAccount381>,
515    #[serde(rename = "Dbtr")]
516    pub dbtr: BranchAndFinancialInstitutionIdentification61,
517    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
518    pub dbtr_acct: Option<CashAccount381>,
519    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
520    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
521    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
522    pub dbtr_agt_acct: Option<CashAccount381>,
523    #[serde(rename = "CdtrAgt", skip_serializing_if = "Option::is_none")]
524    pub cdtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
525    #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
526    pub cdtr_agt_acct: Option<CashAccount381>,
527    #[serde(rename = "Cdtr")]
528    pub cdtr: BranchAndFinancialInstitutionIdentification61,
529    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
530    pub cdtr_acct: Option<CashAccount381>,
531    #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
532    pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent21>>,
533    #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
534    pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent11>>,
535    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
536    pub purp: Option<Purpose2Choice1>,
537    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
538    pub rmt_inf: Option<RemittanceInformation21>,
539    #[serde(rename = "UndrlygCstmrCdtTrf")]
540    pub undrlyg_cstmr_cdt_trf: CreditTransferTransaction371,
541}
542
543impl CreditTransferTransaction361 {
544    pub fn validate(&self) -> Result<(), ValidationError> {
545        self.pmt_id.validate()?;
546        if let Some(ref val) = self.pmt_tp_inf {
547            val.validate()?
548        }
549        self.intr_bk_sttlm_amt.validate()?;
550        if let Some(ref val) = self.sttlm_prty {
551            val.validate()?
552        }
553        if let Some(ref val) = self.sttlm_tm_indctn {
554            val.validate()?
555        }
556        if let Some(ref val) = self.sttlm_tm_req {
557            val.validate()?
558        }
559        if let Some(ref val) = self.prvs_instg_agt1 {
560            val.validate()?
561        }
562        if let Some(ref val) = self.prvs_instg_agt1_acct {
563            val.validate()?
564        }
565        if let Some(ref val) = self.prvs_instg_agt2 {
566            val.validate()?
567        }
568        if let Some(ref val) = self.prvs_instg_agt2_acct {
569            val.validate()?
570        }
571        if let Some(ref val) = self.prvs_instg_agt3 {
572            val.validate()?
573        }
574        if let Some(ref val) = self.prvs_instg_agt3_acct {
575            val.validate()?
576        }
577        self.instg_agt.validate()?;
578        self.instd_agt.validate()?;
579        if let Some(ref val) = self.intrmy_agt1 {
580            val.validate()?
581        }
582        if let Some(ref val) = self.intrmy_agt1_acct {
583            val.validate()?
584        }
585        if let Some(ref val) = self.intrmy_agt2 {
586            val.validate()?
587        }
588        if let Some(ref val) = self.intrmy_agt2_acct {
589            val.validate()?
590        }
591        if let Some(ref val) = self.intrmy_agt3 {
592            val.validate()?
593        }
594        if let Some(ref val) = self.intrmy_agt3_acct {
595            val.validate()?
596        }
597        self.dbtr.validate()?;
598        if let Some(ref val) = self.dbtr_acct {
599            val.validate()?
600        }
601        if let Some(ref val) = self.dbtr_agt {
602            val.validate()?
603        }
604        if let Some(ref val) = self.dbtr_agt_acct {
605            val.validate()?
606        }
607        if let Some(ref val) = self.cdtr_agt {
608            val.validate()?
609        }
610        if let Some(ref val) = self.cdtr_agt_acct {
611            val.validate()?
612        }
613        self.cdtr.validate()?;
614        if let Some(ref val) = self.cdtr_acct {
615            val.validate()?
616        }
617        if let Some(ref vec) = self.instr_for_cdtr_agt {
618            for item in vec {
619                item.validate()?
620            }
621        }
622        if let Some(ref vec) = self.instr_for_nxt_agt {
623            for item in vec {
624                item.validate()?
625            }
626        }
627        if let Some(ref val) = self.purp {
628            val.validate()?
629        }
630        if let Some(ref val) = self.rmt_inf {
631            val.validate()?
632        }
633        self.undrlyg_cstmr_cdt_trf.validate()?;
634        Ok(())
635    }
636}
637
638// CreditTransferTransaction371: Amount of money to be moved between the debtor and creditor, before deduction of charges, expressed in the currency as ordered by the initiating party.
639// Usage: This amount has to be transported unchanged through the transaction chain.
640#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
641pub struct CreditTransferTransaction371 {
642    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
643    pub ultmt_dbtr: Option<PartyIdentification1351>,
644    #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
645    pub initg_pty: Option<PartyIdentification1351>,
646    #[serde(rename = "Dbtr")]
647    pub dbtr: PartyIdentification1352,
648    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
649    pub dbtr_acct: Option<CashAccount381>,
650    #[serde(rename = "DbtrAgt")]
651    pub dbtr_agt: BranchAndFinancialInstitutionIdentification61,
652    #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
653    pub dbtr_agt_acct: Option<CashAccount381>,
654    #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
655    pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification61>,
656    #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
657    pub prvs_instg_agt1_acct: Option<CashAccount381>,
658    #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
659    pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
660    #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
661    pub prvs_instg_agt2_acct: Option<CashAccount381>,
662    #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
663    pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
664    #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
665    pub prvs_instg_agt3_acct: Option<CashAccount381>,
666    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
667    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification61>,
668    #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
669    pub intrmy_agt1_acct: Option<CashAccount381>,
670    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
671    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
672    #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
673    pub intrmy_agt2_acct: Option<CashAccount381>,
674    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
675    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
676    #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
677    pub intrmy_agt3_acct: Option<CashAccount381>,
678    #[serde(rename = "CdtrAgt")]
679    pub cdtr_agt: BranchAndFinancialInstitutionIdentification63,
680    #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
681    pub cdtr_agt_acct: Option<CashAccount381>,
682    #[serde(rename = "Cdtr")]
683    pub cdtr: PartyIdentification1353,
684    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
685    pub cdtr_acct: Option<CashAccount381>,
686    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
687    pub ultmt_cdtr: Option<PartyIdentification1351>,
688    #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
689    pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent11>>,
690    #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
691    pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent11>>,
692    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
693    pub rmt_inf: Option<RemittanceInformation161>,
694    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
695    pub instd_amt: Option<CBPRAmount1>,
696}
697
698impl CreditTransferTransaction371 {
699    pub fn validate(&self) -> Result<(), ValidationError> {
700        if let Some(ref val) = self.ultmt_dbtr {
701            val.validate()?
702        }
703        if let Some(ref val) = self.initg_pty {
704            val.validate()?
705        }
706        self.dbtr.validate()?;
707        if let Some(ref val) = self.dbtr_acct {
708            val.validate()?
709        }
710        self.dbtr_agt.validate()?;
711        if let Some(ref val) = self.dbtr_agt_acct {
712            val.validate()?
713        }
714        if let Some(ref val) = self.prvs_instg_agt1 {
715            val.validate()?
716        }
717        if let Some(ref val) = self.prvs_instg_agt1_acct {
718            val.validate()?
719        }
720        if let Some(ref val) = self.prvs_instg_agt2 {
721            val.validate()?
722        }
723        if let Some(ref val) = self.prvs_instg_agt2_acct {
724            val.validate()?
725        }
726        if let Some(ref val) = self.prvs_instg_agt3 {
727            val.validate()?
728        }
729        if let Some(ref val) = self.prvs_instg_agt3_acct {
730            val.validate()?
731        }
732        if let Some(ref val) = self.intrmy_agt1 {
733            val.validate()?
734        }
735        if let Some(ref val) = self.intrmy_agt1_acct {
736            val.validate()?
737        }
738        if let Some(ref val) = self.intrmy_agt2 {
739            val.validate()?
740        }
741        if let Some(ref val) = self.intrmy_agt2_acct {
742            val.validate()?
743        }
744        if let Some(ref val) = self.intrmy_agt3 {
745            val.validate()?
746        }
747        if let Some(ref val) = self.intrmy_agt3_acct {
748            val.validate()?
749        }
750        self.cdtr_agt.validate()?;
751        if let Some(ref val) = self.cdtr_agt_acct {
752            val.validate()?
753        }
754        self.cdtr.validate()?;
755        if let Some(ref val) = self.cdtr_acct {
756            val.validate()?
757        }
758        if let Some(ref val) = self.ultmt_cdtr {
759            val.validate()?
760        }
761        if let Some(ref vec) = self.instr_for_cdtr_agt {
762            for item in vec {
763                item.validate()?
764            }
765        }
766        if let Some(ref vec) = self.instr_for_nxt_agt {
767            for item in vec {
768                item.validate()?
769            }
770        }
771        if let Some(ref val) = self.rmt_inf {
772            val.validate()?
773        }
774        if let Some(ref val) = self.instd_amt {
775            val.validate()?
776        }
777        Ok(())
778    }
779}
780
781// CreditorReferenceInformation21: Unique reference, as assigned by the creditor, to unambiguously refer to the payment transaction.
782//
783// Usage: If available, the initiating party should provide this reference in the structured remittance information, to enable reconciliation by the creditor upon receipt of the amount of money.
784//
785// If the business context requires the use of a creditor reference or a payment remit identification, and only one identifier can be passed through the end-to-end chain, the creditor's reference or payment remittance identification should be quoted in the end-to-end transaction identification.
786#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
787pub struct CreditorReferenceInformation21 {
788    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
789    pub tp: Option<CreditorReferenceType21>,
790    #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
791    pub ref_attr: Option<String>,
792}
793
794impl CreditorReferenceInformation21 {
795    pub fn validate(&self) -> Result<(), ValidationError> {
796        if let Some(ref val) = self.tp {
797            val.validate()?
798        }
799        if let Some(ref val) = self.ref_attr {
800            if val.chars().count() < 1 {
801                return Err(ValidationError::new(
802                    1001,
803                    "ref_attr is shorter than the minimum length of 1".to_string(),
804                ));
805            }
806            if val.chars().count() > 35 {
807                return Err(ValidationError::new(
808                    1002,
809                    "ref_attr exceeds the maximum length of 35".to_string(),
810                ));
811            }
812            let pattern = Regex::new(
813                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
814            )
815            .unwrap();
816            if !pattern.is_match(val) {
817                return Err(ValidationError::new(
818                    1005,
819                    "ref_attr does not match the required pattern".to_string(),
820                ));
821            }
822        }
823        Ok(())
824    }
825}
826
827// CreditorReferenceType1Choice1: Creditor reference type, in a proprietary form.
828#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
829pub struct CreditorReferenceType1Choice1 {
830    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
831    pub cd: Option<DocumentType3Code>,
832    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
833    pub prtry: Option<String>,
834}
835
836impl CreditorReferenceType1Choice1 {
837    pub fn validate(&self) -> Result<(), ValidationError> {
838        if let Some(ref val) = self.cd {
839            val.validate()?
840        }
841        if let Some(ref val) = self.prtry {
842            if val.chars().count() < 1 {
843                return Err(ValidationError::new(
844                    1001,
845                    "prtry is shorter than the minimum length of 1".to_string(),
846                ));
847            }
848            if val.chars().count() > 35 {
849                return Err(ValidationError::new(
850                    1002,
851                    "prtry exceeds the maximum length of 35".to_string(),
852                ));
853            }
854            let pattern = Regex::new(
855                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
856            )
857            .unwrap();
858            if !pattern.is_match(val) {
859                return Err(ValidationError::new(
860                    1005,
861                    "prtry does not match the required pattern".to_string(),
862                ));
863            }
864        }
865        Ok(())
866    }
867}
868
869// CreditorReferenceType21: Entity that assigns the credit reference type.
870#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
871pub struct CreditorReferenceType21 {
872    #[serde(rename = "CdOrPrtry")]
873    pub cd_or_prtry: CreditorReferenceType1Choice1,
874    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
875    pub issr: Option<String>,
876}
877
878impl CreditorReferenceType21 {
879    pub fn validate(&self) -> Result<(), ValidationError> {
880        self.cd_or_prtry.validate()?;
881        if let Some(ref val) = self.issr {
882            if val.chars().count() < 1 {
883                return Err(ValidationError::new(
884                    1001,
885                    "issr is shorter than the minimum length of 1".to_string(),
886                ));
887            }
888            if val.chars().count() > 35 {
889                return Err(ValidationError::new(
890                    1002,
891                    "issr exceeds the maximum length of 35".to_string(),
892                ));
893            }
894            let pattern = Regex::new(
895                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
896            )
897            .unwrap();
898            if !pattern.is_match(val) {
899                return Err(ValidationError::new(
900                    1005,
901                    "issr does not match the required pattern".to_string(),
902                ));
903            }
904        }
905        Ok(())
906    }
907}
908
909// DateAndPlaceOfBirth11: Country where a person was born.
910#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
911pub struct DateAndPlaceOfBirth11 {
912    #[serde(rename = "BirthDt")]
913    pub birth_dt: String,
914    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
915    pub prvc_of_birth: Option<String>,
916    #[serde(rename = "CityOfBirth")]
917    pub city_of_birth: String,
918    #[serde(rename = "CtryOfBirth")]
919    pub ctry_of_birth: String,
920}
921
922impl DateAndPlaceOfBirth11 {
923    pub fn validate(&self) -> Result<(), ValidationError> {
924        if let Some(ref val) = self.prvc_of_birth {
925            if val.chars().count() < 1 {
926                return Err(ValidationError::new(
927                    1001,
928                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
929                ));
930            }
931            if val.chars().count() > 35 {
932                return Err(ValidationError::new(
933                    1002,
934                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
935                ));
936            }
937            let pattern = Regex::new(
938                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
939            )
940            .unwrap();
941            if !pattern.is_match(val) {
942                return Err(ValidationError::new(
943                    1005,
944                    "prvc_of_birth does not match the required pattern".to_string(),
945                ));
946            }
947        }
948        if self.city_of_birth.chars().count() < 1 {
949            return Err(ValidationError::new(
950                1001,
951                "city_of_birth is shorter than the minimum length of 1".to_string(),
952            ));
953        }
954        if self.city_of_birth.chars().count() > 35 {
955            return Err(ValidationError::new(
956                1002,
957                "city_of_birth exceeds the maximum length of 35".to_string(),
958            ));
959        }
960        let pattern =
961            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
962                .unwrap();
963        if !pattern.is_match(&self.city_of_birth) {
964            return Err(ValidationError::new(
965                1005,
966                "city_of_birth does not match the required pattern".to_string(),
967            ));
968        }
969        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
970        if !pattern.is_match(&self.ctry_of_birth) {
971            return Err(ValidationError::new(
972                1005,
973                "ctry_of_birth does not match the required pattern".to_string(),
974            ));
975        }
976        Ok(())
977    }
978}
979
980// DatePeriod2: End date of the range.
981#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
982pub struct DatePeriod2 {
983    #[serde(rename = "FrDt")]
984    pub fr_dt: String,
985    #[serde(rename = "ToDt")]
986    pub to_dt: String,
987}
988
989impl DatePeriod2 {
990    pub fn validate(&self) -> Result<(), ValidationError> {
991        Ok(())
992    }
993}
994
995// DiscountAmountAndType11: Amount of money, which has been typed.
996#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
997pub struct DiscountAmountAndType11 {
998    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
999    pub tp: Option<DiscountAmountType1Choice1>,
1000    #[serde(rename = "Amt")]
1001    pub amt: ActiveOrHistoricCurrencyAndAmount,
1002}
1003
1004impl DiscountAmountAndType11 {
1005    pub fn validate(&self) -> Result<(), ValidationError> {
1006        if let Some(ref val) = self.tp {
1007            val.validate()?
1008        }
1009        self.amt.validate()?;
1010        Ok(())
1011    }
1012}
1013
1014// DiscountAmountType1Choice1: Specifies the amount type, in a free-text form.
1015#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1016pub struct DiscountAmountType1Choice1 {
1017    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1018    pub cd: Option<String>,
1019    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1020    pub prtry: Option<String>,
1021}
1022
1023impl DiscountAmountType1Choice1 {
1024    pub fn validate(&self) -> Result<(), ValidationError> {
1025        if let Some(ref val) = self.cd {
1026            if val.chars().count() < 1 {
1027                return Err(ValidationError::new(
1028                    1001,
1029                    "cd is shorter than the minimum length of 1".to_string(),
1030                ));
1031            }
1032            if val.chars().count() > 4 {
1033                return Err(ValidationError::new(
1034                    1002,
1035                    "cd exceeds the maximum length of 4".to_string(),
1036                ));
1037            }
1038        }
1039        if let Some(ref val) = self.prtry {
1040            if val.chars().count() < 1 {
1041                return Err(ValidationError::new(
1042                    1001,
1043                    "prtry is shorter than the minimum length of 1".to_string(),
1044                ));
1045            }
1046            if val.chars().count() > 35 {
1047                return Err(ValidationError::new(
1048                    1002,
1049                    "prtry exceeds the maximum length of 35".to_string(),
1050                ));
1051            }
1052            let pattern = Regex::new(
1053                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1054            )
1055            .unwrap();
1056            if !pattern.is_match(val) {
1057                return Err(ValidationError::new(
1058                    1005,
1059                    "prtry does not match the required pattern".to_string(),
1060                ));
1061            }
1062        }
1063        Ok(())
1064    }
1065}
1066
1067// DocumentAdjustment11: Provides further details on the document adjustment.
1068#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1069pub struct DocumentAdjustment11 {
1070    #[serde(rename = "Amt")]
1071    pub amt: ActiveOrHistoricCurrencyAndAmount,
1072    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1073    pub cdt_dbt_ind: Option<CreditDebitCode>,
1074    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1075    pub rsn: Option<String>,
1076    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1077    pub addtl_inf: Option<String>,
1078}
1079
1080impl DocumentAdjustment11 {
1081    pub fn validate(&self) -> Result<(), ValidationError> {
1082        self.amt.validate()?;
1083        if let Some(ref val) = self.cdt_dbt_ind {
1084            val.validate()?
1085        }
1086        if let Some(ref val) = self.rsn {
1087            if val.chars().count() < 1 {
1088                return Err(ValidationError::new(
1089                    1001,
1090                    "rsn is shorter than the minimum length of 1".to_string(),
1091                ));
1092            }
1093            if val.chars().count() > 4 {
1094                return Err(ValidationError::new(
1095                    1002,
1096                    "rsn exceeds the maximum length of 4".to_string(),
1097                ));
1098            }
1099            let pattern = Regex::new(
1100                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1101            )
1102            .unwrap();
1103            if !pattern.is_match(val) {
1104                return Err(ValidationError::new(
1105                    1005,
1106                    "rsn does not match the required pattern".to_string(),
1107                ));
1108            }
1109        }
1110        if let Some(ref val) = self.addtl_inf {
1111            if val.chars().count() < 1 {
1112                return Err(ValidationError::new(
1113                    1001,
1114                    "addtl_inf is shorter than the minimum length of 1".to_string(),
1115                ));
1116            }
1117            if val.chars().count() > 140 {
1118                return Err(ValidationError::new(
1119                    1002,
1120                    "addtl_inf exceeds the maximum length of 140".to_string(),
1121                ));
1122            }
1123            let pattern = Regex::new(
1124                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1125            )
1126            .unwrap();
1127            if !pattern.is_match(val) {
1128                return Err(ValidationError::new(
1129                    1005,
1130                    "addtl_inf does not match the required pattern".to_string(),
1131                ));
1132            }
1133        }
1134        Ok(())
1135    }
1136}
1137
1138// DocumentLineIdentification11: Date associated with the referred document line.
1139#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1140pub struct DocumentLineIdentification11 {
1141    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1142    pub tp: Option<DocumentLineType11>,
1143    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
1144    pub nb: Option<String>,
1145    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
1146    pub rltd_dt: Option<String>,
1147}
1148
1149impl DocumentLineIdentification11 {
1150    pub fn validate(&self) -> Result<(), ValidationError> {
1151        if let Some(ref val) = self.tp {
1152            val.validate()?
1153        }
1154        if let Some(ref val) = self.nb {
1155            if val.chars().count() < 1 {
1156                return Err(ValidationError::new(
1157                    1001,
1158                    "nb is shorter than the minimum length of 1".to_string(),
1159                ));
1160            }
1161            if val.chars().count() > 35 {
1162                return Err(ValidationError::new(
1163                    1002,
1164                    "nb exceeds the maximum length of 35".to_string(),
1165                ));
1166            }
1167            let pattern = Regex::new(
1168                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1169            )
1170            .unwrap();
1171            if !pattern.is_match(val) {
1172                return Err(ValidationError::new(
1173                    1005,
1174                    "nb does not match the required pattern".to_string(),
1175                ));
1176            }
1177        }
1178        Ok(())
1179    }
1180}
1181
1182// DocumentLineInformation11: Provides details on the amounts of the document line.
1183#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1184pub struct DocumentLineInformation11 {
1185    #[serde(rename = "Id")]
1186    pub id: Vec<DocumentLineIdentification11>,
1187    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
1188    pub desc: Option<String>,
1189    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
1190    pub amt: Option<RemittanceAmount31>,
1191}
1192
1193impl DocumentLineInformation11 {
1194    pub fn validate(&self) -> Result<(), ValidationError> {
1195        for item in &self.id {
1196            item.validate()?
1197        }
1198        if let Some(ref val) = self.desc {
1199            if val.chars().count() < 1 {
1200                return Err(ValidationError::new(
1201                    1001,
1202                    "desc is shorter than the minimum length of 1".to_string(),
1203                ));
1204            }
1205            if val.chars().count() > 35 {
1206                return Err(ValidationError::new(
1207                    1002,
1208                    "desc exceeds the maximum length of 35".to_string(),
1209                ));
1210            }
1211            let pattern = Regex::new(
1212                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1213            )
1214            .unwrap();
1215            if !pattern.is_match(val) {
1216                return Err(ValidationError::new(
1217                    1005,
1218                    "desc does not match the required pattern".to_string(),
1219                ));
1220            }
1221        }
1222        if let Some(ref val) = self.amt {
1223            val.validate()?
1224        }
1225        Ok(())
1226    }
1227}
1228
1229// DocumentLineType1Choice1: Proprietary identification of the type of the remittance document.
1230#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1231pub struct DocumentLineType1Choice1 {
1232    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1233    pub cd: Option<String>,
1234    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1235    pub prtry: Option<String>,
1236}
1237
1238impl DocumentLineType1Choice1 {
1239    pub fn validate(&self) -> Result<(), ValidationError> {
1240        if let Some(ref val) = self.cd {
1241            if val.chars().count() < 1 {
1242                return Err(ValidationError::new(
1243                    1001,
1244                    "cd is shorter than the minimum length of 1".to_string(),
1245                ));
1246            }
1247            if val.chars().count() > 4 {
1248                return Err(ValidationError::new(
1249                    1002,
1250                    "cd exceeds the maximum length of 4".to_string(),
1251                ));
1252            }
1253        }
1254        if let Some(ref val) = self.prtry {
1255            if val.chars().count() < 1 {
1256                return Err(ValidationError::new(
1257                    1001,
1258                    "prtry is shorter than the minimum length of 1".to_string(),
1259                ));
1260            }
1261            if val.chars().count() > 35 {
1262                return Err(ValidationError::new(
1263                    1002,
1264                    "prtry exceeds the maximum length of 35".to_string(),
1265                ));
1266            }
1267            let pattern = Regex::new(
1268                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1269            )
1270            .unwrap();
1271            if !pattern.is_match(val) {
1272                return Err(ValidationError::new(
1273                    1005,
1274                    "prtry does not match the required pattern".to_string(),
1275                ));
1276            }
1277        }
1278        Ok(())
1279    }
1280}
1281
1282// DocumentLineType11: Identification of the issuer of the reference document line identificationtype.
1283#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1284pub struct DocumentLineType11 {
1285    #[serde(rename = "CdOrPrtry")]
1286    pub cd_or_prtry: DocumentLineType1Choice1,
1287    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1288    pub issr: Option<String>,
1289}
1290
1291impl DocumentLineType11 {
1292    pub fn validate(&self) -> Result<(), ValidationError> {
1293        self.cd_or_prtry.validate()?;
1294        if let Some(ref val) = self.issr {
1295            if val.chars().count() < 1 {
1296                return Err(ValidationError::new(
1297                    1001,
1298                    "issr is shorter than the minimum length of 1".to_string(),
1299                ));
1300            }
1301            if val.chars().count() > 35 {
1302                return Err(ValidationError::new(
1303                    1002,
1304                    "issr exceeds the maximum length of 35".to_string(),
1305                ));
1306            }
1307            let pattern = Regex::new(
1308                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1309            )
1310            .unwrap();
1311            if !pattern.is_match(val) {
1312                return Err(ValidationError::new(
1313                    1005,
1314                    "issr does not match the required pattern".to_string(),
1315                ));
1316            }
1317        }
1318        Ok(())
1319    }
1320}
1321
1322// DocumentType3Code: Document is a structured communication reference provided by the creditor to identify the referred transaction.
1323#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1324pub enum DocumentType3Code {
1325    #[default]
1326    #[serde(rename = "RADM")]
1327    CodeRADM,
1328    #[serde(rename = "RPIN")]
1329    CodeRPIN,
1330    #[serde(rename = "FXDR")]
1331    CodeFXDR,
1332    #[serde(rename = "DISP")]
1333    CodeDISP,
1334    #[serde(rename = "PUOR")]
1335    CodePUOR,
1336    #[serde(rename = "SCOR")]
1337    CodeSCOR,
1338}
1339
1340impl DocumentType3Code {
1341    pub fn validate(&self) -> Result<(), ValidationError> {
1342        Ok(())
1343    }
1344}
1345
1346// DocumentType6Code: Document is a purchase order.
1347#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1348pub enum DocumentType6Code {
1349    #[default]
1350    #[serde(rename = "MSIN")]
1351    CodeMSIN,
1352    #[serde(rename = "CNFA")]
1353    CodeCNFA,
1354    #[serde(rename = "DNFA")]
1355    CodeDNFA,
1356    #[serde(rename = "CINV")]
1357    CodeCINV,
1358    #[serde(rename = "CREN")]
1359    CodeCREN,
1360    #[serde(rename = "DEBN")]
1361    CodeDEBN,
1362    #[serde(rename = "HIRI")]
1363    CodeHIRI,
1364    #[serde(rename = "SBIN")]
1365    CodeSBIN,
1366    #[serde(rename = "CMCN")]
1367    CodeCMCN,
1368    #[serde(rename = "SOAC")]
1369    CodeSOAC,
1370    #[serde(rename = "DISP")]
1371    CodeDISP,
1372    #[serde(rename = "BOLD")]
1373    CodeBOLD,
1374    #[serde(rename = "VCHR")]
1375    CodeVCHR,
1376    #[serde(rename = "AROI")]
1377    CodeAROI,
1378    #[serde(rename = "TSUT")]
1379    CodeTSUT,
1380    #[serde(rename = "PUOR")]
1381    CodePUOR,
1382}
1383
1384impl DocumentType6Code {
1385    pub fn validate(&self) -> Result<(), ValidationError> {
1386        Ok(())
1387    }
1388}
1389
1390// FinancialInstitutionCreditTransferV08: Set of elements providing information specific to the individual credit transfer(s).
1391#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1392pub struct FinancialInstitutionCreditTransferV08 {
1393    #[serde(rename = "GrpHdr")]
1394    pub grp_hdr: GroupHeader931,
1395    #[serde(rename = "CdtTrfTxInf")]
1396    pub cdt_trf_tx_inf: CreditTransferTransaction361,
1397}
1398
1399impl FinancialInstitutionCreditTransferV08 {
1400    pub fn validate(&self) -> Result<(), ValidationError> {
1401        self.grp_hdr.validate()?;
1402        self.cdt_trf_tx_inf.validate()?;
1403        Ok(())
1404    }
1405}
1406
1407// FinancialInstitutionIdentification181: Information that locates and identifies a specific address, as defined by postal services.
1408#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1409pub struct FinancialInstitutionIdentification181 {
1410    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1411    pub bicfi: Option<String>,
1412    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1413    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
1414    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1415    pub lei: Option<String>,
1416    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1417    pub nm: Option<String>,
1418    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1419    pub pstl_adr: Option<PostalAddress241>,
1420}
1421
1422impl FinancialInstitutionIdentification181 {
1423    pub fn validate(&self) -> Result<(), ValidationError> {
1424        if let Some(ref val) = self.bicfi {
1425            let pattern =
1426                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1427            if !pattern.is_match(val) {
1428                return Err(ValidationError::new(
1429                    1005,
1430                    "bicfi does not match the required pattern".to_string(),
1431                ));
1432            }
1433        }
1434        if let Some(ref val) = self.clr_sys_mmb_id {
1435            val.validate()?
1436        }
1437        if let Some(ref val) = self.lei {
1438            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1439            if !pattern.is_match(val) {
1440                return Err(ValidationError::new(
1441                    1005,
1442                    "lei does not match the required pattern".to_string(),
1443                ));
1444            }
1445        }
1446        if let Some(ref val) = self.nm {
1447            if val.chars().count() < 1 {
1448                return Err(ValidationError::new(
1449                    1001,
1450                    "nm is shorter than the minimum length of 1".to_string(),
1451                ));
1452            }
1453            if val.chars().count() > 140 {
1454                return Err(ValidationError::new(
1455                    1002,
1456                    "nm exceeds the maximum length of 140".to_string(),
1457                ));
1458            }
1459            let pattern = Regex::new(
1460                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1461            )
1462            .unwrap();
1463            if !pattern.is_match(val) {
1464                return Err(ValidationError::new(
1465                    1005,
1466                    "nm does not match the required pattern".to_string(),
1467                ));
1468            }
1469        }
1470        if let Some(ref val) = self.pstl_adr {
1471            val.validate()?
1472        }
1473        Ok(())
1474    }
1475}
1476
1477// FinancialInstitutionIdentification182: Legal entity identifier of the financial institution.
1478#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1479pub struct FinancialInstitutionIdentification182 {
1480    #[serde(rename = "BICFI")]
1481    pub bicfi: String,
1482    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1483    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
1484    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1485    pub lei: Option<String>,
1486}
1487
1488impl FinancialInstitutionIdentification182 {
1489    pub fn validate(&self) -> Result<(), ValidationError> {
1490        let pattern =
1491            Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1492        if !pattern.is_match(&self.bicfi) {
1493            return Err(ValidationError::new(
1494                1005,
1495                "bicfi does not match the required pattern".to_string(),
1496            ));
1497        }
1498        if let Some(ref val) = self.clr_sys_mmb_id {
1499            val.validate()?
1500        }
1501        if let Some(ref val) = self.lei {
1502            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1503            if !pattern.is_match(val) {
1504                return Err(ValidationError::new(
1505                    1005,
1506                    "lei does not match the required pattern".to_string(),
1507                ));
1508            }
1509        }
1510        Ok(())
1511    }
1512}
1513
1514// Garnishment31: Indicates if the employment of the person to whom the garnishment applies (that is, the ultimate debtor) has been terminated.
1515#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1516pub struct Garnishment31 {
1517    #[serde(rename = "Tp")]
1518    pub tp: GarnishmentType11,
1519    #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
1520    pub grnshee: Option<PartyIdentification1354>,
1521    #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
1522    pub grnshmt_admstr: Option<PartyIdentification1354>,
1523    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
1524    pub ref_nb: Option<String>,
1525    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
1526    pub dt: Option<String>,
1527    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
1528    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1529    #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
1530    pub fmly_mdcl_insrnc_ind: Option<bool>,
1531    #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
1532    pub mplyee_termntn_ind: Option<bool>,
1533}
1534
1535impl Garnishment31 {
1536    pub fn validate(&self) -> Result<(), ValidationError> {
1537        self.tp.validate()?;
1538        if let Some(ref val) = self.grnshee {
1539            val.validate()?
1540        }
1541        if let Some(ref val) = self.grnshmt_admstr {
1542            val.validate()?
1543        }
1544        if let Some(ref val) = self.ref_nb {
1545            if val.chars().count() < 1 {
1546                return Err(ValidationError::new(
1547                    1001,
1548                    "ref_nb is shorter than the minimum length of 1".to_string(),
1549                ));
1550            }
1551            if val.chars().count() > 140 {
1552                return Err(ValidationError::new(
1553                    1002,
1554                    "ref_nb exceeds the maximum length of 140".to_string(),
1555                ));
1556            }
1557            let pattern = Regex::new(
1558                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1559            )
1560            .unwrap();
1561            if !pattern.is_match(val) {
1562                return Err(ValidationError::new(
1563                    1005,
1564                    "ref_nb does not match the required pattern".to_string(),
1565                ));
1566            }
1567        }
1568        if let Some(ref val) = self.rmtd_amt {
1569            val.validate()?
1570        }
1571        Ok(())
1572    }
1573}
1574
1575// GarnishmentType1Choice1: Proprietary identification of the type of garnishment.
1576#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1577pub struct GarnishmentType1Choice1 {
1578    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1579    pub cd: Option<String>,
1580    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1581    pub prtry: Option<String>,
1582}
1583
1584impl GarnishmentType1Choice1 {
1585    pub fn validate(&self) -> Result<(), ValidationError> {
1586        if let Some(ref val) = self.cd {
1587            if val.chars().count() < 1 {
1588                return Err(ValidationError::new(
1589                    1001,
1590                    "cd is shorter than the minimum length of 1".to_string(),
1591                ));
1592            }
1593            if val.chars().count() > 4 {
1594                return Err(ValidationError::new(
1595                    1002,
1596                    "cd exceeds the maximum length of 4".to_string(),
1597                ));
1598            }
1599        }
1600        if let Some(ref val) = self.prtry {
1601            if val.chars().count() < 1 {
1602                return Err(ValidationError::new(
1603                    1001,
1604                    "prtry is shorter than the minimum length of 1".to_string(),
1605                ));
1606            }
1607            if val.chars().count() > 35 {
1608                return Err(ValidationError::new(
1609                    1002,
1610                    "prtry exceeds the maximum length of 35".to_string(),
1611                ));
1612            }
1613            let pattern = Regex::new(
1614                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1615            )
1616            .unwrap();
1617            if !pattern.is_match(val) {
1618                return Err(ValidationError::new(
1619                    1005,
1620                    "prtry does not match the required pattern".to_string(),
1621                ));
1622            }
1623        }
1624        Ok(())
1625    }
1626}
1627
1628// GarnishmentType11: Identification of the issuer of the garnishment type.
1629#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1630pub struct GarnishmentType11 {
1631    #[serde(rename = "CdOrPrtry")]
1632    pub cd_or_prtry: GarnishmentType1Choice1,
1633    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1634    pub issr: Option<String>,
1635}
1636
1637impl GarnishmentType11 {
1638    pub fn validate(&self) -> Result<(), ValidationError> {
1639        self.cd_or_prtry.validate()?;
1640        if let Some(ref val) = self.issr {
1641            if val.chars().count() < 1 {
1642                return Err(ValidationError::new(
1643                    1001,
1644                    "issr is shorter than the minimum length of 1".to_string(),
1645                ));
1646            }
1647            if val.chars().count() > 35 {
1648                return Err(ValidationError::new(
1649                    1002,
1650                    "issr exceeds the maximum length of 35".to_string(),
1651                ));
1652            }
1653            let pattern = Regex::new(
1654                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1655            )
1656            .unwrap();
1657            if !pattern.is_match(val) {
1658                return Err(ValidationError::new(
1659                    1005,
1660                    "issr does not match the required pattern".to_string(),
1661                ));
1662            }
1663        }
1664        Ok(())
1665    }
1666}
1667
1668// GenericAccountIdentification11: Entity that assigns the identification.
1669#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1670pub struct GenericAccountIdentification11 {
1671    #[serde(rename = "Id")]
1672    pub id: String,
1673    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1674    pub schme_nm: Option<AccountSchemeName1Choice1>,
1675    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1676    pub issr: Option<String>,
1677}
1678
1679impl GenericAccountIdentification11 {
1680    pub fn validate(&self) -> Result<(), ValidationError> {
1681        if self.id.chars().count() < 1 {
1682            return Err(ValidationError::new(
1683                1001,
1684                "id is shorter than the minimum length of 1".to_string(),
1685            ));
1686        }
1687        if self.id.chars().count() > 34 {
1688            return Err(ValidationError::new(
1689                1002,
1690                "id exceeds the maximum length of 34".to_string(),
1691            ));
1692        }
1693        let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
1694        if !pattern.is_match(&self.id) {
1695            return Err(ValidationError::new(
1696                1005,
1697                "id does not match the required pattern".to_string(),
1698            ));
1699        }
1700        if let Some(ref val) = self.schme_nm {
1701            val.validate()?
1702        }
1703        if let Some(ref val) = self.issr {
1704            if val.chars().count() < 1 {
1705                return Err(ValidationError::new(
1706                    1001,
1707                    "issr is shorter than the minimum length of 1".to_string(),
1708                ));
1709            }
1710            if val.chars().count() > 35 {
1711                return Err(ValidationError::new(
1712                    1002,
1713                    "issr exceeds the maximum length of 35".to_string(),
1714                ));
1715            }
1716            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1717            if !pattern.is_match(val) {
1718                return Err(ValidationError::new(
1719                    1005,
1720                    "issr does not match the required pattern".to_string(),
1721                ));
1722            }
1723        }
1724        Ok(())
1725    }
1726}
1727
1728// GenericOrganisationIdentification11: Entity that assigns the identification.
1729#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1730pub struct GenericOrganisationIdentification11 {
1731    #[serde(rename = "Id")]
1732    pub id: String,
1733    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1734    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
1735    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1736    pub issr: Option<String>,
1737}
1738
1739impl GenericOrganisationIdentification11 {
1740    pub fn validate(&self) -> Result<(), ValidationError> {
1741        if self.id.chars().count() < 1 {
1742            return Err(ValidationError::new(
1743                1001,
1744                "id is shorter than the minimum length of 1".to_string(),
1745            ));
1746        }
1747        if self.id.chars().count() > 35 {
1748            return Err(ValidationError::new(
1749                1002,
1750                "id exceeds the maximum length of 35".to_string(),
1751            ));
1752        }
1753        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1754        if !pattern.is_match(&self.id) {
1755            return Err(ValidationError::new(
1756                1005,
1757                "id does not match the required pattern".to_string(),
1758            ));
1759        }
1760        if let Some(ref val) = self.schme_nm {
1761            val.validate()?
1762        }
1763        if let Some(ref val) = self.issr {
1764            if val.chars().count() < 1 {
1765                return Err(ValidationError::new(
1766                    1001,
1767                    "issr is shorter than the minimum length of 1".to_string(),
1768                ));
1769            }
1770            if val.chars().count() > 35 {
1771                return Err(ValidationError::new(
1772                    1002,
1773                    "issr exceeds the maximum length of 35".to_string(),
1774                ));
1775            }
1776            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1777            if !pattern.is_match(val) {
1778                return Err(ValidationError::new(
1779                    1005,
1780                    "issr does not match the required pattern".to_string(),
1781                ));
1782            }
1783        }
1784        Ok(())
1785    }
1786}
1787
1788// GenericOrganisationIdentification12: Entity that assigns the identification.
1789#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1790pub struct GenericOrganisationIdentification12 {
1791    #[serde(rename = "Id")]
1792    pub id: String,
1793    #[serde(rename = "SchmeNm")]
1794    pub schme_nm: OrganisationIdentificationSchemeName1Choice2,
1795    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1796    pub issr: Option<String>,
1797}
1798
1799impl GenericOrganisationIdentification12 {
1800    pub fn validate(&self) -> Result<(), ValidationError> {
1801        if self.id.chars().count() < 1 {
1802            return Err(ValidationError::new(
1803                1001,
1804                "id is shorter than the minimum length of 1".to_string(),
1805            ));
1806        }
1807        if self.id.chars().count() > 35 {
1808            return Err(ValidationError::new(
1809                1002,
1810                "id exceeds the maximum length of 35".to_string(),
1811            ));
1812        }
1813        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1814        if !pattern.is_match(&self.id) {
1815            return Err(ValidationError::new(
1816                1005,
1817                "id does not match the required pattern".to_string(),
1818            ));
1819        }
1820        self.schme_nm.validate()?;
1821        if let Some(ref val) = self.issr {
1822            if val.chars().count() < 1 {
1823                return Err(ValidationError::new(
1824                    1001,
1825                    "issr is shorter than the minimum length of 1".to_string(),
1826                ));
1827            }
1828            if val.chars().count() > 35 {
1829                return Err(ValidationError::new(
1830                    1002,
1831                    "issr exceeds the maximum length of 35".to_string(),
1832                ));
1833            }
1834            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1835            if !pattern.is_match(val) {
1836                return Err(ValidationError::new(
1837                    1005,
1838                    "issr does not match the required pattern".to_string(),
1839                ));
1840            }
1841        }
1842        Ok(())
1843    }
1844}
1845
1846// GenericOrganisationIdentification13: Entity that assigns the identification.
1847#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1848pub struct GenericOrganisationIdentification13 {
1849    #[serde(rename = "Id")]
1850    pub id: String,
1851    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1852    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice3>,
1853    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1854    pub issr: Option<String>,
1855}
1856
1857impl GenericOrganisationIdentification13 {
1858    pub fn validate(&self) -> Result<(), ValidationError> {
1859        if self.id.chars().count() < 1 {
1860            return Err(ValidationError::new(
1861                1001,
1862                "id is shorter than the minimum length of 1".to_string(),
1863            ));
1864        }
1865        if self.id.chars().count() > 35 {
1866            return Err(ValidationError::new(
1867                1002,
1868                "id exceeds the maximum length of 35".to_string(),
1869            ));
1870        }
1871        let pattern =
1872            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
1873                .unwrap();
1874        if !pattern.is_match(&self.id) {
1875            return Err(ValidationError::new(
1876                1005,
1877                "id does not match the required pattern".to_string(),
1878            ));
1879        }
1880        if let Some(ref val) = self.schme_nm {
1881            val.validate()?
1882        }
1883        if let Some(ref val) = self.issr {
1884            if val.chars().count() < 1 {
1885                return Err(ValidationError::new(
1886                    1001,
1887                    "issr is shorter than the minimum length of 1".to_string(),
1888                ));
1889            }
1890            if val.chars().count() > 35 {
1891                return Err(ValidationError::new(
1892                    1002,
1893                    "issr exceeds the maximum length of 35".to_string(),
1894                ));
1895            }
1896            let pattern = Regex::new(
1897                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1898            )
1899            .unwrap();
1900            if !pattern.is_match(val) {
1901                return Err(ValidationError::new(
1902                    1005,
1903                    "issr does not match the required pattern".to_string(),
1904                ));
1905            }
1906        }
1907        Ok(())
1908    }
1909}
1910
1911// GenericPersonIdentification11: Entity that assigns the identification.
1912#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1913pub struct GenericPersonIdentification11 {
1914    #[serde(rename = "Id")]
1915    pub id: String,
1916    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1917    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
1918    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1919    pub issr: Option<String>,
1920}
1921
1922impl GenericPersonIdentification11 {
1923    pub fn validate(&self) -> Result<(), ValidationError> {
1924        if self.id.chars().count() < 1 {
1925            return Err(ValidationError::new(
1926                1001,
1927                "id is shorter than the minimum length of 1".to_string(),
1928            ));
1929        }
1930        if self.id.chars().count() > 35 {
1931            return Err(ValidationError::new(
1932                1002,
1933                "id exceeds the maximum length of 35".to_string(),
1934            ));
1935        }
1936        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1937        if !pattern.is_match(&self.id) {
1938            return Err(ValidationError::new(
1939                1005,
1940                "id does not match the required pattern".to_string(),
1941            ));
1942        }
1943        if let Some(ref val) = self.schme_nm {
1944            val.validate()?
1945        }
1946        if let Some(ref val) = self.issr {
1947            if val.chars().count() < 1 {
1948                return Err(ValidationError::new(
1949                    1001,
1950                    "issr is shorter than the minimum length of 1".to_string(),
1951                ));
1952            }
1953            if val.chars().count() > 35 {
1954                return Err(ValidationError::new(
1955                    1002,
1956                    "issr exceeds the maximum length of 35".to_string(),
1957                ));
1958            }
1959            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1960            if !pattern.is_match(val) {
1961                return Err(ValidationError::new(
1962                    1005,
1963                    "issr does not match the required pattern".to_string(),
1964                ));
1965            }
1966        }
1967        Ok(())
1968    }
1969}
1970
1971// GenericPersonIdentification12: Entity that assigns the identification.
1972#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1973pub struct GenericPersonIdentification12 {
1974    #[serde(rename = "Id")]
1975    pub id: String,
1976    #[serde(rename = "SchmeNm")]
1977    pub schme_nm: PersonIdentificationSchemeName1Choice2,
1978    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1979    pub issr: Option<String>,
1980}
1981
1982impl GenericPersonIdentification12 {
1983    pub fn validate(&self) -> Result<(), ValidationError> {
1984        if self.id.chars().count() < 1 {
1985            return Err(ValidationError::new(
1986                1001,
1987                "id is shorter than the minimum length of 1".to_string(),
1988            ));
1989        }
1990        if self.id.chars().count() > 35 {
1991            return Err(ValidationError::new(
1992                1002,
1993                "id exceeds the maximum length of 35".to_string(),
1994            ));
1995        }
1996        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1997        if !pattern.is_match(&self.id) {
1998            return Err(ValidationError::new(
1999                1005,
2000                "id does not match the required pattern".to_string(),
2001            ));
2002        }
2003        self.schme_nm.validate()?;
2004        if let Some(ref val) = self.issr {
2005            if val.chars().count() < 1 {
2006                return Err(ValidationError::new(
2007                    1001,
2008                    "issr is shorter than the minimum length of 1".to_string(),
2009                ));
2010            }
2011            if val.chars().count() > 35 {
2012                return Err(ValidationError::new(
2013                    1002,
2014                    "issr exceeds the maximum length of 35".to_string(),
2015                ));
2016            }
2017            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2018            if !pattern.is_match(val) {
2019                return Err(ValidationError::new(
2020                    1005,
2021                    "issr does not match the required pattern".to_string(),
2022                ));
2023            }
2024        }
2025        Ok(())
2026    }
2027}
2028
2029// GenericPersonIdentification13: Entity that assigns the identification.
2030#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2031pub struct GenericPersonIdentification13 {
2032    #[serde(rename = "Id")]
2033    pub id: String,
2034    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2035    pub schme_nm: Option<PersonIdentificationSchemeName1Choice3>,
2036    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2037    pub issr: Option<String>,
2038}
2039
2040impl GenericPersonIdentification13 {
2041    pub fn validate(&self) -> Result<(), ValidationError> {
2042        if self.id.chars().count() < 1 {
2043            return Err(ValidationError::new(
2044                1001,
2045                "id is shorter than the minimum length of 1".to_string(),
2046            ));
2047        }
2048        if self.id.chars().count() > 35 {
2049            return Err(ValidationError::new(
2050                1002,
2051                "id exceeds the maximum length of 35".to_string(),
2052            ));
2053        }
2054        let pattern =
2055            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
2056                .unwrap();
2057        if !pattern.is_match(&self.id) {
2058            return Err(ValidationError::new(
2059                1005,
2060                "id does not match the required pattern".to_string(),
2061            ));
2062        }
2063        if let Some(ref val) = self.schme_nm {
2064            val.validate()?
2065        }
2066        if let Some(ref val) = self.issr {
2067            if val.chars().count() < 1 {
2068                return Err(ValidationError::new(
2069                    1001,
2070                    "issr is shorter than the minimum length of 1".to_string(),
2071                ));
2072            }
2073            if val.chars().count() > 35 {
2074                return Err(ValidationError::new(
2075                    1002,
2076                    "issr exceeds the maximum length of 35".to_string(),
2077                ));
2078            }
2079            let pattern = Regex::new(
2080                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2081            )
2082            .unwrap();
2083            if !pattern.is_match(val) {
2084                return Err(ValidationError::new(
2085                    1005,
2086                    "issr does not match the required pattern".to_string(),
2087                ));
2088            }
2089        }
2090        Ok(())
2091    }
2092}
2093
2094// GroupHeader931: Specifies the details on how the settlement of the transaction(s) between the instructing agent and the instructed agent is completed.
2095#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2096pub struct GroupHeader931 {
2097    #[serde(rename = "MsgId")]
2098    pub msg_id: String,
2099    #[serde(rename = "CreDtTm")]
2100    pub cre_dt_tm: String,
2101    #[serde(rename = "NbOfTxs")]
2102    pub nb_of_txs: Max15NumericTextfixed,
2103    #[serde(rename = "SttlmInf")]
2104    pub sttlm_inf: SettlementInstruction71,
2105}
2106
2107impl GroupHeader931 {
2108    pub fn validate(&self) -> Result<(), ValidationError> {
2109        if self.msg_id.chars().count() < 1 {
2110            return Err(ValidationError::new(
2111                1001,
2112                "msg_id is shorter than the minimum length of 1".to_string(),
2113            ));
2114        }
2115        if self.msg_id.chars().count() > 35 {
2116            return Err(ValidationError::new(
2117                1002,
2118                "msg_id exceeds the maximum length of 35".to_string(),
2119            ));
2120        }
2121        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2122        if !pattern.is_match(&self.msg_id) {
2123            return Err(ValidationError::new(
2124                1005,
2125                "msg_id does not match the required pattern".to_string(),
2126            ));
2127        }
2128        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2129        if !pattern.is_match(&self.cre_dt_tm) {
2130            return Err(ValidationError::new(
2131                1005,
2132                "cre_dt_tm does not match the required pattern".to_string(),
2133            ));
2134        }
2135        self.nb_of_txs.validate()?;
2136        self.sttlm_inf.validate()?;
2137        Ok(())
2138    }
2139}
2140
2141// Instruction5Code: Please advise/contact (ultimate) creditor/claimant by the most efficient means of telecommunication.
2142#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2143pub enum Instruction5Code {
2144    #[default]
2145    #[serde(rename = "PHOB")]
2146    CodePHOB,
2147    #[serde(rename = "TELB")]
2148    CodeTELB,
2149}
2150
2151impl Instruction5Code {
2152    pub fn validate(&self) -> Result<(), ValidationError> {
2153        Ok(())
2154    }
2155}
2156
2157// InstructionForCreditorAgent11: Further information complementing the coded instruction or instruction to the creditor's agent that is bilaterally agreed or specific to a user community.
2158#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2159pub struct InstructionForCreditorAgent11 {
2160    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2161    pub instr_inf: Option<String>,
2162}
2163
2164impl InstructionForCreditorAgent11 {
2165    pub fn validate(&self) -> Result<(), ValidationError> {
2166        if let Some(ref val) = self.instr_inf {
2167            if val.chars().count() < 1 {
2168                return Err(ValidationError::new(
2169                    1001,
2170                    "instr_inf is shorter than the minimum length of 1".to_string(),
2171                ));
2172            }
2173            if val.chars().count() > 140 {
2174                return Err(ValidationError::new(
2175                    1002,
2176                    "instr_inf exceeds the maximum length of 140".to_string(),
2177                ));
2178            }
2179            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2180            if !pattern.is_match(val) {
2181                return Err(ValidationError::new(
2182                    1005,
2183                    "instr_inf does not match the required pattern".to_string(),
2184                ));
2185            }
2186        }
2187        Ok(())
2188    }
2189}
2190
2191// InstructionForCreditorAgent21: Further information complementing the coded instruction or instruction to the creditor's agent that is bilaterally agreed or specific to a user community.
2192#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2193pub struct InstructionForCreditorAgent21 {
2194    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2195    pub cd: Option<Instruction5Code>,
2196    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2197    pub instr_inf: Option<String>,
2198}
2199
2200impl InstructionForCreditorAgent21 {
2201    pub fn validate(&self) -> Result<(), ValidationError> {
2202        if let Some(ref val) = self.cd {
2203            val.validate()?
2204        }
2205        if let Some(ref val) = self.instr_inf {
2206            if val.chars().count() < 1 {
2207                return Err(ValidationError::new(
2208                    1001,
2209                    "instr_inf is shorter than the minimum length of 1".to_string(),
2210                ));
2211            }
2212            if val.chars().count() > 140 {
2213                return Err(ValidationError::new(
2214                    1002,
2215                    "instr_inf exceeds the maximum length of 140".to_string(),
2216                ));
2217            }
2218            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2219            if !pattern.is_match(val) {
2220                return Err(ValidationError::new(
2221                    1005,
2222                    "instr_inf does not match the required pattern".to_string(),
2223                ));
2224            }
2225        }
2226        Ok(())
2227    }
2228}
2229
2230// InstructionForNextAgent11: Further information complementing the coded instruction or instruction to the next agent that is bilaterally agreed or specific to a user community.
2231#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2232pub struct InstructionForNextAgent11 {
2233    #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2234    pub instr_inf: Option<String>,
2235}
2236
2237impl InstructionForNextAgent11 {
2238    pub fn validate(&self) -> Result<(), ValidationError> {
2239        if let Some(ref val) = self.instr_inf {
2240            if val.chars().count() < 1 {
2241                return Err(ValidationError::new(
2242                    1001,
2243                    "instr_inf is shorter than the minimum length of 1".to_string(),
2244                ));
2245            }
2246            if val.chars().count() > 35 {
2247                return Err(ValidationError::new(
2248                    1002,
2249                    "instr_inf exceeds the maximum length of 35".to_string(),
2250                ));
2251            }
2252            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2253            if !pattern.is_match(val) {
2254                return Err(ValidationError::new(
2255                    1005,
2256                    "instr_inf does not match the required pattern".to_string(),
2257                ));
2258            }
2259        }
2260        Ok(())
2261    }
2262}
2263
2264// LocalInstrument2Choice1: Specifies the local instrument, as a proprietary code.
2265#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2266pub struct LocalInstrument2Choice1 {
2267    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2268    pub cd: Option<String>,
2269    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2270    pub prtry: Option<String>,
2271}
2272
2273impl LocalInstrument2Choice1 {
2274    pub fn validate(&self) -> Result<(), ValidationError> {
2275        if let Some(ref val) = self.cd {
2276            if val.chars().count() < 1 {
2277                return Err(ValidationError::new(
2278                    1001,
2279                    "cd is shorter than the minimum length of 1".to_string(),
2280                ));
2281            }
2282            if val.chars().count() > 35 {
2283                return Err(ValidationError::new(
2284                    1002,
2285                    "cd exceeds the maximum length of 35".to_string(),
2286                ));
2287            }
2288        }
2289        if let Some(ref val) = self.prtry {
2290            if val.chars().count() < 1 {
2291                return Err(ValidationError::new(
2292                    1001,
2293                    "prtry is shorter than the minimum length of 1".to_string(),
2294                ));
2295            }
2296            if val.chars().count() > 35 {
2297                return Err(ValidationError::new(
2298                    1002,
2299                    "prtry exceeds the maximum length of 35".to_string(),
2300                ));
2301            }
2302            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2303            if !pattern.is_match(val) {
2304                return Err(ValidationError::new(
2305                    1005,
2306                    "prtry does not match the required pattern".to_string(),
2307                ));
2308            }
2309        }
2310        Ok(())
2311    }
2312}
2313
2314// Max15NumericText_fixed: 1
2315#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2316pub enum Max15NumericTextfixed {
2317    #[default]
2318    #[serde(rename = "1")]
2319    Code1,
2320}
2321
2322impl Max15NumericTextfixed {
2323    pub fn validate(&self) -> Result<(), ValidationError> {
2324        Ok(())
2325    }
2326}
2327
2328// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
2329#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2330pub struct OrganisationIdentification291 {
2331    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2332    pub any_bic: Option<String>,
2333    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2334    pub lei: Option<String>,
2335    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2336    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
2337}
2338
2339impl OrganisationIdentification291 {
2340    pub fn validate(&self) -> Result<(), ValidationError> {
2341        if let Some(ref val) = self.any_bic {
2342            let pattern =
2343                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2344            if !pattern.is_match(val) {
2345                return Err(ValidationError::new(
2346                    1005,
2347                    "any_bic does not match the required pattern".to_string(),
2348                ));
2349            }
2350        }
2351        if let Some(ref val) = self.lei {
2352            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2353            if !pattern.is_match(val) {
2354                return Err(ValidationError::new(
2355                    1005,
2356                    "lei does not match the required pattern".to_string(),
2357                ));
2358            }
2359        }
2360        if let Some(ref vec) = self.othr {
2361            for item in vec {
2362                item.validate()?
2363            }
2364        }
2365        Ok(())
2366    }
2367}
2368
2369// OrganisationIdentification292: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
2370#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2371pub struct OrganisationIdentification292 {
2372    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2373    pub any_bic: Option<String>,
2374    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2375    pub lei: Option<String>,
2376    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2377    pub othr: Option<Vec<GenericOrganisationIdentification12>>,
2378}
2379
2380impl OrganisationIdentification292 {
2381    pub fn validate(&self) -> Result<(), ValidationError> {
2382        if let Some(ref val) = self.any_bic {
2383            let pattern =
2384                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2385            if !pattern.is_match(val) {
2386                return Err(ValidationError::new(
2387                    1005,
2388                    "any_bic does not match the required pattern".to_string(),
2389                ));
2390            }
2391        }
2392        if let Some(ref val) = self.lei {
2393            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2394            if !pattern.is_match(val) {
2395                return Err(ValidationError::new(
2396                    1005,
2397                    "lei does not match the required pattern".to_string(),
2398                ));
2399            }
2400        }
2401        if let Some(ref vec) = self.othr {
2402            for item in vec {
2403                item.validate()?
2404            }
2405        }
2406        Ok(())
2407    }
2408}
2409
2410// OrganisationIdentification293: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
2411#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2412pub struct OrganisationIdentification293 {
2413    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2414    pub any_bic: Option<String>,
2415    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2416    pub lei: Option<String>,
2417    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2418    pub othr: Option<Vec<GenericOrganisationIdentification13>>,
2419}
2420
2421impl OrganisationIdentification293 {
2422    pub fn validate(&self) -> Result<(), ValidationError> {
2423        if let Some(ref val) = self.any_bic {
2424            let pattern =
2425                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2426            if !pattern.is_match(val) {
2427                return Err(ValidationError::new(
2428                    1005,
2429                    "any_bic does not match the required pattern".to_string(),
2430                ));
2431            }
2432        }
2433        if let Some(ref val) = self.lei {
2434            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2435            if !pattern.is_match(val) {
2436                return Err(ValidationError::new(
2437                    1005,
2438                    "lei does not match the required pattern".to_string(),
2439                ));
2440            }
2441        }
2442        if let Some(ref vec) = self.othr {
2443            for item in vec {
2444                item.validate()?
2445            }
2446        }
2447        Ok(())
2448    }
2449}
2450
2451// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
2452#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2453pub struct OrganisationIdentificationSchemeName1Choice1 {
2454    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2455    pub cd: Option<String>,
2456    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2457    pub prtry: Option<String>,
2458}
2459
2460impl OrganisationIdentificationSchemeName1Choice1 {
2461    pub fn validate(&self) -> Result<(), ValidationError> {
2462        if let Some(ref val) = self.cd {
2463            if val.chars().count() < 1 {
2464                return Err(ValidationError::new(
2465                    1001,
2466                    "cd is shorter than the minimum length of 1".to_string(),
2467                ));
2468            }
2469            if val.chars().count() > 4 {
2470                return Err(ValidationError::new(
2471                    1002,
2472                    "cd exceeds the maximum length of 4".to_string(),
2473                ));
2474            }
2475        }
2476        if let Some(ref val) = self.prtry {
2477            if val.chars().count() < 1 {
2478                return Err(ValidationError::new(
2479                    1001,
2480                    "prtry is shorter than the minimum length of 1".to_string(),
2481                ));
2482            }
2483            if val.chars().count() > 35 {
2484                return Err(ValidationError::new(
2485                    1002,
2486                    "prtry exceeds the maximum length of 35".to_string(),
2487                ));
2488            }
2489            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2490            if !pattern.is_match(val) {
2491                return Err(ValidationError::new(
2492                    1005,
2493                    "prtry does not match the required pattern".to_string(),
2494                ));
2495            }
2496        }
2497        Ok(())
2498    }
2499}
2500
2501// OrganisationIdentificationSchemeName1Choice2: Name of the identification scheme, in a coded form as published in an external list.
2502#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2503pub struct OrganisationIdentificationSchemeName1Choice2 {
2504    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2505    pub cd: Option<String>,
2506}
2507
2508impl OrganisationIdentificationSchemeName1Choice2 {
2509    pub fn validate(&self) -> Result<(), ValidationError> {
2510        if let Some(ref val) = self.cd {
2511            if val.chars().count() < 1 {
2512                return Err(ValidationError::new(
2513                    1001,
2514                    "cd is shorter than the minimum length of 1".to_string(),
2515                ));
2516            }
2517            if val.chars().count() > 4 {
2518                return Err(ValidationError::new(
2519                    1002,
2520                    "cd exceeds the maximum length of 4".to_string(),
2521                ));
2522            }
2523        }
2524        Ok(())
2525    }
2526}
2527
2528// OrganisationIdentificationSchemeName1Choice3: Name of the identification scheme, in a free text form.
2529#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2530pub struct OrganisationIdentificationSchemeName1Choice3 {
2531    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2532    pub cd: Option<String>,
2533    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2534    pub prtry: Option<String>,
2535}
2536
2537impl OrganisationIdentificationSchemeName1Choice3 {
2538    pub fn validate(&self) -> Result<(), ValidationError> {
2539        if let Some(ref val) = self.cd {
2540            if val.chars().count() < 1 {
2541                return Err(ValidationError::new(
2542                    1001,
2543                    "cd is shorter than the minimum length of 1".to_string(),
2544                ));
2545            }
2546            if val.chars().count() > 4 {
2547                return Err(ValidationError::new(
2548                    1002,
2549                    "cd exceeds the maximum length of 4".to_string(),
2550                ));
2551            }
2552        }
2553        if let Some(ref val) = self.prtry {
2554            if val.chars().count() < 1 {
2555                return Err(ValidationError::new(
2556                    1001,
2557                    "prtry is shorter than the minimum length of 1".to_string(),
2558                ));
2559            }
2560            if val.chars().count() > 35 {
2561                return Err(ValidationError::new(
2562                    1002,
2563                    "prtry exceeds the maximum length of 35".to_string(),
2564                ));
2565            }
2566            let pattern = Regex::new(
2567                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2568            )
2569            .unwrap();
2570            if !pattern.is_match(val) {
2571                return Err(ValidationError::new(
2572                    1005,
2573                    "prtry does not match the required pattern".to_string(),
2574                ));
2575            }
2576        }
2577        Ok(())
2578    }
2579}
2580
2581// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
2582#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2583pub struct Party38Choice1 {
2584    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2585    pub org_id: Option<OrganisationIdentification291>,
2586    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2587    pub prvt_id: Option<PersonIdentification131>,
2588}
2589
2590impl Party38Choice1 {
2591    pub fn validate(&self) -> Result<(), ValidationError> {
2592        if let Some(ref val) = self.org_id {
2593            val.validate()?
2594        }
2595        if let Some(ref val) = self.prvt_id {
2596            val.validate()?
2597        }
2598        Ok(())
2599    }
2600}
2601
2602// Party38Choice2: Unique and unambiguous identification of a person, for example a passport.
2603#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2604pub struct Party38Choice2 {
2605    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2606    pub org_id: Option<OrganisationIdentification292>,
2607    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2608    pub prvt_id: Option<PersonIdentification132>,
2609}
2610
2611impl Party38Choice2 {
2612    pub fn validate(&self) -> Result<(), ValidationError> {
2613        if let Some(ref val) = self.org_id {
2614            val.validate()?
2615        }
2616        if let Some(ref val) = self.prvt_id {
2617            val.validate()?
2618        }
2619        Ok(())
2620    }
2621}
2622
2623// Party38Choice3: Unique and unambiguous identification of a person, for example a passport.
2624#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2625pub struct Party38Choice3 {
2626    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2627    pub org_id: Option<OrganisationIdentification293>,
2628    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2629    pub prvt_id: Option<PersonIdentification133>,
2630}
2631
2632impl Party38Choice3 {
2633    pub fn validate(&self) -> Result<(), ValidationError> {
2634        if let Some(ref val) = self.org_id {
2635            val.validate()?
2636        }
2637        if let Some(ref val) = self.prvt_id {
2638            val.validate()?
2639        }
2640        Ok(())
2641    }
2642}
2643
2644// PartyIdentification1351: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
2645#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2646pub struct PartyIdentification1351 {
2647    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2648    pub nm: Option<String>,
2649    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2650    pub pstl_adr: Option<PostalAddress242>,
2651    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2652    pub id: Option<Party38Choice1>,
2653    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2654    pub ctry_of_res: Option<String>,
2655}
2656
2657impl PartyIdentification1351 {
2658    pub fn validate(&self) -> Result<(), ValidationError> {
2659        if let Some(ref val) = self.nm {
2660            if val.chars().count() < 1 {
2661                return Err(ValidationError::new(
2662                    1001,
2663                    "nm is shorter than the minimum length of 1".to_string(),
2664                ));
2665            }
2666            if val.chars().count() > 140 {
2667                return Err(ValidationError::new(
2668                    1002,
2669                    "nm exceeds the maximum length of 140".to_string(),
2670                ));
2671            }
2672            let pattern = Regex::new(
2673                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2674            )
2675            .unwrap();
2676            if !pattern.is_match(val) {
2677                return Err(ValidationError::new(
2678                    1005,
2679                    "nm does not match the required pattern".to_string(),
2680                ));
2681            }
2682        }
2683        if let Some(ref val) = self.pstl_adr {
2684            val.validate()?
2685        }
2686        if let Some(ref val) = self.id {
2687            val.validate()?
2688        }
2689        if let Some(ref val) = self.ctry_of_res {
2690            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2691            if !pattern.is_match(val) {
2692                return Err(ValidationError::new(
2693                    1005,
2694                    "ctry_of_res does not match the required pattern".to_string(),
2695                ));
2696            }
2697        }
2698        Ok(())
2699    }
2700}
2701
2702// PartyIdentification1352: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
2703#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2704pub struct PartyIdentification1352 {
2705    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2706    pub nm: Option<String>,
2707    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2708    pub pstl_adr: Option<PostalAddress241>,
2709    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2710    pub id: Option<Party38Choice2>,
2711    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2712    pub ctry_of_res: Option<String>,
2713}
2714
2715impl PartyIdentification1352 {
2716    pub fn validate(&self) -> Result<(), ValidationError> {
2717        if let Some(ref val) = self.nm {
2718            if val.chars().count() < 1 {
2719                return Err(ValidationError::new(
2720                    1001,
2721                    "nm is shorter than the minimum length of 1".to_string(),
2722                ));
2723            }
2724            if val.chars().count() > 140 {
2725                return Err(ValidationError::new(
2726                    1002,
2727                    "nm exceeds the maximum length of 140".to_string(),
2728                ));
2729            }
2730            let pattern = Regex::new(
2731                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2732            )
2733            .unwrap();
2734            if !pattern.is_match(val) {
2735                return Err(ValidationError::new(
2736                    1005,
2737                    "nm does not match the required pattern".to_string(),
2738                ));
2739            }
2740        }
2741        if let Some(ref val) = self.pstl_adr {
2742            val.validate()?
2743        }
2744        if let Some(ref val) = self.id {
2745            val.validate()?
2746        }
2747        if let Some(ref val) = self.ctry_of_res {
2748            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2749            if !pattern.is_match(val) {
2750                return Err(ValidationError::new(
2751                    1005,
2752                    "ctry_of_res does not match the required pattern".to_string(),
2753                ));
2754            }
2755        }
2756        Ok(())
2757    }
2758}
2759
2760// PartyIdentification1353: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
2761#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2762pub struct PartyIdentification1353 {
2763    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2764    pub nm: Option<String>,
2765    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2766    pub pstl_adr: Option<PostalAddress241>,
2767    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2768    pub id: Option<Party38Choice1>,
2769    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2770    pub ctry_of_res: Option<String>,
2771}
2772
2773impl PartyIdentification1353 {
2774    pub fn validate(&self) -> Result<(), ValidationError> {
2775        if let Some(ref val) = self.nm {
2776            if val.chars().count() < 1 {
2777                return Err(ValidationError::new(
2778                    1001,
2779                    "nm is shorter than the minimum length of 1".to_string(),
2780                ));
2781            }
2782            if val.chars().count() > 140 {
2783                return Err(ValidationError::new(
2784                    1002,
2785                    "nm exceeds the maximum length of 140".to_string(),
2786                ));
2787            }
2788            let pattern = Regex::new(
2789                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2790            )
2791            .unwrap();
2792            if !pattern.is_match(val) {
2793                return Err(ValidationError::new(
2794                    1005,
2795                    "nm does not match the required pattern".to_string(),
2796                ));
2797            }
2798        }
2799        if let Some(ref val) = self.pstl_adr {
2800            val.validate()?
2801        }
2802        if let Some(ref val) = self.id {
2803            val.validate()?
2804        }
2805        if let Some(ref val) = self.ctry_of_res {
2806            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2807            if !pattern.is_match(val) {
2808                return Err(ValidationError::new(
2809                    1005,
2810                    "ctry_of_res does not match the required pattern".to_string(),
2811                ));
2812            }
2813        }
2814        Ok(())
2815    }
2816}
2817
2818// PartyIdentification1354: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
2819#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2820pub struct PartyIdentification1354 {
2821    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2822    pub nm: Option<String>,
2823    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2824    pub pstl_adr: Option<PostalAddress242>,
2825    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2826    pub id: Option<Party38Choice3>,
2827    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2828    pub ctry_of_res: Option<String>,
2829}
2830
2831impl PartyIdentification1354 {
2832    pub fn validate(&self) -> Result<(), ValidationError> {
2833        if let Some(ref val) = self.nm {
2834            if val.chars().count() < 1 {
2835                return Err(ValidationError::new(
2836                    1001,
2837                    "nm is shorter than the minimum length of 1".to_string(),
2838                ));
2839            }
2840            if val.chars().count() > 140 {
2841                return Err(ValidationError::new(
2842                    1002,
2843                    "nm exceeds the maximum length of 140".to_string(),
2844                ));
2845            }
2846            let pattern = Regex::new(
2847                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2848            )
2849            .unwrap();
2850            if !pattern.is_match(val) {
2851                return Err(ValidationError::new(
2852                    1005,
2853                    "nm does not match the required pattern".to_string(),
2854                ));
2855            }
2856        }
2857        if let Some(ref val) = self.pstl_adr {
2858            val.validate()?
2859        }
2860        if let Some(ref val) = self.id {
2861            val.validate()?
2862        }
2863        if let Some(ref val) = self.ctry_of_res {
2864            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2865            if !pattern.is_match(val) {
2866                return Err(ValidationError::new(
2867                    1005,
2868                    "ctry_of_res does not match the required pattern".to_string(),
2869                ));
2870            }
2871        }
2872        Ok(())
2873    }
2874}
2875
2876// PaymentIdentification71: Unique reference, as assigned by a clearing system, to unambiguously identify the instruction.
2877#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2878pub struct PaymentIdentification71 {
2879    #[serde(rename = "InstrId")]
2880    pub instr_id: String,
2881    #[serde(rename = "EndToEndId")]
2882    pub end_to_end_id: String,
2883    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
2884    pub tx_id: Option<String>,
2885    #[serde(rename = "UETR")]
2886    pub uetr: String,
2887    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
2888    pub clr_sys_ref: Option<String>,
2889}
2890
2891impl PaymentIdentification71 {
2892    pub fn validate(&self) -> Result<(), ValidationError> {
2893        if self.instr_id.chars().count() < 1 {
2894            return Err(ValidationError::new(
2895                1001,
2896                "instr_id is shorter than the minimum length of 1".to_string(),
2897            ));
2898        }
2899        if self.instr_id.chars().count() > 16 {
2900            return Err(ValidationError::new(
2901                1002,
2902                "instr_id exceeds the maximum length of 16".to_string(),
2903            ));
2904        }
2905        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2906        if !pattern.is_match(&self.instr_id) {
2907            return Err(ValidationError::new(
2908                1005,
2909                "instr_id does not match the required pattern".to_string(),
2910            ));
2911        }
2912        if self.end_to_end_id.chars().count() < 1 {
2913            return Err(ValidationError::new(
2914                1001,
2915                "end_to_end_id is shorter than the minimum length of 1".to_string(),
2916            ));
2917        }
2918        if self.end_to_end_id.chars().count() > 35 {
2919            return Err(ValidationError::new(
2920                1002,
2921                "end_to_end_id exceeds the maximum length of 35".to_string(),
2922            ));
2923        }
2924        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2925        if !pattern.is_match(&self.end_to_end_id) {
2926            return Err(ValidationError::new(
2927                1005,
2928                "end_to_end_id does not match the required pattern".to_string(),
2929            ));
2930        }
2931        if let Some(ref val) = self.tx_id {
2932            if val.chars().count() < 1 {
2933                return Err(ValidationError::new(
2934                    1001,
2935                    "tx_id is shorter than the minimum length of 1".to_string(),
2936                ));
2937            }
2938            if val.chars().count() > 35 {
2939                return Err(ValidationError::new(
2940                    1002,
2941                    "tx_id exceeds the maximum length of 35".to_string(),
2942                ));
2943            }
2944            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2945            if !pattern.is_match(val) {
2946                return Err(ValidationError::new(
2947                    1005,
2948                    "tx_id does not match the required pattern".to_string(),
2949                ));
2950            }
2951        }
2952        let pattern =
2953            Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
2954                .unwrap();
2955        if !pattern.is_match(&self.uetr) {
2956            return Err(ValidationError::new(
2957                1005,
2958                "uetr does not match the required pattern".to_string(),
2959            ));
2960        }
2961        if let Some(ref val) = self.clr_sys_ref {
2962            if val.chars().count() < 1 {
2963                return Err(ValidationError::new(
2964                    1001,
2965                    "clr_sys_ref is shorter than the minimum length of 1".to_string(),
2966                ));
2967            }
2968            if val.chars().count() > 35 {
2969                return Err(ValidationError::new(
2970                    1002,
2971                    "clr_sys_ref exceeds the maximum length of 35".to_string(),
2972                ));
2973            }
2974            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2975            if !pattern.is_match(val) {
2976                return Err(ValidationError::new(
2977                    1005,
2978                    "clr_sys_ref does not match the required pattern".to_string(),
2979                ));
2980            }
2981        }
2982        Ok(())
2983    }
2984}
2985
2986// PaymentTypeInformation281: Specifies the high level purpose of the instruction based on a set of pre-defined categories.
2987// Usage: This is used by the initiating party to provide information concerning the processing of the payment. It is likely to trigger special processing by any of the agents involved in the payment chain.
2988#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2989pub struct PaymentTypeInformation281 {
2990    #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
2991    pub instr_prty: Option<Priority2Code>,
2992    #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
2993    pub clr_chanl: Option<ClearingChannel2Code>,
2994    #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
2995    pub svc_lvl: Option<Vec<ServiceLevel8Choice1>>,
2996    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2997    pub lcl_instrm: Option<LocalInstrument2Choice1>,
2998    #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
2999    pub ctgy_purp: Option<CategoryPurpose1Choice1>,
3000}
3001
3002impl PaymentTypeInformation281 {
3003    pub fn validate(&self) -> Result<(), ValidationError> {
3004        if let Some(ref val) = self.instr_prty {
3005            val.validate()?
3006        }
3007        if let Some(ref val) = self.clr_chanl {
3008            val.validate()?
3009        }
3010        if let Some(ref vec) = self.svc_lvl {
3011            for item in vec {
3012                item.validate()?
3013            }
3014        }
3015        if let Some(ref val) = self.lcl_instrm {
3016            val.validate()?
3017        }
3018        if let Some(ref val) = self.ctgy_purp {
3019            val.validate()?
3020        }
3021        Ok(())
3022    }
3023}
3024
3025// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
3026#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3027pub struct PersonIdentification131 {
3028    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3029    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3030    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3031    pub othr: Option<Vec<GenericPersonIdentification11>>,
3032}
3033
3034impl PersonIdentification131 {
3035    pub fn validate(&self) -> Result<(), ValidationError> {
3036        if let Some(ref val) = self.dt_and_plc_of_birth {
3037            val.validate()?
3038        }
3039        if let Some(ref vec) = self.othr {
3040            for item in vec {
3041                item.validate()?
3042            }
3043        }
3044        Ok(())
3045    }
3046}
3047
3048// PersonIdentification132: Unique identification of a person, as assigned by an institution, using an identification scheme.
3049#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3050pub struct PersonIdentification132 {
3051    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3052    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3053    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3054    pub othr: Option<Vec<GenericPersonIdentification12>>,
3055}
3056
3057impl PersonIdentification132 {
3058    pub fn validate(&self) -> Result<(), ValidationError> {
3059        if let Some(ref val) = self.dt_and_plc_of_birth {
3060            val.validate()?
3061        }
3062        if let Some(ref vec) = self.othr {
3063            for item in vec {
3064                item.validate()?
3065            }
3066        }
3067        Ok(())
3068    }
3069}
3070
3071// PersonIdentification133: Unique identification of a person, as assigned by an institution, using an identification scheme.
3072#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3073pub struct PersonIdentification133 {
3074    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3075    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3076    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3077    pub othr: Option<Vec<GenericPersonIdentification13>>,
3078}
3079
3080impl PersonIdentification133 {
3081    pub fn validate(&self) -> Result<(), ValidationError> {
3082        if let Some(ref val) = self.dt_and_plc_of_birth {
3083            val.validate()?
3084        }
3085        if let Some(ref vec) = self.othr {
3086            for item in vec {
3087                item.validate()?
3088            }
3089        }
3090        Ok(())
3091    }
3092}
3093
3094// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
3095#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3096pub struct PersonIdentificationSchemeName1Choice1 {
3097    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3098    pub cd: Option<String>,
3099    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3100    pub prtry: Option<String>,
3101}
3102
3103impl PersonIdentificationSchemeName1Choice1 {
3104    pub fn validate(&self) -> Result<(), ValidationError> {
3105        if let Some(ref val) = self.cd {
3106            if val.chars().count() < 1 {
3107                return Err(ValidationError::new(
3108                    1001,
3109                    "cd is shorter than the minimum length of 1".to_string(),
3110                ));
3111            }
3112            if val.chars().count() > 4 {
3113                return Err(ValidationError::new(
3114                    1002,
3115                    "cd exceeds the maximum length of 4".to_string(),
3116                ));
3117            }
3118        }
3119        if let Some(ref val) = self.prtry {
3120            if val.chars().count() < 1 {
3121                return Err(ValidationError::new(
3122                    1001,
3123                    "prtry is shorter than the minimum length of 1".to_string(),
3124                ));
3125            }
3126            if val.chars().count() > 35 {
3127                return Err(ValidationError::new(
3128                    1002,
3129                    "prtry exceeds the maximum length of 35".to_string(),
3130                ));
3131            }
3132            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3133            if !pattern.is_match(val) {
3134                return Err(ValidationError::new(
3135                    1005,
3136                    "prtry does not match the required pattern".to_string(),
3137                ));
3138            }
3139        }
3140        Ok(())
3141    }
3142}
3143
3144// PersonIdentificationSchemeName1Choice2: Name of the identification scheme, in a coded form as published in an external list.
3145#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3146pub struct PersonIdentificationSchemeName1Choice2 {
3147    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3148    pub cd: Option<String>,
3149}
3150
3151impl PersonIdentificationSchemeName1Choice2 {
3152    pub fn validate(&self) -> Result<(), ValidationError> {
3153        if let Some(ref val) = self.cd {
3154            if val.chars().count() < 1 {
3155                return Err(ValidationError::new(
3156                    1001,
3157                    "cd is shorter than the minimum length of 1".to_string(),
3158                ));
3159            }
3160            if val.chars().count() > 4 {
3161                return Err(ValidationError::new(
3162                    1002,
3163                    "cd exceeds the maximum length of 4".to_string(),
3164                ));
3165            }
3166        }
3167        Ok(())
3168    }
3169}
3170
3171// PersonIdentificationSchemeName1Choice3: Name of the identification scheme, in a free text form.
3172#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3173pub struct PersonIdentificationSchemeName1Choice3 {
3174    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3175    pub cd: Option<String>,
3176    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3177    pub prtry: Option<String>,
3178}
3179
3180impl PersonIdentificationSchemeName1Choice3 {
3181    pub fn validate(&self) -> Result<(), ValidationError> {
3182        if let Some(ref val) = self.cd {
3183            if val.chars().count() < 1 {
3184                return Err(ValidationError::new(
3185                    1001,
3186                    "cd is shorter than the minimum length of 1".to_string(),
3187                ));
3188            }
3189            if val.chars().count() > 4 {
3190                return Err(ValidationError::new(
3191                    1002,
3192                    "cd exceeds the maximum length of 4".to_string(),
3193                ));
3194            }
3195        }
3196        if let Some(ref val) = self.prtry {
3197            if val.chars().count() < 1 {
3198                return Err(ValidationError::new(
3199                    1001,
3200                    "prtry is shorter than the minimum length of 1".to_string(),
3201                ));
3202            }
3203            if val.chars().count() > 35 {
3204                return Err(ValidationError::new(
3205                    1002,
3206                    "prtry exceeds the maximum length of 35".to_string(),
3207                ));
3208            }
3209            let pattern = Regex::new(
3210                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3211            )
3212            .unwrap();
3213            if !pattern.is_match(val) {
3214                return Err(ValidationError::new(
3215                    1005,
3216                    "prtry does not match the required pattern".to_string(),
3217                ));
3218            }
3219        }
3220        Ok(())
3221    }
3222}
3223
3224// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
3225#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3226pub struct PostalAddress241 {
3227    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
3228    pub dept: Option<String>,
3229    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
3230    pub sub_dept: Option<String>,
3231    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
3232    pub strt_nm: Option<String>,
3233    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
3234    pub bldg_nb: Option<String>,
3235    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
3236    pub bldg_nm: Option<String>,
3237    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
3238    pub flr: Option<String>,
3239    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
3240    pub pst_bx: Option<String>,
3241    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
3242    pub room: Option<String>,
3243    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
3244    pub pst_cd: Option<String>,
3245    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
3246    pub twn_nm: Option<String>,
3247    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
3248    pub twn_lctn_nm: Option<String>,
3249    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
3250    pub dstrct_nm: Option<String>,
3251    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
3252    pub ctry_sub_dvsn: Option<String>,
3253    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
3254    pub ctry: Option<String>,
3255    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
3256    pub adr_line: Option<Vec<String>>,
3257}
3258
3259impl PostalAddress241 {
3260    pub fn validate(&self) -> Result<(), ValidationError> {
3261        if let Some(ref val) = self.dept {
3262            if val.chars().count() < 1 {
3263                return Err(ValidationError::new(
3264                    1001,
3265                    "dept is shorter than the minimum length of 1".to_string(),
3266                ));
3267            }
3268            if val.chars().count() > 70 {
3269                return Err(ValidationError::new(
3270                    1002,
3271                    "dept exceeds the maximum length of 70".to_string(),
3272                ));
3273            }
3274            let pattern = Regex::new(
3275                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3276            )
3277            .unwrap();
3278            if !pattern.is_match(val) {
3279                return Err(ValidationError::new(
3280                    1005,
3281                    "dept does not match the required pattern".to_string(),
3282                ));
3283            }
3284        }
3285        if let Some(ref val) = self.sub_dept {
3286            if val.chars().count() < 1 {
3287                return Err(ValidationError::new(
3288                    1001,
3289                    "sub_dept is shorter than the minimum length of 1".to_string(),
3290                ));
3291            }
3292            if val.chars().count() > 70 {
3293                return Err(ValidationError::new(
3294                    1002,
3295                    "sub_dept exceeds the maximum length of 70".to_string(),
3296                ));
3297            }
3298            let pattern = Regex::new(
3299                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3300            )
3301            .unwrap();
3302            if !pattern.is_match(val) {
3303                return Err(ValidationError::new(
3304                    1005,
3305                    "sub_dept does not match the required pattern".to_string(),
3306                ));
3307            }
3308        }
3309        if let Some(ref val) = self.strt_nm {
3310            if val.chars().count() < 1 {
3311                return Err(ValidationError::new(
3312                    1001,
3313                    "strt_nm is shorter than the minimum length of 1".to_string(),
3314                ));
3315            }
3316            if val.chars().count() > 70 {
3317                return Err(ValidationError::new(
3318                    1002,
3319                    "strt_nm exceeds the maximum length of 70".to_string(),
3320                ));
3321            }
3322            let pattern = Regex::new(
3323                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3324            )
3325            .unwrap();
3326            if !pattern.is_match(val) {
3327                return Err(ValidationError::new(
3328                    1005,
3329                    "strt_nm does not match the required pattern".to_string(),
3330                ));
3331            }
3332        }
3333        if let Some(ref val) = self.bldg_nb {
3334            if val.chars().count() < 1 {
3335                return Err(ValidationError::new(
3336                    1001,
3337                    "bldg_nb is shorter than the minimum length of 1".to_string(),
3338                ));
3339            }
3340            if val.chars().count() > 16 {
3341                return Err(ValidationError::new(
3342                    1002,
3343                    "bldg_nb exceeds the maximum length of 16".to_string(),
3344                ));
3345            }
3346            let pattern = Regex::new(
3347                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3348            )
3349            .unwrap();
3350            if !pattern.is_match(val) {
3351                return Err(ValidationError::new(
3352                    1005,
3353                    "bldg_nb does not match the required pattern".to_string(),
3354                ));
3355            }
3356        }
3357        if let Some(ref val) = self.bldg_nm {
3358            if val.chars().count() < 1 {
3359                return Err(ValidationError::new(
3360                    1001,
3361                    "bldg_nm is shorter than the minimum length of 1".to_string(),
3362                ));
3363            }
3364            if val.chars().count() > 35 {
3365                return Err(ValidationError::new(
3366                    1002,
3367                    "bldg_nm exceeds the maximum length of 35".to_string(),
3368                ));
3369            }
3370            let pattern = Regex::new(
3371                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3372            )
3373            .unwrap();
3374            if !pattern.is_match(val) {
3375                return Err(ValidationError::new(
3376                    1005,
3377                    "bldg_nm does not match the required pattern".to_string(),
3378                ));
3379            }
3380        }
3381        if let Some(ref val) = self.flr {
3382            if val.chars().count() < 1 {
3383                return Err(ValidationError::new(
3384                    1001,
3385                    "flr is shorter than the minimum length of 1".to_string(),
3386                ));
3387            }
3388            if val.chars().count() > 70 {
3389                return Err(ValidationError::new(
3390                    1002,
3391                    "flr exceeds the maximum length of 70".to_string(),
3392                ));
3393            }
3394            let pattern = Regex::new(
3395                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3396            )
3397            .unwrap();
3398            if !pattern.is_match(val) {
3399                return Err(ValidationError::new(
3400                    1005,
3401                    "flr does not match the required pattern".to_string(),
3402                ));
3403            }
3404        }
3405        if let Some(ref val) = self.pst_bx {
3406            if val.chars().count() < 1 {
3407                return Err(ValidationError::new(
3408                    1001,
3409                    "pst_bx is shorter than the minimum length of 1".to_string(),
3410                ));
3411            }
3412            if val.chars().count() > 16 {
3413                return Err(ValidationError::new(
3414                    1002,
3415                    "pst_bx exceeds the maximum length of 16".to_string(),
3416                ));
3417            }
3418            let pattern = Regex::new(
3419                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3420            )
3421            .unwrap();
3422            if !pattern.is_match(val) {
3423                return Err(ValidationError::new(
3424                    1005,
3425                    "pst_bx does not match the required pattern".to_string(),
3426                ));
3427            }
3428        }
3429        if let Some(ref val) = self.room {
3430            if val.chars().count() < 1 {
3431                return Err(ValidationError::new(
3432                    1001,
3433                    "room is shorter than the minimum length of 1".to_string(),
3434                ));
3435            }
3436            if val.chars().count() > 70 {
3437                return Err(ValidationError::new(
3438                    1002,
3439                    "room exceeds the maximum length of 70".to_string(),
3440                ));
3441            }
3442            let pattern = Regex::new(
3443                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3444            )
3445            .unwrap();
3446            if !pattern.is_match(val) {
3447                return Err(ValidationError::new(
3448                    1005,
3449                    "room does not match the required pattern".to_string(),
3450                ));
3451            }
3452        }
3453        if let Some(ref val) = self.pst_cd {
3454            if val.chars().count() < 1 {
3455                return Err(ValidationError::new(
3456                    1001,
3457                    "pst_cd is shorter than the minimum length of 1".to_string(),
3458                ));
3459            }
3460            if val.chars().count() > 16 {
3461                return Err(ValidationError::new(
3462                    1002,
3463                    "pst_cd exceeds the maximum length of 16".to_string(),
3464                ));
3465            }
3466            let pattern = Regex::new(
3467                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3468            )
3469            .unwrap();
3470            if !pattern.is_match(val) {
3471                return Err(ValidationError::new(
3472                    1005,
3473                    "pst_cd does not match the required pattern".to_string(),
3474                ));
3475            }
3476        }
3477        if let Some(ref val) = self.twn_nm {
3478            if val.chars().count() < 1 {
3479                return Err(ValidationError::new(
3480                    1001,
3481                    "twn_nm is shorter than the minimum length of 1".to_string(),
3482                ));
3483            }
3484            if val.chars().count() > 35 {
3485                return Err(ValidationError::new(
3486                    1002,
3487                    "twn_nm exceeds the maximum length of 35".to_string(),
3488                ));
3489            }
3490            let pattern = Regex::new(
3491                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3492            )
3493            .unwrap();
3494            if !pattern.is_match(val) {
3495                return Err(ValidationError::new(
3496                    1005,
3497                    "twn_nm does not match the required pattern".to_string(),
3498                ));
3499            }
3500        }
3501        if let Some(ref val) = self.twn_lctn_nm {
3502            if val.chars().count() < 1 {
3503                return Err(ValidationError::new(
3504                    1001,
3505                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
3506                ));
3507            }
3508            if val.chars().count() > 35 {
3509                return Err(ValidationError::new(
3510                    1002,
3511                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
3512                ));
3513            }
3514            let pattern = Regex::new(
3515                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3516            )
3517            .unwrap();
3518            if !pattern.is_match(val) {
3519                return Err(ValidationError::new(
3520                    1005,
3521                    "twn_lctn_nm does not match the required pattern".to_string(),
3522                ));
3523            }
3524        }
3525        if let Some(ref val) = self.dstrct_nm {
3526            if val.chars().count() < 1 {
3527                return Err(ValidationError::new(
3528                    1001,
3529                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
3530                ));
3531            }
3532            if val.chars().count() > 35 {
3533                return Err(ValidationError::new(
3534                    1002,
3535                    "dstrct_nm exceeds the maximum length of 35".to_string(),
3536                ));
3537            }
3538            let pattern = Regex::new(
3539                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3540            )
3541            .unwrap();
3542            if !pattern.is_match(val) {
3543                return Err(ValidationError::new(
3544                    1005,
3545                    "dstrct_nm does not match the required pattern".to_string(),
3546                ));
3547            }
3548        }
3549        if let Some(ref val) = self.ctry_sub_dvsn {
3550            if val.chars().count() < 1 {
3551                return Err(ValidationError::new(
3552                    1001,
3553                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
3554                ));
3555            }
3556            if val.chars().count() > 35 {
3557                return Err(ValidationError::new(
3558                    1002,
3559                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
3560                ));
3561            }
3562            let pattern = Regex::new(
3563                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3564            )
3565            .unwrap();
3566            if !pattern.is_match(val) {
3567                return Err(ValidationError::new(
3568                    1005,
3569                    "ctry_sub_dvsn does not match the required pattern".to_string(),
3570                ));
3571            }
3572        }
3573        if let Some(ref val) = self.ctry {
3574            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3575            if !pattern.is_match(val) {
3576                return Err(ValidationError::new(
3577                    1005,
3578                    "ctry does not match the required pattern".to_string(),
3579                ));
3580            }
3581        }
3582        if let Some(ref vec) = self.adr_line {
3583            for item in vec {
3584                if item.chars().count() < 1 {
3585                    return Err(ValidationError::new(
3586                        1001,
3587                        "adr_line is shorter than the minimum length of 1".to_string(),
3588                    ));
3589                }
3590                if item.chars().count() > 70 {
3591                    return Err(ValidationError::new(
3592                        1002,
3593                        "adr_line exceeds the maximum length of 70".to_string(),
3594                    ));
3595                }
3596                let pattern = Regex::new(
3597                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3598                )
3599                .unwrap();
3600                if !pattern.is_match(&item) {
3601                    return Err(ValidationError::new(
3602                        1005,
3603                        "adr_line does not match the required pattern".to_string(),
3604                    ));
3605                }
3606            }
3607        }
3608        Ok(())
3609    }
3610}
3611
3612// PostalAddress242: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
3613#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3614pub struct PostalAddress242 {
3615    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
3616    pub dept: Option<String>,
3617    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
3618    pub sub_dept: Option<String>,
3619    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
3620    pub strt_nm: Option<String>,
3621    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
3622    pub bldg_nb: Option<String>,
3623    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
3624    pub bldg_nm: Option<String>,
3625    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
3626    pub flr: Option<String>,
3627    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
3628    pub pst_bx: Option<String>,
3629    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
3630    pub room: Option<String>,
3631    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
3632    pub pst_cd: Option<String>,
3633    #[serde(rename = "TwnNm")]
3634    pub twn_nm: String,
3635    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
3636    pub twn_lctn_nm: Option<String>,
3637    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
3638    pub dstrct_nm: Option<String>,
3639    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
3640    pub ctry_sub_dvsn: Option<String>,
3641    #[serde(rename = "Ctry")]
3642    pub ctry: String,
3643    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
3644    pub adr_line: Option<Vec<String>>,
3645}
3646
3647impl PostalAddress242 {
3648    pub fn validate(&self) -> Result<(), ValidationError> {
3649        if let Some(ref val) = self.dept {
3650            if val.chars().count() < 1 {
3651                return Err(ValidationError::new(
3652                    1001,
3653                    "dept is shorter than the minimum length of 1".to_string(),
3654                ));
3655            }
3656            if val.chars().count() > 70 {
3657                return Err(ValidationError::new(
3658                    1002,
3659                    "dept exceeds the maximum length of 70".to_string(),
3660                ));
3661            }
3662            let pattern = Regex::new(
3663                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3664            )
3665            .unwrap();
3666            if !pattern.is_match(val) {
3667                return Err(ValidationError::new(
3668                    1005,
3669                    "dept does not match the required pattern".to_string(),
3670                ));
3671            }
3672        }
3673        if let Some(ref val) = self.sub_dept {
3674            if val.chars().count() < 1 {
3675                return Err(ValidationError::new(
3676                    1001,
3677                    "sub_dept is shorter than the minimum length of 1".to_string(),
3678                ));
3679            }
3680            if val.chars().count() > 70 {
3681                return Err(ValidationError::new(
3682                    1002,
3683                    "sub_dept exceeds the maximum length of 70".to_string(),
3684                ));
3685            }
3686            let pattern = Regex::new(
3687                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3688            )
3689            .unwrap();
3690            if !pattern.is_match(val) {
3691                return Err(ValidationError::new(
3692                    1005,
3693                    "sub_dept does not match the required pattern".to_string(),
3694                ));
3695            }
3696        }
3697        if let Some(ref val) = self.strt_nm {
3698            if val.chars().count() < 1 {
3699                return Err(ValidationError::new(
3700                    1001,
3701                    "strt_nm is shorter than the minimum length of 1".to_string(),
3702                ));
3703            }
3704            if val.chars().count() > 70 {
3705                return Err(ValidationError::new(
3706                    1002,
3707                    "strt_nm exceeds the maximum length of 70".to_string(),
3708                ));
3709            }
3710            let pattern = Regex::new(
3711                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3712            )
3713            .unwrap();
3714            if !pattern.is_match(val) {
3715                return Err(ValidationError::new(
3716                    1005,
3717                    "strt_nm does not match the required pattern".to_string(),
3718                ));
3719            }
3720        }
3721        if let Some(ref val) = self.bldg_nb {
3722            if val.chars().count() < 1 {
3723                return Err(ValidationError::new(
3724                    1001,
3725                    "bldg_nb is shorter than the minimum length of 1".to_string(),
3726                ));
3727            }
3728            if val.chars().count() > 16 {
3729                return Err(ValidationError::new(
3730                    1002,
3731                    "bldg_nb exceeds the maximum length of 16".to_string(),
3732                ));
3733            }
3734            let pattern = Regex::new(
3735                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3736            )
3737            .unwrap();
3738            if !pattern.is_match(val) {
3739                return Err(ValidationError::new(
3740                    1005,
3741                    "bldg_nb does not match the required pattern".to_string(),
3742                ));
3743            }
3744        }
3745        if let Some(ref val) = self.bldg_nm {
3746            if val.chars().count() < 1 {
3747                return Err(ValidationError::new(
3748                    1001,
3749                    "bldg_nm is shorter than the minimum length of 1".to_string(),
3750                ));
3751            }
3752            if val.chars().count() > 35 {
3753                return Err(ValidationError::new(
3754                    1002,
3755                    "bldg_nm exceeds the maximum length of 35".to_string(),
3756                ));
3757            }
3758            let pattern = Regex::new(
3759                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3760            )
3761            .unwrap();
3762            if !pattern.is_match(val) {
3763                return Err(ValidationError::new(
3764                    1005,
3765                    "bldg_nm does not match the required pattern".to_string(),
3766                ));
3767            }
3768        }
3769        if let Some(ref val) = self.flr {
3770            if val.chars().count() < 1 {
3771                return Err(ValidationError::new(
3772                    1001,
3773                    "flr is shorter than the minimum length of 1".to_string(),
3774                ));
3775            }
3776            if val.chars().count() > 70 {
3777                return Err(ValidationError::new(
3778                    1002,
3779                    "flr exceeds the maximum length of 70".to_string(),
3780                ));
3781            }
3782            let pattern = Regex::new(
3783                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3784            )
3785            .unwrap();
3786            if !pattern.is_match(val) {
3787                return Err(ValidationError::new(
3788                    1005,
3789                    "flr does not match the required pattern".to_string(),
3790                ));
3791            }
3792        }
3793        if let Some(ref val) = self.pst_bx {
3794            if val.chars().count() < 1 {
3795                return Err(ValidationError::new(
3796                    1001,
3797                    "pst_bx is shorter than the minimum length of 1".to_string(),
3798                ));
3799            }
3800            if val.chars().count() > 16 {
3801                return Err(ValidationError::new(
3802                    1002,
3803                    "pst_bx exceeds the maximum length of 16".to_string(),
3804                ));
3805            }
3806            let pattern = Regex::new(
3807                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3808            )
3809            .unwrap();
3810            if !pattern.is_match(val) {
3811                return Err(ValidationError::new(
3812                    1005,
3813                    "pst_bx does not match the required pattern".to_string(),
3814                ));
3815            }
3816        }
3817        if let Some(ref val) = self.room {
3818            if val.chars().count() < 1 {
3819                return Err(ValidationError::new(
3820                    1001,
3821                    "room is shorter than the minimum length of 1".to_string(),
3822                ));
3823            }
3824            if val.chars().count() > 70 {
3825                return Err(ValidationError::new(
3826                    1002,
3827                    "room exceeds the maximum length of 70".to_string(),
3828                ));
3829            }
3830            let pattern = Regex::new(
3831                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3832            )
3833            .unwrap();
3834            if !pattern.is_match(val) {
3835                return Err(ValidationError::new(
3836                    1005,
3837                    "room does not match the required pattern".to_string(),
3838                ));
3839            }
3840        }
3841        if let Some(ref val) = self.pst_cd {
3842            if val.chars().count() < 1 {
3843                return Err(ValidationError::new(
3844                    1001,
3845                    "pst_cd is shorter than the minimum length of 1".to_string(),
3846                ));
3847            }
3848            if val.chars().count() > 16 {
3849                return Err(ValidationError::new(
3850                    1002,
3851                    "pst_cd exceeds the maximum length of 16".to_string(),
3852                ));
3853            }
3854            let pattern = Regex::new(
3855                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3856            )
3857            .unwrap();
3858            if !pattern.is_match(val) {
3859                return Err(ValidationError::new(
3860                    1005,
3861                    "pst_cd does not match the required pattern".to_string(),
3862                ));
3863            }
3864        }
3865        if self.twn_nm.chars().count() < 1 {
3866            return Err(ValidationError::new(
3867                1001,
3868                "twn_nm is shorter than the minimum length of 1".to_string(),
3869            ));
3870        }
3871        if self.twn_nm.chars().count() > 35 {
3872            return Err(ValidationError::new(
3873                1002,
3874                "twn_nm exceeds the maximum length of 35".to_string(),
3875            ));
3876        }
3877        let pattern =
3878            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
3879                .unwrap();
3880        if !pattern.is_match(&self.twn_nm) {
3881            return Err(ValidationError::new(
3882                1005,
3883                "twn_nm does not match the required pattern".to_string(),
3884            ));
3885        }
3886        if let Some(ref val) = self.twn_lctn_nm {
3887            if val.chars().count() < 1 {
3888                return Err(ValidationError::new(
3889                    1001,
3890                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
3891                ));
3892            }
3893            if val.chars().count() > 35 {
3894                return Err(ValidationError::new(
3895                    1002,
3896                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
3897                ));
3898            }
3899            let pattern = Regex::new(
3900                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3901            )
3902            .unwrap();
3903            if !pattern.is_match(val) {
3904                return Err(ValidationError::new(
3905                    1005,
3906                    "twn_lctn_nm does not match the required pattern".to_string(),
3907                ));
3908            }
3909        }
3910        if let Some(ref val) = self.dstrct_nm {
3911            if val.chars().count() < 1 {
3912                return Err(ValidationError::new(
3913                    1001,
3914                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
3915                ));
3916            }
3917            if val.chars().count() > 35 {
3918                return Err(ValidationError::new(
3919                    1002,
3920                    "dstrct_nm exceeds the maximum length of 35".to_string(),
3921                ));
3922            }
3923            let pattern = Regex::new(
3924                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3925            )
3926            .unwrap();
3927            if !pattern.is_match(val) {
3928                return Err(ValidationError::new(
3929                    1005,
3930                    "dstrct_nm does not match the required pattern".to_string(),
3931                ));
3932            }
3933        }
3934        if let Some(ref val) = self.ctry_sub_dvsn {
3935            if val.chars().count() < 1 {
3936                return Err(ValidationError::new(
3937                    1001,
3938                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
3939                ));
3940            }
3941            if val.chars().count() > 35 {
3942                return Err(ValidationError::new(
3943                    1002,
3944                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
3945                ));
3946            }
3947            let pattern = Regex::new(
3948                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3949            )
3950            .unwrap();
3951            if !pattern.is_match(val) {
3952                return Err(ValidationError::new(
3953                    1005,
3954                    "ctry_sub_dvsn does not match the required pattern".to_string(),
3955                ));
3956            }
3957        }
3958        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3959        if !pattern.is_match(&self.ctry) {
3960            return Err(ValidationError::new(
3961                1005,
3962                "ctry does not match the required pattern".to_string(),
3963            ));
3964        }
3965        if let Some(ref vec) = self.adr_line {
3966            for item in vec {
3967                if item.chars().count() < 1 {
3968                    return Err(ValidationError::new(
3969                        1001,
3970                        "adr_line is shorter than the minimum length of 1".to_string(),
3971                    ));
3972                }
3973                if item.chars().count() > 70 {
3974                    return Err(ValidationError::new(
3975                        1002,
3976                        "adr_line exceeds the maximum length of 70".to_string(),
3977                    ));
3978                }
3979                let pattern = Regex::new(
3980                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3981                )
3982                .unwrap();
3983                if !pattern.is_match(&item) {
3984                    return Err(ValidationError::new(
3985                        1005,
3986                        "adr_line does not match the required pattern".to_string(),
3987                    ));
3988                }
3989            }
3990        }
3991        Ok(())
3992    }
3993}
3994
3995// Priority2Code: Priority level is normal.
3996#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3997pub enum Priority2Code {
3998    #[default]
3999    #[serde(rename = "HIGH")]
4000    CodeHIGH,
4001    #[serde(rename = "NORM")]
4002    CodeNORM,
4003}
4004
4005impl Priority2Code {
4006    pub fn validate(&self) -> Result<(), ValidationError> {
4007        Ok(())
4008    }
4009}
4010
4011// Priority3Code: Priority level is normal.
4012#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4013pub enum Priority3Code {
4014    #[default]
4015    #[serde(rename = "URGT")]
4016    CodeURGT,
4017    #[serde(rename = "HIGH")]
4018    CodeHIGH,
4019    #[serde(rename = "NORM")]
4020    CodeNORM,
4021}
4022
4023impl Priority3Code {
4024    pub fn validate(&self) -> Result<(), ValidationError> {
4025        Ok(())
4026    }
4027}
4028
4029// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
4030#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4031pub struct ProxyAccountIdentification11 {
4032    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4033    pub tp: Option<ProxyAccountType1Choice1>,
4034    #[serde(rename = "Id")]
4035    pub id: String,
4036}
4037
4038impl ProxyAccountIdentification11 {
4039    pub fn validate(&self) -> Result<(), ValidationError> {
4040        if let Some(ref val) = self.tp {
4041            val.validate()?
4042        }
4043        if self.id.chars().count() < 1 {
4044            return Err(ValidationError::new(
4045                1001,
4046                "id is shorter than the minimum length of 1".to_string(),
4047            ));
4048        }
4049        if self.id.chars().count() > 320 {
4050            return Err(ValidationError::new(
4051                1002,
4052                "id exceeds the maximum length of 320".to_string(),
4053            ));
4054        }
4055        let pattern =
4056            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
4057                .unwrap();
4058        if !pattern.is_match(&self.id) {
4059            return Err(ValidationError::new(
4060                1005,
4061                "id does not match the required pattern".to_string(),
4062            ));
4063        }
4064        Ok(())
4065    }
4066}
4067
4068// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
4069#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4070pub struct ProxyAccountType1Choice1 {
4071    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4072    pub cd: Option<String>,
4073    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4074    pub prtry: Option<String>,
4075}
4076
4077impl ProxyAccountType1Choice1 {
4078    pub fn validate(&self) -> Result<(), ValidationError> {
4079        if let Some(ref val) = self.cd {
4080            if val.chars().count() < 1 {
4081                return Err(ValidationError::new(
4082                    1001,
4083                    "cd is shorter than the minimum length of 1".to_string(),
4084                ));
4085            }
4086            if val.chars().count() > 4 {
4087                return Err(ValidationError::new(
4088                    1002,
4089                    "cd exceeds the maximum length of 4".to_string(),
4090                ));
4091            }
4092        }
4093        if let Some(ref val) = self.prtry {
4094            if val.chars().count() < 1 {
4095                return Err(ValidationError::new(
4096                    1001,
4097                    "prtry is shorter than the minimum length of 1".to_string(),
4098                ));
4099            }
4100            if val.chars().count() > 35 {
4101                return Err(ValidationError::new(
4102                    1002,
4103                    "prtry exceeds the maximum length of 35".to_string(),
4104                ));
4105            }
4106            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4107            if !pattern.is_match(val) {
4108                return Err(ValidationError::new(
4109                    1005,
4110                    "prtry does not match the required pattern".to_string(),
4111                ));
4112            }
4113        }
4114        Ok(())
4115    }
4116}
4117
4118// Purpose2Choice1: Purpose, in a proprietary form.
4119#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4120pub struct Purpose2Choice1 {
4121    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4122    pub cd: Option<String>,
4123    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4124    pub prtry: Option<String>,
4125}
4126
4127impl Purpose2Choice1 {
4128    pub fn validate(&self) -> Result<(), ValidationError> {
4129        if let Some(ref val) = self.cd {
4130            if val.chars().count() < 1 {
4131                return Err(ValidationError::new(
4132                    1001,
4133                    "cd is shorter than the minimum length of 1".to_string(),
4134                ));
4135            }
4136            if val.chars().count() > 4 {
4137                return Err(ValidationError::new(
4138                    1002,
4139                    "cd exceeds the maximum length of 4".to_string(),
4140                ));
4141            }
4142        }
4143        if let Some(ref val) = self.prtry {
4144            if val.chars().count() < 1 {
4145                return Err(ValidationError::new(
4146                    1001,
4147                    "prtry is shorter than the minimum length of 1".to_string(),
4148                ));
4149            }
4150            if val.chars().count() > 35 {
4151                return Err(ValidationError::new(
4152                    1002,
4153                    "prtry exceeds the maximum length of 35".to_string(),
4154                ));
4155            }
4156            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4157            if !pattern.is_match(val) {
4158                return Err(ValidationError::new(
4159                    1005,
4160                    "prtry does not match the required pattern".to_string(),
4161                ));
4162            }
4163        }
4164        Ok(())
4165    }
4166}
4167
4168// ReferredDocumentInformation71: Set of elements used to provide the content of the referred document line.
4169#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4170pub struct ReferredDocumentInformation71 {
4171    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4172    pub tp: Option<ReferredDocumentType41>,
4173    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
4174    pub nb: Option<String>,
4175    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
4176    pub rltd_dt: Option<String>,
4177    #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
4178    pub line_dtls: Option<Vec<DocumentLineInformation11>>,
4179}
4180
4181impl ReferredDocumentInformation71 {
4182    pub fn validate(&self) -> Result<(), ValidationError> {
4183        if let Some(ref val) = self.tp {
4184            val.validate()?
4185        }
4186        if let Some(ref val) = self.nb {
4187            if val.chars().count() < 1 {
4188                return Err(ValidationError::new(
4189                    1001,
4190                    "nb is shorter than the minimum length of 1".to_string(),
4191                ));
4192            }
4193            if val.chars().count() > 35 {
4194                return Err(ValidationError::new(
4195                    1002,
4196                    "nb exceeds the maximum length of 35".to_string(),
4197                ));
4198            }
4199            let pattern = Regex::new(
4200                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4201            )
4202            .unwrap();
4203            if !pattern.is_match(val) {
4204                return Err(ValidationError::new(
4205                    1005,
4206                    "nb does not match the required pattern".to_string(),
4207                ));
4208            }
4209        }
4210        if let Some(ref vec) = self.line_dtls {
4211            for item in vec {
4212                item.validate()?
4213            }
4214        }
4215        Ok(())
4216    }
4217}
4218
4219// ReferredDocumentType3Choice1: Proprietary identification of the type of the remittance document.
4220#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4221pub struct ReferredDocumentType3Choice1 {
4222    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4223    pub cd: Option<DocumentType6Code>,
4224    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4225    pub prtry: Option<String>,
4226}
4227
4228impl ReferredDocumentType3Choice1 {
4229    pub fn validate(&self) -> Result<(), ValidationError> {
4230        if let Some(ref val) = self.cd {
4231            val.validate()?
4232        }
4233        if let Some(ref val) = self.prtry {
4234            if val.chars().count() < 1 {
4235                return Err(ValidationError::new(
4236                    1001,
4237                    "prtry is shorter than the minimum length of 1".to_string(),
4238                ));
4239            }
4240            if val.chars().count() > 35 {
4241                return Err(ValidationError::new(
4242                    1002,
4243                    "prtry exceeds the maximum length of 35".to_string(),
4244                ));
4245            }
4246            let pattern = Regex::new(
4247                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4248            )
4249            .unwrap();
4250            if !pattern.is_match(val) {
4251                return Err(ValidationError::new(
4252                    1005,
4253                    "prtry does not match the required pattern".to_string(),
4254                ));
4255            }
4256        }
4257        Ok(())
4258    }
4259}
4260
4261// ReferredDocumentType41: Identification of the issuer of the reference document type.
4262#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4263pub struct ReferredDocumentType41 {
4264    #[serde(rename = "CdOrPrtry")]
4265    pub cd_or_prtry: ReferredDocumentType3Choice1,
4266    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4267    pub issr: Option<String>,
4268}
4269
4270impl ReferredDocumentType41 {
4271    pub fn validate(&self) -> Result<(), ValidationError> {
4272        self.cd_or_prtry.validate()?;
4273        if let Some(ref val) = self.issr {
4274            if val.chars().count() < 1 {
4275                return Err(ValidationError::new(
4276                    1001,
4277                    "issr is shorter than the minimum length of 1".to_string(),
4278                ));
4279            }
4280            if val.chars().count() > 35 {
4281                return Err(ValidationError::new(
4282                    1002,
4283                    "issr exceeds the maximum length of 35".to_string(),
4284                ));
4285            }
4286            let pattern = Regex::new(
4287                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4288            )
4289            .unwrap();
4290            if !pattern.is_match(val) {
4291                return Err(ValidationError::new(
4292                    1005,
4293                    "issr does not match the required pattern".to_string(),
4294                ));
4295            }
4296        }
4297        Ok(())
4298    }
4299}
4300
4301// RemittanceAmount21: Amount of money remitted for the referred document.
4302#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4303pub struct RemittanceAmount21 {
4304    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
4305    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4306    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
4307    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType11>>,
4308    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
4309    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4310    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
4311    pub tax_amt: Option<Vec<TaxAmountAndType11>>,
4312    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
4313    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment11>>,
4314    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
4315    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4316}
4317
4318impl RemittanceAmount21 {
4319    pub fn validate(&self) -> Result<(), ValidationError> {
4320        if let Some(ref val) = self.due_pybl_amt {
4321            val.validate()?
4322        }
4323        if let Some(ref vec) = self.dscnt_apld_amt {
4324            for item in vec {
4325                item.validate()?
4326            }
4327        }
4328        if let Some(ref val) = self.cdt_note_amt {
4329            val.validate()?
4330        }
4331        if let Some(ref vec) = self.tax_amt {
4332            for item in vec {
4333                item.validate()?
4334            }
4335        }
4336        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
4337            for item in vec {
4338                item.validate()?
4339            }
4340        }
4341        if let Some(ref val) = self.rmtd_amt {
4342            val.validate()?
4343        }
4344        Ok(())
4345    }
4346}
4347
4348// RemittanceAmount31: Amount of money remitted.
4349#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4350pub struct RemittanceAmount31 {
4351    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
4352    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4353    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
4354    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType11>>,
4355    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
4356    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4357    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
4358    pub tax_amt: Option<Vec<TaxAmountAndType11>>,
4359    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
4360    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment11>>,
4361    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
4362    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4363}
4364
4365impl RemittanceAmount31 {
4366    pub fn validate(&self) -> Result<(), ValidationError> {
4367        if let Some(ref val) = self.due_pybl_amt {
4368            val.validate()?
4369        }
4370        if let Some(ref vec) = self.dscnt_apld_amt {
4371            for item in vec {
4372                item.validate()?
4373            }
4374        }
4375        if let Some(ref val) = self.cdt_note_amt {
4376            val.validate()?
4377        }
4378        if let Some(ref vec) = self.tax_amt {
4379            for item in vec {
4380                item.validate()?
4381            }
4382        }
4383        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
4384            for item in vec {
4385                item.validate()?
4386            }
4387        }
4388        if let Some(ref val) = self.rmtd_amt {
4389            val.validate()?
4390        }
4391        Ok(())
4392    }
4393}
4394
4395// RemittanceInformation161: Information supplied to enable the matching/reconciliation of an entry with the items that the payment is intended to settle, such as commercial invoices in an accounts' receivable system, in a structured form.
4396#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4397pub struct RemittanceInformation161 {
4398    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
4399    pub ustrd: Option<String>,
4400    #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
4401    pub strd: Option<Vec<StructuredRemittanceInformation161>>,
4402}
4403
4404impl RemittanceInformation161 {
4405    pub fn validate(&self) -> Result<(), ValidationError> {
4406        if let Some(ref val) = self.ustrd {
4407            if val.chars().count() < 1 {
4408                return Err(ValidationError::new(
4409                    1001,
4410                    "ustrd is shorter than the minimum length of 1".to_string(),
4411                ));
4412            }
4413            if val.chars().count() > 140 {
4414                return Err(ValidationError::new(
4415                    1002,
4416                    "ustrd exceeds the maximum length of 140".to_string(),
4417                ));
4418            }
4419            let pattern = Regex::new(
4420                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4421            )
4422            .unwrap();
4423            if !pattern.is_match(val) {
4424                return Err(ValidationError::new(
4425                    1005,
4426                    "ustrd does not match the required pattern".to_string(),
4427                ));
4428            }
4429        }
4430        if let Some(ref vec) = self.strd {
4431            for item in vec {
4432                item.validate()?
4433            }
4434        }
4435        Ok(())
4436    }
4437}
4438
4439// RemittanceInformation21: Information supplied to enable the matching of an entry with the items that the transfer is intended to settle, for example, commercial invoices in an accounts' receivable system in an unstructured form.
4440#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4441pub struct RemittanceInformation21 {
4442    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
4443    pub ustrd: Option<String>,
4444}
4445
4446impl RemittanceInformation21 {
4447    pub fn validate(&self) -> Result<(), ValidationError> {
4448        if let Some(ref val) = self.ustrd {
4449            if val.chars().count() < 1 {
4450                return Err(ValidationError::new(
4451                    1001,
4452                    "ustrd is shorter than the minimum length of 1".to_string(),
4453                ));
4454            }
4455            if val.chars().count() > 140 {
4456                return Err(ValidationError::new(
4457                    1002,
4458                    "ustrd exceeds the maximum length of 140".to_string(),
4459                ));
4460            }
4461            let pattern = Regex::new(
4462                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4463            )
4464            .unwrap();
4465            if !pattern.is_match(val) {
4466                return Err(ValidationError::new(
4467                    1005,
4468                    "ustrd does not match the required pattern".to_string(),
4469                ));
4470            }
4471        }
4472        Ok(())
4473    }
4474}
4475
4476// ServiceLevel8Choice1: Specifies a pre-agreed service or level of service between the parties, as a proprietary code.
4477#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4478pub struct ServiceLevel8Choice1 {
4479    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4480    pub cd: Option<String>,
4481    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4482    pub prtry: Option<String>,
4483}
4484
4485impl ServiceLevel8Choice1 {
4486    pub fn validate(&self) -> Result<(), ValidationError> {
4487        if let Some(ref val) = self.cd {
4488            if val.chars().count() < 1 {
4489                return Err(ValidationError::new(
4490                    1001,
4491                    "cd is shorter than the minimum length of 1".to_string(),
4492                ));
4493            }
4494            if val.chars().count() > 4 {
4495                return Err(ValidationError::new(
4496                    1002,
4497                    "cd exceeds the maximum length of 4".to_string(),
4498                ));
4499            }
4500        }
4501        if let Some(ref val) = self.prtry {
4502            if val.chars().count() < 1 {
4503                return Err(ValidationError::new(
4504                    1001,
4505                    "prtry is shorter than the minimum length of 1".to_string(),
4506                ));
4507            }
4508            if val.chars().count() > 35 {
4509                return Err(ValidationError::new(
4510                    1002,
4511                    "prtry exceeds the maximum length of 35".to_string(),
4512                ));
4513            }
4514            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4515            if !pattern.is_match(val) {
4516                return Err(ValidationError::new(
4517                    1005,
4518                    "prtry does not match the required pattern".to_string(),
4519                ));
4520            }
4521        }
4522        Ok(())
4523    }
4524}
4525
4526// SettlementDateTimeIndication11: Date and time at which a payment has been credited at the transaction administrator. In the case of TARGET, the date and time at which the payment has been credited at the receiving central bank, expressed in Central European Time (CET).
4527#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4528pub struct SettlementDateTimeIndication11 {
4529    #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
4530    pub dbt_dt_tm: Option<String>,
4531    #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
4532    pub cdt_dt_tm: Option<String>,
4533}
4534
4535impl SettlementDateTimeIndication11 {
4536    pub fn validate(&self) -> Result<(), ValidationError> {
4537        if let Some(ref val) = self.dbt_dt_tm {
4538            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4539            if !pattern.is_match(val) {
4540                return Err(ValidationError::new(
4541                    1005,
4542                    "dbt_dt_tm does not match the required pattern".to_string(),
4543                ));
4544            }
4545        }
4546        if let Some(ref val) = self.cdt_dt_tm {
4547            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4548            if !pattern.is_match(val) {
4549                return Err(ValidationError::new(
4550                    1005,
4551                    "cdt_dt_tm does not match the required pattern".to_string(),
4552                ));
4553            }
4554        }
4555        Ok(())
4556    }
4557}
4558
4559// SettlementInstruction71: A specific purpose account used to post debit and credit entries as a result of the transaction.
4560#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4561pub struct SettlementInstruction71 {
4562    #[serde(rename = "SttlmMtd")]
4563    pub sttlm_mtd: SettlementMethod1Code1,
4564    #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
4565    pub sttlm_acct: Option<CashAccount381>,
4566}
4567
4568impl SettlementInstruction71 {
4569    pub fn validate(&self) -> Result<(), ValidationError> {
4570        self.sttlm_mtd.validate()?;
4571        if let Some(ref val) = self.sttlm_acct {
4572            val.validate()?
4573        }
4574        Ok(())
4575    }
4576}
4577
4578// SettlementMethod1Code__1: Settlement is done by the agent instructing and forwarding the payment to the next party in the payment chain.
4579#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4580pub enum SettlementMethod1Code1 {
4581    #[default]
4582    #[serde(rename = "INDA")]
4583    CodeINDA,
4584    #[serde(rename = "INGA")]
4585    CodeINGA,
4586}
4587
4588impl SettlementMethod1Code1 {
4589    pub fn validate(&self) -> Result<(), ValidationError> {
4590        Ok(())
4591    }
4592}
4593
4594// SettlementTimeRequest21: Time by when the payment must be settled to avoid rejection.
4595#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4596pub struct SettlementTimeRequest21 {
4597    #[serde(rename = "CLSTm", skip_serializing_if = "Option::is_none")]
4598    pub cls_tm: Option<String>,
4599    #[serde(rename = "TillTm", skip_serializing_if = "Option::is_none")]
4600    pub till_tm: Option<String>,
4601    #[serde(rename = "FrTm", skip_serializing_if = "Option::is_none")]
4602    pub fr_tm: Option<String>,
4603    #[serde(rename = "RjctTm", skip_serializing_if = "Option::is_none")]
4604    pub rjct_tm: Option<String>,
4605}
4606
4607impl SettlementTimeRequest21 {
4608    pub fn validate(&self) -> Result<(), ValidationError> {
4609        if let Some(ref val) = self.cls_tm {
4610            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4611            if !pattern.is_match(val) {
4612                return Err(ValidationError::new(
4613                    1005,
4614                    "cls_tm does not match the required pattern".to_string(),
4615                ));
4616            }
4617        }
4618        if let Some(ref val) = self.till_tm {
4619            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4620            if !pattern.is_match(val) {
4621                return Err(ValidationError::new(
4622                    1005,
4623                    "till_tm does not match the required pattern".to_string(),
4624                ));
4625            }
4626        }
4627        if let Some(ref val) = self.fr_tm {
4628            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4629            if !pattern.is_match(val) {
4630                return Err(ValidationError::new(
4631                    1005,
4632                    "fr_tm does not match the required pattern".to_string(),
4633                ));
4634            }
4635        }
4636        if let Some(ref val) = self.rjct_tm {
4637            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4638            if !pattern.is_match(val) {
4639                return Err(ValidationError::new(
4640                    1005,
4641                    "rjct_tm does not match the required pattern".to_string(),
4642                ));
4643            }
4644        }
4645        Ok(())
4646    }
4647}
4648
4649// StructuredRemittanceInformation161: Additional information, in free text form, to complement the structured remittance information.
4650#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4651pub struct StructuredRemittanceInformation161 {
4652    #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
4653    pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation71>>,
4654    #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
4655    pub rfrd_doc_amt: Option<RemittanceAmount21>,
4656    #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
4657    pub cdtr_ref_inf: Option<CreditorReferenceInformation21>,
4658    #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
4659    pub invcr: Option<PartyIdentification1354>,
4660    #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
4661    pub invcee: Option<PartyIdentification1354>,
4662    #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
4663    pub tax_rmt: Option<TaxInformation71>,
4664    #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
4665    pub grnshmt_rmt: Option<Garnishment31>,
4666    #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
4667    pub addtl_rmt_inf: Option<Vec<String>>,
4668}
4669
4670impl StructuredRemittanceInformation161 {
4671    pub fn validate(&self) -> Result<(), ValidationError> {
4672        if let Some(ref vec) = self.rfrd_doc_inf {
4673            for item in vec {
4674                item.validate()?
4675            }
4676        }
4677        if let Some(ref val) = self.rfrd_doc_amt {
4678            val.validate()?
4679        }
4680        if let Some(ref val) = self.cdtr_ref_inf {
4681            val.validate()?
4682        }
4683        if let Some(ref val) = self.invcr {
4684            val.validate()?
4685        }
4686        if let Some(ref val) = self.invcee {
4687            val.validate()?
4688        }
4689        if let Some(ref val) = self.tax_rmt {
4690            val.validate()?
4691        }
4692        if let Some(ref val) = self.grnshmt_rmt {
4693            val.validate()?
4694        }
4695        if let Some(ref vec) = self.addtl_rmt_inf {
4696            for item in vec {
4697                if item.chars().count() < 1 {
4698                    return Err(ValidationError::new(
4699                        1001,
4700                        "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
4701                    ));
4702                }
4703                if item.chars().count() > 140 {
4704                    return Err(ValidationError::new(
4705                        1002,
4706                        "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
4707                    ));
4708                }
4709                let pattern = Regex::new(
4710                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4711                )
4712                .unwrap();
4713                if !pattern.is_match(&item) {
4714                    return Err(ValidationError::new(
4715                        1005,
4716                        "addtl_rmt_inf does not match the required pattern".to_string(),
4717                    ));
4718                }
4719            }
4720        }
4721        Ok(())
4722    }
4723}
4724
4725// TaxAmount2: Set of elements used to provide details on the tax period and amount.
4726#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4727pub struct TaxAmount2 {
4728    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
4729    pub rate: Option<f64>,
4730    #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
4731    pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4732    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
4733    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4734    #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
4735    pub dtls: Option<Vec<TaxRecordDetails2>>,
4736}
4737
4738impl TaxAmount2 {
4739    pub fn validate(&self) -> Result<(), ValidationError> {
4740        if let Some(ref val) = self.taxbl_base_amt {
4741            val.validate()?
4742        }
4743        if let Some(ref val) = self.ttl_amt {
4744            val.validate()?
4745        }
4746        if let Some(ref vec) = self.dtls {
4747            for item in vec {
4748                item.validate()?
4749            }
4750        }
4751        Ok(())
4752    }
4753}
4754
4755// TaxAmountAndType11: Amount of money, which has been typed.
4756#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4757pub struct TaxAmountAndType11 {
4758    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4759    pub tp: Option<TaxAmountType1Choice1>,
4760    #[serde(rename = "Amt")]
4761    pub amt: ActiveOrHistoricCurrencyAndAmount,
4762}
4763
4764impl TaxAmountAndType11 {
4765    pub fn validate(&self) -> Result<(), ValidationError> {
4766        if let Some(ref val) = self.tp {
4767            val.validate()?
4768        }
4769        self.amt.validate()?;
4770        Ok(())
4771    }
4772}
4773
4774// TaxAmountType1Choice1: Specifies the amount type, in a free-text form.
4775#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4776pub struct TaxAmountType1Choice1 {
4777    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4778    pub cd: Option<String>,
4779    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4780    pub prtry: Option<String>,
4781}
4782
4783impl TaxAmountType1Choice1 {
4784    pub fn validate(&self) -> Result<(), ValidationError> {
4785        if let Some(ref val) = self.cd {
4786            if val.chars().count() < 1 {
4787                return Err(ValidationError::new(
4788                    1001,
4789                    "cd is shorter than the minimum length of 1".to_string(),
4790                ));
4791            }
4792            if val.chars().count() > 4 {
4793                return Err(ValidationError::new(
4794                    1002,
4795                    "cd exceeds the maximum length of 4".to_string(),
4796                ));
4797            }
4798        }
4799        if let Some(ref val) = self.prtry {
4800            if val.chars().count() < 1 {
4801                return Err(ValidationError::new(
4802                    1001,
4803                    "prtry is shorter than the minimum length of 1".to_string(),
4804                ));
4805            }
4806            if val.chars().count() > 35 {
4807                return Err(ValidationError::new(
4808                    1002,
4809                    "prtry exceeds the maximum length of 35".to_string(),
4810                ));
4811            }
4812            let pattern = Regex::new(
4813                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4814            )
4815            .unwrap();
4816            if !pattern.is_match(val) {
4817                return Err(ValidationError::new(
4818                    1005,
4819                    "prtry does not match the required pattern".to_string(),
4820                ));
4821            }
4822        }
4823        Ok(())
4824    }
4825}
4826
4827// TaxAuthorisation11: Name of the debtor or the debtor's authorised representative.
4828#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4829pub struct TaxAuthorisation11 {
4830    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
4831    pub titl: Option<String>,
4832    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
4833    pub nm: Option<String>,
4834}
4835
4836impl TaxAuthorisation11 {
4837    pub fn validate(&self) -> Result<(), ValidationError> {
4838        if let Some(ref val) = self.titl {
4839            if val.chars().count() < 1 {
4840                return Err(ValidationError::new(
4841                    1001,
4842                    "titl is shorter than the minimum length of 1".to_string(),
4843                ));
4844            }
4845            if val.chars().count() > 35 {
4846                return Err(ValidationError::new(
4847                    1002,
4848                    "titl exceeds the maximum length of 35".to_string(),
4849                ));
4850            }
4851            let pattern = Regex::new(
4852                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4853            )
4854            .unwrap();
4855            if !pattern.is_match(val) {
4856                return Err(ValidationError::new(
4857                    1005,
4858                    "titl does not match the required pattern".to_string(),
4859                ));
4860            }
4861        }
4862        if let Some(ref val) = self.nm {
4863            if val.chars().count() < 1 {
4864                return Err(ValidationError::new(
4865                    1001,
4866                    "nm is shorter than the minimum length of 1".to_string(),
4867                ));
4868            }
4869            if val.chars().count() > 140 {
4870                return Err(ValidationError::new(
4871                    1002,
4872                    "nm exceeds the maximum length of 140".to_string(),
4873                ));
4874            }
4875            let pattern = Regex::new(
4876                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4877            )
4878            .unwrap();
4879            if !pattern.is_match(val) {
4880                return Err(ValidationError::new(
4881                    1005,
4882                    "nm does not match the required pattern".to_string(),
4883                ));
4884            }
4885        }
4886        Ok(())
4887    }
4888}
4889
4890// TaxInformation71: Record of tax details.
4891#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4892pub struct TaxInformation71 {
4893    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
4894    pub cdtr: Option<TaxParty11>,
4895    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
4896    pub dbtr: Option<TaxParty21>,
4897    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
4898    pub ultmt_dbtr: Option<TaxParty21>,
4899    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
4900    pub admstn_zone: Option<String>,
4901    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
4902    pub ref_nb: Option<String>,
4903    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
4904    pub mtd: Option<String>,
4905    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
4906    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4907    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
4908    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4909    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
4910    pub dt: Option<String>,
4911    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
4912    pub seq_nb: Option<f64>,
4913    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
4914    pub rcrd: Option<Vec<TaxRecord21>>,
4915}
4916
4917impl TaxInformation71 {
4918    pub fn validate(&self) -> Result<(), ValidationError> {
4919        if let Some(ref val) = self.cdtr {
4920            val.validate()?
4921        }
4922        if let Some(ref val) = self.dbtr {
4923            val.validate()?
4924        }
4925        if let Some(ref val) = self.ultmt_dbtr {
4926            val.validate()?
4927        }
4928        if let Some(ref val) = self.admstn_zone {
4929            if val.chars().count() < 1 {
4930                return Err(ValidationError::new(
4931                    1001,
4932                    "admstn_zone is shorter than the minimum length of 1".to_string(),
4933                ));
4934            }
4935            if val.chars().count() > 35 {
4936                return Err(ValidationError::new(
4937                    1002,
4938                    "admstn_zone exceeds the maximum length of 35".to_string(),
4939                ));
4940            }
4941            let pattern = Regex::new(
4942                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4943            )
4944            .unwrap();
4945            if !pattern.is_match(val) {
4946                return Err(ValidationError::new(
4947                    1005,
4948                    "admstn_zone does not match the required pattern".to_string(),
4949                ));
4950            }
4951        }
4952        if let Some(ref val) = self.ref_nb {
4953            if val.chars().count() < 1 {
4954                return Err(ValidationError::new(
4955                    1001,
4956                    "ref_nb is shorter than the minimum length of 1".to_string(),
4957                ));
4958            }
4959            if val.chars().count() > 140 {
4960                return Err(ValidationError::new(
4961                    1002,
4962                    "ref_nb exceeds the maximum length of 140".to_string(),
4963                ));
4964            }
4965            let pattern = Regex::new(
4966                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4967            )
4968            .unwrap();
4969            if !pattern.is_match(val) {
4970                return Err(ValidationError::new(
4971                    1005,
4972                    "ref_nb does not match the required pattern".to_string(),
4973                ));
4974            }
4975        }
4976        if let Some(ref val) = self.mtd {
4977            if val.chars().count() < 1 {
4978                return Err(ValidationError::new(
4979                    1001,
4980                    "mtd is shorter than the minimum length of 1".to_string(),
4981                ));
4982            }
4983            if val.chars().count() > 35 {
4984                return Err(ValidationError::new(
4985                    1002,
4986                    "mtd exceeds the maximum length of 35".to_string(),
4987                ));
4988            }
4989            let pattern = Regex::new(
4990                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4991            )
4992            .unwrap();
4993            if !pattern.is_match(val) {
4994                return Err(ValidationError::new(
4995                    1005,
4996                    "mtd does not match the required pattern".to_string(),
4997                ));
4998            }
4999        }
5000        if let Some(ref val) = self.ttl_taxbl_base_amt {
5001            val.validate()?
5002        }
5003        if let Some(ref val) = self.ttl_tax_amt {
5004            val.validate()?
5005        }
5006        if let Some(ref vec) = self.rcrd {
5007            for item in vec {
5008                item.validate()?
5009            }
5010        }
5011        Ok(())
5012    }
5013}
5014
5015// TaxParty11: Type of tax payer.
5016#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5017pub struct TaxParty11 {
5018    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
5019    pub tax_id: Option<String>,
5020    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
5021    pub regn_id: Option<String>,
5022    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
5023    pub tax_tp: Option<String>,
5024}
5025
5026impl TaxParty11 {
5027    pub fn validate(&self) -> Result<(), ValidationError> {
5028        if let Some(ref val) = self.tax_id {
5029            if val.chars().count() < 1 {
5030                return Err(ValidationError::new(
5031                    1001,
5032                    "tax_id is shorter than the minimum length of 1".to_string(),
5033                ));
5034            }
5035            if val.chars().count() > 35 {
5036                return Err(ValidationError::new(
5037                    1002,
5038                    "tax_id exceeds the maximum length of 35".to_string(),
5039                ));
5040            }
5041            let pattern = Regex::new(
5042                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5043            )
5044            .unwrap();
5045            if !pattern.is_match(val) {
5046                return Err(ValidationError::new(
5047                    1005,
5048                    "tax_id does not match the required pattern".to_string(),
5049                ));
5050            }
5051        }
5052        if let Some(ref val) = self.regn_id {
5053            if val.chars().count() < 1 {
5054                return Err(ValidationError::new(
5055                    1001,
5056                    "regn_id is shorter than the minimum length of 1".to_string(),
5057                ));
5058            }
5059            if val.chars().count() > 35 {
5060                return Err(ValidationError::new(
5061                    1002,
5062                    "regn_id exceeds the maximum length of 35".to_string(),
5063                ));
5064            }
5065            let pattern = Regex::new(
5066                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5067            )
5068            .unwrap();
5069            if !pattern.is_match(val) {
5070                return Err(ValidationError::new(
5071                    1005,
5072                    "regn_id does not match the required pattern".to_string(),
5073                ));
5074            }
5075        }
5076        if let Some(ref val) = self.tax_tp {
5077            if val.chars().count() < 1 {
5078                return Err(ValidationError::new(
5079                    1001,
5080                    "tax_tp is shorter than the minimum length of 1".to_string(),
5081                ));
5082            }
5083            if val.chars().count() > 35 {
5084                return Err(ValidationError::new(
5085                    1002,
5086                    "tax_tp exceeds the maximum length of 35".to_string(),
5087                ));
5088            }
5089            let pattern = Regex::new(
5090                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5091            )
5092            .unwrap();
5093            if !pattern.is_match(val) {
5094                return Err(ValidationError::new(
5095                    1005,
5096                    "tax_tp does not match the required pattern".to_string(),
5097                ));
5098            }
5099        }
5100        Ok(())
5101    }
5102}
5103
5104// TaxParty21: Details of the authorised tax paying party.
5105#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5106pub struct TaxParty21 {
5107    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
5108    pub tax_id: Option<String>,
5109    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
5110    pub regn_id: Option<String>,
5111    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
5112    pub tax_tp: Option<String>,
5113    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
5114    pub authstn: Option<TaxAuthorisation11>,
5115}
5116
5117impl TaxParty21 {
5118    pub fn validate(&self) -> Result<(), ValidationError> {
5119        if let Some(ref val) = self.tax_id {
5120            if val.chars().count() < 1 {
5121                return Err(ValidationError::new(
5122                    1001,
5123                    "tax_id is shorter than the minimum length of 1".to_string(),
5124                ));
5125            }
5126            if val.chars().count() > 35 {
5127                return Err(ValidationError::new(
5128                    1002,
5129                    "tax_id exceeds the maximum length of 35".to_string(),
5130                ));
5131            }
5132            let pattern = Regex::new(
5133                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5134            )
5135            .unwrap();
5136            if !pattern.is_match(val) {
5137                return Err(ValidationError::new(
5138                    1005,
5139                    "tax_id does not match the required pattern".to_string(),
5140                ));
5141            }
5142        }
5143        if let Some(ref val) = self.regn_id {
5144            if val.chars().count() < 1 {
5145                return Err(ValidationError::new(
5146                    1001,
5147                    "regn_id is shorter than the minimum length of 1".to_string(),
5148                ));
5149            }
5150            if val.chars().count() > 35 {
5151                return Err(ValidationError::new(
5152                    1002,
5153                    "regn_id exceeds the maximum length of 35".to_string(),
5154                ));
5155            }
5156            let pattern = Regex::new(
5157                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5158            )
5159            .unwrap();
5160            if !pattern.is_match(val) {
5161                return Err(ValidationError::new(
5162                    1005,
5163                    "regn_id does not match the required pattern".to_string(),
5164                ));
5165            }
5166        }
5167        if let Some(ref val) = self.tax_tp {
5168            if val.chars().count() < 1 {
5169                return Err(ValidationError::new(
5170                    1001,
5171                    "tax_tp is shorter than the minimum length of 1".to_string(),
5172                ));
5173            }
5174            if val.chars().count() > 35 {
5175                return Err(ValidationError::new(
5176                    1002,
5177                    "tax_tp exceeds the maximum length of 35".to_string(),
5178                ));
5179            }
5180            let pattern = Regex::new(
5181                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5182            )
5183            .unwrap();
5184            if !pattern.is_match(val) {
5185                return Err(ValidationError::new(
5186                    1005,
5187                    "tax_tp does not match the required pattern".to_string(),
5188                ));
5189            }
5190        }
5191        if let Some(ref val) = self.authstn {
5192            val.validate()?
5193        }
5194        Ok(())
5195    }
5196}
5197
5198// TaxPeriod2: Range of time between a start date and an end date for which the tax report is provided.
5199#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5200pub struct TaxPeriod2 {
5201    #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
5202    pub yr: Option<String>,
5203    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
5204    pub tp: Option<TaxRecordPeriod1Code>,
5205    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
5206    pub fr_to_dt: Option<DatePeriod2>,
5207}
5208
5209impl TaxPeriod2 {
5210    pub fn validate(&self) -> Result<(), ValidationError> {
5211        if let Some(ref val) = self.tp {
5212            val.validate()?
5213        }
5214        if let Some(ref val) = self.fr_to_dt {
5215            val.validate()?
5216        }
5217        Ok(())
5218    }
5219}
5220
5221// TaxRecord21: Further details of the tax record.
5222#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5223pub struct TaxRecord21 {
5224    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
5225    pub tp: Option<String>,
5226    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
5227    pub ctgy: Option<String>,
5228    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
5229    pub ctgy_dtls: Option<String>,
5230    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
5231    pub dbtr_sts: Option<String>,
5232    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
5233    pub cert_id: Option<String>,
5234    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
5235    pub frms_cd: Option<String>,
5236    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
5237    pub prd: Option<TaxPeriod2>,
5238    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
5239    pub tax_amt: Option<TaxAmount2>,
5240    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
5241    pub addtl_inf: Option<String>,
5242}
5243
5244impl TaxRecord21 {
5245    pub fn validate(&self) -> Result<(), ValidationError> {
5246        if let Some(ref val) = self.tp {
5247            if val.chars().count() < 1 {
5248                return Err(ValidationError::new(
5249                    1001,
5250                    "tp is shorter than the minimum length of 1".to_string(),
5251                ));
5252            }
5253            if val.chars().count() > 35 {
5254                return Err(ValidationError::new(
5255                    1002,
5256                    "tp exceeds the maximum length of 35".to_string(),
5257                ));
5258            }
5259            let pattern = Regex::new(
5260                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5261            )
5262            .unwrap();
5263            if !pattern.is_match(val) {
5264                return Err(ValidationError::new(
5265                    1005,
5266                    "tp does not match the required pattern".to_string(),
5267                ));
5268            }
5269        }
5270        if let Some(ref val) = self.ctgy {
5271            if val.chars().count() < 1 {
5272                return Err(ValidationError::new(
5273                    1001,
5274                    "ctgy is shorter than the minimum length of 1".to_string(),
5275                ));
5276            }
5277            if val.chars().count() > 35 {
5278                return Err(ValidationError::new(
5279                    1002,
5280                    "ctgy exceeds the maximum length of 35".to_string(),
5281                ));
5282            }
5283            let pattern = Regex::new(
5284                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5285            )
5286            .unwrap();
5287            if !pattern.is_match(val) {
5288                return Err(ValidationError::new(
5289                    1005,
5290                    "ctgy does not match the required pattern".to_string(),
5291                ));
5292            }
5293        }
5294        if let Some(ref val) = self.ctgy_dtls {
5295            if val.chars().count() < 1 {
5296                return Err(ValidationError::new(
5297                    1001,
5298                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
5299                ));
5300            }
5301            if val.chars().count() > 35 {
5302                return Err(ValidationError::new(
5303                    1002,
5304                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
5305                ));
5306            }
5307            let pattern = Regex::new(
5308                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5309            )
5310            .unwrap();
5311            if !pattern.is_match(val) {
5312                return Err(ValidationError::new(
5313                    1005,
5314                    "ctgy_dtls does not match the required pattern".to_string(),
5315                ));
5316            }
5317        }
5318        if let Some(ref val) = self.dbtr_sts {
5319            if val.chars().count() < 1 {
5320                return Err(ValidationError::new(
5321                    1001,
5322                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
5323                ));
5324            }
5325            if val.chars().count() > 35 {
5326                return Err(ValidationError::new(
5327                    1002,
5328                    "dbtr_sts exceeds the maximum length of 35".to_string(),
5329                ));
5330            }
5331            let pattern = Regex::new(
5332                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5333            )
5334            .unwrap();
5335            if !pattern.is_match(val) {
5336                return Err(ValidationError::new(
5337                    1005,
5338                    "dbtr_sts does not match the required pattern".to_string(),
5339                ));
5340            }
5341        }
5342        if let Some(ref val) = self.cert_id {
5343            if val.chars().count() < 1 {
5344                return Err(ValidationError::new(
5345                    1001,
5346                    "cert_id is shorter than the minimum length of 1".to_string(),
5347                ));
5348            }
5349            if val.chars().count() > 35 {
5350                return Err(ValidationError::new(
5351                    1002,
5352                    "cert_id exceeds the maximum length of 35".to_string(),
5353                ));
5354            }
5355            let pattern = Regex::new(
5356                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5357            )
5358            .unwrap();
5359            if !pattern.is_match(val) {
5360                return Err(ValidationError::new(
5361                    1005,
5362                    "cert_id does not match the required pattern".to_string(),
5363                ));
5364            }
5365        }
5366        if let Some(ref val) = self.frms_cd {
5367            if val.chars().count() < 1 {
5368                return Err(ValidationError::new(
5369                    1001,
5370                    "frms_cd is shorter than the minimum length of 1".to_string(),
5371                ));
5372            }
5373            if val.chars().count() > 35 {
5374                return Err(ValidationError::new(
5375                    1002,
5376                    "frms_cd exceeds the maximum length of 35".to_string(),
5377                ));
5378            }
5379            let pattern = Regex::new(
5380                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5381            )
5382            .unwrap();
5383            if !pattern.is_match(val) {
5384                return Err(ValidationError::new(
5385                    1005,
5386                    "frms_cd does not match the required pattern".to_string(),
5387                ));
5388            }
5389        }
5390        if let Some(ref val) = self.prd {
5391            val.validate()?
5392        }
5393        if let Some(ref val) = self.tax_amt {
5394            val.validate()?
5395        }
5396        if let Some(ref val) = self.addtl_inf {
5397            if val.chars().count() < 1 {
5398                return Err(ValidationError::new(
5399                    1001,
5400                    "addtl_inf is shorter than the minimum length of 1".to_string(),
5401                ));
5402            }
5403            if val.chars().count() > 140 {
5404                return Err(ValidationError::new(
5405                    1002,
5406                    "addtl_inf exceeds the maximum length of 140".to_string(),
5407                ));
5408            }
5409            let pattern = Regex::new(
5410                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5411            )
5412            .unwrap();
5413            if !pattern.is_match(val) {
5414                return Err(ValidationError::new(
5415                    1005,
5416                    "addtl_inf does not match the required pattern".to_string(),
5417                ));
5418            }
5419        }
5420        Ok(())
5421    }
5422}
5423
5424// TaxRecordDetails2: Underlying tax amount related to the specified period.
5425#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5426pub struct TaxRecordDetails2 {
5427    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
5428    pub prd: Option<TaxPeriod2>,
5429    #[serde(rename = "Amt")]
5430    pub amt: ActiveOrHistoricCurrencyAndAmount,
5431}
5432
5433impl TaxRecordDetails2 {
5434    pub fn validate(&self) -> Result<(), ValidationError> {
5435        if let Some(ref val) = self.prd {
5436            val.validate()?
5437        }
5438        self.amt.validate()?;
5439        Ok(())
5440    }
5441}
5442
5443// TaxRecordPeriod1Code: Tax is related to the second half of the period.
5444#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5445pub enum TaxRecordPeriod1Code {
5446    #[default]
5447    #[serde(rename = "MM01")]
5448    CodeMM01,
5449    #[serde(rename = "MM02")]
5450    CodeMM02,
5451    #[serde(rename = "MM03")]
5452    CodeMM03,
5453    #[serde(rename = "MM04")]
5454    CodeMM04,
5455    #[serde(rename = "MM05")]
5456    CodeMM05,
5457    #[serde(rename = "MM06")]
5458    CodeMM06,
5459    #[serde(rename = "MM07")]
5460    CodeMM07,
5461    #[serde(rename = "MM08")]
5462    CodeMM08,
5463    #[serde(rename = "MM09")]
5464    CodeMM09,
5465    #[serde(rename = "MM10")]
5466    CodeMM10,
5467    #[serde(rename = "MM11")]
5468    CodeMM11,
5469    #[serde(rename = "MM12")]
5470    CodeMM12,
5471    #[serde(rename = "QTR1")]
5472    CodeQTR1,
5473    #[serde(rename = "QTR2")]
5474    CodeQTR2,
5475    #[serde(rename = "QTR3")]
5476    CodeQTR3,
5477    #[serde(rename = "QTR4")]
5478    CodeQTR4,
5479    #[serde(rename = "HLF1")]
5480    CodeHLF1,
5481    #[serde(rename = "HLF2")]
5482    CodeHLF2,
5483}
5484
5485impl TaxRecordPeriod1Code {
5486    pub fn validate(&self) -> Result<(), ValidationError> {
5487        Ok(())
5488    }
5489}