mx_message/document/
pacs_008_001_08.rs

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