mx_message/document/
camt_053_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// AccountInterest41: Provides details on the tax applied to charges.
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountInterest41 {
54    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
55    pub tp: Option<InterestType1Choice1>,
56    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
57    pub rate: Option<Vec<Rate41>>,
58    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
59    pub fr_to_dt: Option<DateTimePeriod11>,
60    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
61    pub rsn: Option<String>,
62    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
63    pub tax: Option<TaxCharges21>,
64}
65
66impl AccountInterest41 {
67    pub fn validate(&self) -> Result<(), ValidationError> {
68        if let Some(ref val) = self.tp {
69            val.validate()?
70        }
71        if let Some(ref vec) = self.rate {
72            for item in vec {
73                item.validate()?
74            }
75        }
76        if let Some(ref val) = self.fr_to_dt {
77            val.validate()?
78        }
79        if let Some(ref val) = self.rsn {
80            if val.chars().count() < 1 {
81                return Err(ValidationError::new(
82                    1001,
83                    "rsn is shorter than the minimum length of 1".to_string(),
84                ));
85            }
86            if val.chars().count() > 35 {
87                return Err(ValidationError::new(
88                    1002,
89                    "rsn exceeds the maximum length of 35".to_string(),
90                ));
91            }
92            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
93            if !pattern.is_match(val) {
94                return Err(ValidationError::new(
95                    1005,
96                    "rsn does not match the required pattern".to_string(),
97                ));
98            }
99        }
100        if let Some(ref val) = self.tax {
101            val.validate()?
102        }
103        Ok(())
104    }
105}
106
107// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
108#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
109pub struct AccountSchemeName1Choice1 {
110    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
111    pub cd: Option<String>,
112    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
113    pub prtry: Option<String>,
114}
115
116impl AccountSchemeName1Choice1 {
117    pub fn validate(&self) -> Result<(), ValidationError> {
118        if let Some(ref val) = self.cd {
119            if val.chars().count() < 1 {
120                return Err(ValidationError::new(
121                    1001,
122                    "cd is shorter than the minimum length of 1".to_string(),
123                ));
124            }
125            if val.chars().count() > 4 {
126                return Err(ValidationError::new(
127                    1002,
128                    "cd exceeds the maximum length of 4".to_string(),
129                ));
130            }
131        }
132        if let Some(ref val) = self.prtry {
133            if val.chars().count() < 1 {
134                return Err(ValidationError::new(
135                    1001,
136                    "prtry is shorter than the minimum length of 1".to_string(),
137                ));
138            }
139            if val.chars().count() > 35 {
140                return Err(ValidationError::new(
141                    1002,
142                    "prtry exceeds the maximum length of 35".to_string(),
143                ));
144            }
145            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
146            if !pattern.is_match(val) {
147                return Err(ValidationError::new(
148                    1005,
149                    "prtry does not match the required pattern".to_string(),
150                ));
151            }
152        }
153        Ok(())
154    }
155}
156
157// AccountStatement91: Further details of the account statement.
158#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
159pub struct AccountStatement91 {
160    #[serde(rename = "Id")]
161    pub id: String,
162    #[serde(rename = "StmtPgntn")]
163    pub stmt_pgntn: Pagination1,
164    #[serde(rename = "ElctrncSeqNb", skip_serializing_if = "Option::is_none")]
165    pub elctrnc_seq_nb: Option<f64>,
166    #[serde(rename = "RptgSeq", skip_serializing_if = "Option::is_none")]
167    pub rptg_seq: Option<SequenceRange1Choice1>,
168    #[serde(rename = "LglSeqNb", skip_serializing_if = "Option::is_none")]
169    pub lgl_seq_nb: Option<f64>,
170    #[serde(rename = "CreDtTm", skip_serializing_if = "Option::is_none")]
171    pub cre_dt_tm: Option<String>,
172    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
173    pub fr_to_dt: Option<DateTimePeriod11>,
174    #[serde(rename = "CpyDplctInd", skip_serializing_if = "Option::is_none")]
175    pub cpy_dplct_ind: Option<CopyDuplicate1Code>,
176    #[serde(rename = "RptgSrc", skip_serializing_if = "Option::is_none")]
177    pub rptg_src: Option<ReportingSource1Choice1>,
178    #[serde(rename = "Acct")]
179    pub acct: CashAccount391,
180    #[serde(rename = "RltdAcct", skip_serializing_if = "Option::is_none")]
181    pub rltd_acct: Option<CashAccount381>,
182    #[serde(rename = "Intrst", skip_serializing_if = "Option::is_none")]
183    pub intrst: Option<Vec<AccountInterest41>>,
184    #[serde(rename = "Bal")]
185    pub bal: Vec<CashBalance81>,
186    #[serde(rename = "TxsSummry", skip_serializing_if = "Option::is_none")]
187    pub txs_summry: Option<TotalTransactions61>,
188    #[serde(rename = "Ntry", skip_serializing_if = "Option::is_none")]
189    pub ntry: Option<Vec<ReportEntry101>>,
190    #[serde(rename = "AddtlStmtInf", skip_serializing_if = "Option::is_none")]
191    pub addtl_stmt_inf: Option<String>,
192}
193
194impl AccountStatement91 {
195    pub fn validate(&self) -> Result<(), ValidationError> {
196        if self.id.chars().count() < 1 {
197            return Err(ValidationError::new(
198                1001,
199                "id is shorter than the minimum length of 1".to_string(),
200            ));
201        }
202        if self.id.chars().count() > 35 {
203            return Err(ValidationError::new(
204                1002,
205                "id exceeds the maximum length of 35".to_string(),
206            ));
207        }
208        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
209        if !pattern.is_match(&self.id) {
210            return Err(ValidationError::new(
211                1005,
212                "id does not match the required pattern".to_string(),
213            ));
214        }
215        self.stmt_pgntn.validate()?;
216        if let Some(ref val) = self.rptg_seq {
217            val.validate()?
218        }
219        if let Some(ref val) = self.cre_dt_tm {
220            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
221            if !pattern.is_match(val) {
222                return Err(ValidationError::new(
223                    1005,
224                    "cre_dt_tm does not match the required pattern".to_string(),
225                ));
226            }
227        }
228        if let Some(ref val) = self.fr_to_dt {
229            val.validate()?
230        }
231        if let Some(ref val) = self.cpy_dplct_ind {
232            val.validate()?
233        }
234        if let Some(ref val) = self.rptg_src {
235            val.validate()?
236        }
237        self.acct.validate()?;
238        if let Some(ref val) = self.rltd_acct {
239            val.validate()?
240        }
241        if let Some(ref vec) = self.intrst {
242            for item in vec {
243                item.validate()?
244            }
245        }
246        for item in &self.bal {
247            item.validate()?
248        }
249        if let Some(ref val) = self.txs_summry {
250            val.validate()?
251        }
252        if let Some(ref vec) = self.ntry {
253            for item in vec {
254                item.validate()?
255            }
256        }
257        if let Some(ref val) = self.addtl_stmt_inf {
258            if val.chars().count() < 1 {
259                return Err(ValidationError::new(
260                    1001,
261                    "addtl_stmt_inf is shorter than the minimum length of 1".to_string(),
262                ));
263            }
264            if val.chars().count() > 500 {
265                return Err(ValidationError::new(
266                    1002,
267                    "addtl_stmt_inf exceeds the maximum length of 500".to_string(),
268                ));
269            }
270            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
271            if !pattern.is_match(val) {
272                return Err(ValidationError::new(
273                    1005,
274                    "addtl_stmt_inf does not match the required pattern".to_string(),
275                ));
276            }
277        }
278        Ok(())
279    }
280}
281
282// ActiveCurrencyAndAmount: A number of monetary units specified in an active currency where the unit of currency is explicit and compliant with ISO 4217.
283#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
284pub struct ActiveCurrencyAndAmount {
285    #[serde(rename = "@Ccy")]
286    pub ccy: String,
287    #[serde(rename = "$value")]
288    pub value: f64,
289}
290
291impl ActiveCurrencyAndAmount {
292    pub fn validate(&self) -> Result<(), ValidationError> {
293        Ok(())
294    }
295}
296
297// ActiveOrHistoricCurrencyAnd13DecimalAmount: 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. The number of fractional digits (or minor unit of currency) is not checked as per ISO 4217: It must be lesser than or equal to 13.
298// Note: The decimal separator is a dot.
299#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
300pub struct ActiveOrHistoricCurrencyAnd13DecimalAmount {
301    #[serde(rename = "@Ccy")]
302    pub ccy: String,
303    #[serde(rename = "$value")]
304    pub value: f64,
305}
306
307impl ActiveOrHistoricCurrencyAnd13DecimalAmount {
308    pub fn validate(&self) -> Result<(), ValidationError> {
309        Ok(())
310    }
311}
312
313// 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.
314#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
315pub struct ActiveOrHistoricCurrencyAndAmount {
316    #[serde(rename = "@Ccy")]
317    pub ccy: String,
318    #[serde(rename = "$value")]
319    pub value: f64,
320}
321
322impl ActiveOrHistoricCurrencyAndAmount {
323    pub fn validate(&self) -> Result<(), ValidationError> {
324        Ok(())
325    }
326}
327
328// ActiveOrHistoricCurrencyAndAmountRange2: Medium of exchange of value, used to qualify an amount.
329#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
330pub struct ActiveOrHistoricCurrencyAndAmountRange2 {
331    #[serde(rename = "Amt")]
332    pub amt: ImpliedCurrencyAmountRange1Choice,
333    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
334    pub cdt_dbt_ind: Option<CreditDebitCode>,
335    #[serde(rename = "Ccy")]
336    pub ccy: String,
337}
338
339impl ActiveOrHistoricCurrencyAndAmountRange2 {
340    pub fn validate(&self) -> Result<(), ValidationError> {
341        self.amt.validate()?;
342        if let Some(ref val) = self.cdt_dbt_ind {
343            val.validate()?
344        }
345        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
346        if !pattern.is_match(&self.ccy) {
347            return Err(ValidationError::new(
348                1005,
349                "ccy does not match the required pattern".to_string(),
350            ));
351        }
352        Ok(())
353    }
354}
355
356// AddressType2Code: Address is the address to which delivery is to take place.
357#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
358pub enum AddressType2Code {
359    #[default]
360    #[serde(rename = "ADDR")]
361    CodeADDR,
362    #[serde(rename = "PBOX")]
363    CodePBOX,
364    #[serde(rename = "HOME")]
365    CodeHOME,
366    #[serde(rename = "BIZZ")]
367    CodeBIZZ,
368    #[serde(rename = "MLTO")]
369    CodeMLTO,
370    #[serde(rename = "DLVY")]
371    CodeDLVY,
372}
373
374impl AddressType2Code {
375    pub fn validate(&self) -> Result<(), ValidationError> {
376        Ok(())
377    }
378}
379
380// AddressType3Choice1: Type of address expressed as a proprietary code.
381#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
382pub struct AddressType3Choice1 {
383    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
384    pub cd: Option<AddressType2Code>,
385    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
386    pub prtry: Option<GenericIdentification301>,
387}
388
389impl AddressType3Choice1 {
390    pub fn validate(&self) -> Result<(), ValidationError> {
391        if let Some(ref val) = self.cd {
392            val.validate()?
393        }
394        if let Some(ref val) = self.prtry {
395            val.validate()?
396        }
397        Ok(())
398    }
399}
400
401// AddressType3Choice2: Type of address expressed as a proprietary code.
402#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
403pub struct AddressType3Choice2 {
404    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
405    pub cd: Option<AddressType2Code>,
406    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
407    pub prtry: Option<GenericIdentification302>,
408}
409
410impl AddressType3Choice2 {
411    pub fn validate(&self) -> Result<(), ValidationError> {
412        if let Some(ref val) = self.cd {
413            val.validate()?
414        }
415        if let Some(ref val) = self.prtry {
416            val.validate()?
417        }
418        Ok(())
419    }
420}
421
422// AmountAndCurrencyExchange31: Set of elements used to provide information on the original amount and currency exchange.
423#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
424pub struct AmountAndCurrencyExchange31 {
425    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
426    pub instd_amt: Option<AmountAndCurrencyExchangeDetails31>,
427    #[serde(rename = "TxAmt", skip_serializing_if = "Option::is_none")]
428    pub tx_amt: Option<AmountAndCurrencyExchangeDetails31>,
429    #[serde(rename = "CntrValAmt", skip_serializing_if = "Option::is_none")]
430    pub cntr_val_amt: Option<AmountAndCurrencyExchangeDetails31>,
431    #[serde(rename = "AnncdPstngAmt", skip_serializing_if = "Option::is_none")]
432    pub anncd_pstng_amt: Option<AmountAndCurrencyExchangeDetails31>,
433    #[serde(rename = "PrtryAmt", skip_serializing_if = "Option::is_none")]
434    pub prtry_amt: Option<Vec<AmountAndCurrencyExchangeDetails41>>,
435}
436
437impl AmountAndCurrencyExchange31 {
438    pub fn validate(&self) -> Result<(), ValidationError> {
439        if let Some(ref val) = self.instd_amt {
440            val.validate()?
441        }
442        if let Some(ref val) = self.tx_amt {
443            val.validate()?
444        }
445        if let Some(ref val) = self.cntr_val_amt {
446            val.validate()?
447        }
448        if let Some(ref val) = self.anncd_pstng_amt {
449            val.validate()?
450        }
451        if let Some(ref vec) = self.prtry_amt {
452            for item in vec {
453                item.validate()?
454            }
455        }
456        Ok(())
457    }
458}
459
460// AmountAndCurrencyExchange32: Set of elements used to provide information on the original amount and currency exchange.
461#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
462pub struct AmountAndCurrencyExchange32 {
463    #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
464    pub instd_amt: Option<AmountAndCurrencyExchangeDetails32>,
465    #[serde(rename = "TxAmt", skip_serializing_if = "Option::is_none")]
466    pub tx_amt: Option<AmountAndCurrencyExchangeDetails32>,
467    #[serde(rename = "CntrValAmt", skip_serializing_if = "Option::is_none")]
468    pub cntr_val_amt: Option<AmountAndCurrencyExchangeDetails32>,
469    #[serde(rename = "AnncdPstngAmt", skip_serializing_if = "Option::is_none")]
470    pub anncd_pstng_amt: Option<AmountAndCurrencyExchangeDetails32>,
471    #[serde(rename = "PrtryAmt", skip_serializing_if = "Option::is_none")]
472    pub prtry_amt: Option<Vec<AmountAndCurrencyExchangeDetails42>>,
473}
474
475impl AmountAndCurrencyExchange32 {
476    pub fn validate(&self) -> Result<(), ValidationError> {
477        if let Some(ref val) = self.instd_amt {
478            val.validate()?
479        }
480        if let Some(ref val) = self.tx_amt {
481            val.validate()?
482        }
483        if let Some(ref val) = self.cntr_val_amt {
484            val.validate()?
485        }
486        if let Some(ref val) = self.anncd_pstng_amt {
487            val.validate()?
488        }
489        if let Some(ref vec) = self.prtry_amt {
490            for item in vec {
491                item.validate()?
492            }
493        }
494        Ok(())
495    }
496}
497
498// AmountAndCurrencyExchangeDetails31: Set of elements used to provide details on the currency exchange.
499#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
500pub struct AmountAndCurrencyExchangeDetails31 {
501    #[serde(rename = "Amt")]
502    pub amt: ActiveOrHistoricCurrencyAndAmount,
503    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
504    pub ccy_xchg: Option<CurrencyExchange51>,
505}
506
507impl AmountAndCurrencyExchangeDetails31 {
508    pub fn validate(&self) -> Result<(), ValidationError> {
509        self.amt.validate()?;
510        if let Some(ref val) = self.ccy_xchg {
511            val.validate()?
512        }
513        Ok(())
514    }
515}
516
517// AmountAndCurrencyExchangeDetails32: Set of elements used to provide details on the currency exchange.
518#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
519pub struct AmountAndCurrencyExchangeDetails32 {
520    #[serde(rename = "Amt")]
521    pub amt: ActiveOrHistoricCurrencyAndAmount,
522    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
523    pub ccy_xchg: Option<CurrencyExchange52>,
524}
525
526impl AmountAndCurrencyExchangeDetails32 {
527    pub fn validate(&self) -> Result<(), ValidationError> {
528        self.amt.validate()?;
529        if let Some(ref val) = self.ccy_xchg {
530            val.validate()?
531        }
532        Ok(())
533    }
534}
535
536// AmountAndCurrencyExchangeDetails41: Set of elements used to provide details on the currency exchange.
537#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
538pub struct AmountAndCurrencyExchangeDetails41 {
539    #[serde(rename = "Tp")]
540    pub tp: String,
541    #[serde(rename = "Amt")]
542    pub amt: ActiveOrHistoricCurrencyAndAmount,
543    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
544    pub ccy_xchg: Option<CurrencyExchange51>,
545}
546
547impl AmountAndCurrencyExchangeDetails41 {
548    pub fn validate(&self) -> Result<(), ValidationError> {
549        if self.tp.chars().count() < 1 {
550            return Err(ValidationError::new(
551                1001,
552                "tp is shorter than the minimum length of 1".to_string(),
553            ));
554        }
555        if self.tp.chars().count() > 35 {
556            return Err(ValidationError::new(
557                1002,
558                "tp exceeds the maximum length of 35".to_string(),
559            ));
560        }
561        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
562        if !pattern.is_match(&self.tp) {
563            return Err(ValidationError::new(
564                1005,
565                "tp does not match the required pattern".to_string(),
566            ));
567        }
568        self.amt.validate()?;
569        if let Some(ref val) = self.ccy_xchg {
570            val.validate()?
571        }
572        Ok(())
573    }
574}
575
576// AmountAndCurrencyExchangeDetails42: Set of elements used to provide details on the currency exchange.
577#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
578pub struct AmountAndCurrencyExchangeDetails42 {
579    #[serde(rename = "Tp")]
580    pub tp: String,
581    #[serde(rename = "Amt")]
582    pub amt: ActiveOrHistoricCurrencyAndAmount,
583    #[serde(rename = "CcyXchg", skip_serializing_if = "Option::is_none")]
584    pub ccy_xchg: Option<CurrencyExchange5>,
585}
586
587impl AmountAndCurrencyExchangeDetails42 {
588    pub fn validate(&self) -> Result<(), ValidationError> {
589        if self.tp.chars().count() < 1 {
590            return Err(ValidationError::new(
591                1001,
592                "tp is shorter than the minimum length of 1".to_string(),
593            ));
594        }
595        if self.tp.chars().count() > 35 {
596            return Err(ValidationError::new(
597                1002,
598                "tp exceeds the maximum length of 35".to_string(),
599            ));
600        }
601        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
602        if !pattern.is_match(&self.tp) {
603            return Err(ValidationError::new(
604                1005,
605                "tp does not match the required pattern".to_string(),
606            ));
607        }
608        self.amt.validate()?;
609        if let Some(ref val) = self.ccy_xchg {
610            val.validate()?
611        }
612        Ok(())
613    }
614}
615
616// AmountAndDirection35: Indicates whether the amount is a credit or a debit amount.
617#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
618pub struct AmountAndDirection35 {
619    #[serde(rename = "Amt")]
620    pub amt: f64,
621    #[serde(rename = "CdtDbtInd")]
622    pub cdt_dbt_ind: CreditDebitCode,
623}
624
625impl AmountAndDirection35 {
626    pub fn validate(&self) -> Result<(), ValidationError> {
627        if self.amt < 0.000000 {
628            return Err(ValidationError::new(
629                1003,
630                "amt is less than the minimum value of 0.000000".to_string(),
631            ));
632        }
633        self.cdt_dbt_ind.validate()?;
634        Ok(())
635    }
636}
637
638// AmountRangeBoundary1: Indicates whether the boundary amount is included in the range of amount values.
639#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
640pub struct AmountRangeBoundary1 {
641    #[serde(rename = "BdryAmt")]
642    pub bdry_amt: f64,
643    #[serde(rename = "Incl")]
644    pub incl: bool,
645}
646
647impl AmountRangeBoundary1 {
648    pub fn validate(&self) -> Result<(), ValidationError> {
649        if self.bdry_amt < 0.000000 {
650            return Err(ValidationError::new(
651                1003,
652                "bdry_amt is less than the minimum value of 0.000000".to_string(),
653            ));
654        }
655        Ok(())
656    }
657}
658
659// AttendanceContext1Code: Unattended payment, no attendant present.
660#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
661pub enum AttendanceContext1Code {
662    #[default]
663    #[serde(rename = "ATTD")]
664    CodeATTD,
665    #[serde(rename = "SATT")]
666    CodeSATT,
667    #[serde(rename = "UATT")]
668    CodeUATT,
669}
670
671impl AttendanceContext1Code {
672    pub fn validate(&self) -> Result<(), ValidationError> {
673        Ok(())
674    }
675}
676
677// AuthenticationEntity1Code: Merchant (for example signature verification by the attendant).
678#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
679pub enum AuthenticationEntity1Code {
680    #[default]
681    #[serde(rename = "ICCD")]
682    CodeICCD,
683    #[serde(rename = "AGNT")]
684    CodeAGNT,
685    #[serde(rename = "MERC")]
686    CodeMERC,
687}
688
689impl AuthenticationEntity1Code {
690    pub fn validate(&self) -> Result<(), ValidationError> {
691        Ok(())
692    }
693}
694
695// AuthenticationMethod1Code: Channel-encrypted transaction.
696#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
697pub enum AuthenticationMethod1Code {
698    #[default]
699    #[serde(rename = "UKNW")]
700    CodeUKNW,
701    #[serde(rename = "BYPS")]
702    CodeBYPS,
703    #[serde(rename = "NPIN")]
704    CodeNPIN,
705    #[serde(rename = "FPIN")]
706    CodeFPIN,
707    #[serde(rename = "CPSG")]
708    CodeCPSG,
709    #[serde(rename = "PPSG")]
710    CodePPSG,
711    #[serde(rename = "MANU")]
712    CodeMANU,
713    #[serde(rename = "MERC")]
714    CodeMERC,
715    #[serde(rename = "SCRT")]
716    CodeSCRT,
717    #[serde(rename = "SNCT")]
718    CodeSNCT,
719    #[serde(rename = "SCNL")]
720    CodeSCNL,
721}
722
723impl AuthenticationMethod1Code {
724    pub fn validate(&self) -> Result<(), ValidationError> {
725        Ok(())
726    }
727}
728
729// BalanceSubType1Choice1: Specifies a proprietary code for the balance type.
730#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
731pub struct BalanceSubType1Choice1 {
732    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
733    pub cd: Option<String>,
734    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
735    pub prtry: Option<String>,
736}
737
738impl BalanceSubType1Choice1 {
739    pub fn validate(&self) -> Result<(), ValidationError> {
740        if let Some(ref val) = self.cd {
741            if val.chars().count() < 1 {
742                return Err(ValidationError::new(
743                    1001,
744                    "cd is shorter than the minimum length of 1".to_string(),
745                ));
746            }
747            if val.chars().count() > 4 {
748                return Err(ValidationError::new(
749                    1002,
750                    "cd exceeds the maximum length of 4".to_string(),
751                ));
752            }
753        }
754        if let Some(ref val) = self.prtry {
755            if val.chars().count() < 1 {
756                return Err(ValidationError::new(
757                    1001,
758                    "prtry is shorter than the minimum length of 1".to_string(),
759                ));
760            }
761            if val.chars().count() > 35 {
762                return Err(ValidationError::new(
763                    1002,
764                    "prtry exceeds the maximum length of 35".to_string(),
765                ));
766            }
767            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
768            if !pattern.is_match(val) {
769                return Err(ValidationError::new(
770                    1005,
771                    "prtry does not match the required pattern".to_string(),
772                ));
773            }
774        }
775        Ok(())
776    }
777}
778
779// BalanceType10Choice1: Balance type, in a proprietary format.
780#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
781pub struct BalanceType10Choice1 {
782    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
783    pub cd: Option<String>,
784    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
785    pub prtry: Option<String>,
786}
787
788impl BalanceType10Choice1 {
789    pub fn validate(&self) -> Result<(), ValidationError> {
790        if let Some(ref val) = self.cd {
791            if val.chars().count() < 1 {
792                return Err(ValidationError::new(
793                    1001,
794                    "cd is shorter than the minimum length of 1".to_string(),
795                ));
796            }
797            if val.chars().count() > 4 {
798                return Err(ValidationError::new(
799                    1002,
800                    "cd exceeds the maximum length of 4".to_string(),
801                ));
802            }
803        }
804        if let Some(ref val) = self.prtry {
805            if val.chars().count() < 1 {
806                return Err(ValidationError::new(
807                    1001,
808                    "prtry is shorter than the minimum length of 1".to_string(),
809                ));
810            }
811            if val.chars().count() > 35 {
812                return Err(ValidationError::new(
813                    1002,
814                    "prtry exceeds the maximum length of 35".to_string(),
815                ));
816            }
817            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
818            if !pattern.is_match(val) {
819                return Err(ValidationError::new(
820                    1005,
821                    "prtry does not match the required pattern".to_string(),
822                ));
823            }
824        }
825        Ok(())
826    }
827}
828
829// BalanceType131: Specifies the balance sub-type.
830#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
831pub struct BalanceType131 {
832    #[serde(rename = "CdOrPrtry")]
833    pub cd_or_prtry: BalanceType10Choice1,
834    #[serde(rename = "SubTp", skip_serializing_if = "Option::is_none")]
835    pub sub_tp: Option<BalanceSubType1Choice1>,
836}
837
838impl BalanceType131 {
839    pub fn validate(&self) -> Result<(), ValidationError> {
840        self.cd_or_prtry.validate()?;
841        if let Some(ref val) = self.sub_tp {
842            val.validate()?
843        }
844        Ok(())
845    }
846}
847
848// BankToCustomerStatementV08: Reports on booked entries and balances for a cash account.
849#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
850pub struct BankToCustomerStatementV08 {
851    #[serde(rename = "GrpHdr")]
852    pub grp_hdr: GroupHeader811,
853    #[serde(rename = "Stmt")]
854    pub stmt: AccountStatement91,
855}
856
857impl BankToCustomerStatementV08 {
858    pub fn validate(&self) -> Result<(), ValidationError> {
859        self.grp_hdr.validate()?;
860        self.stmt.validate()?;
861        Ok(())
862    }
863}
864
865// BankTransactionCodeStructure41: Bank transaction code in a proprietary form, as defined by the issuer.
866#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
867pub struct BankTransactionCodeStructure41 {
868    #[serde(rename = "Domn", skip_serializing_if = "Option::is_none")]
869    pub domn: Option<BankTransactionCodeStructure5>,
870    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
871    pub prtry: Option<ProprietaryBankTransactionCodeStructure11>,
872}
873
874impl BankTransactionCodeStructure41 {
875    pub fn validate(&self) -> Result<(), ValidationError> {
876        if let Some(ref val) = self.domn {
877            val.validate()?
878        }
879        if let Some(ref val) = self.prtry {
880            val.validate()?
881        }
882        Ok(())
883    }
884}
885
886// BankTransactionCodeStructure5: Specifies the family and the sub-family of the bank transaction code, within a specific domain, in a structured and hierarchical format.
887#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
888pub struct BankTransactionCodeStructure5 {
889    #[serde(rename = "Cd")]
890    pub cd: String,
891    #[serde(rename = "Fmly")]
892    pub fmly: BankTransactionCodeStructure6,
893}
894
895impl BankTransactionCodeStructure5 {
896    pub fn validate(&self) -> Result<(), ValidationError> {
897        if self.cd.chars().count() < 1 {
898            return Err(ValidationError::new(
899                1001,
900                "cd is shorter than the minimum length of 1".to_string(),
901            ));
902        }
903        if self.cd.chars().count() > 4 {
904            return Err(ValidationError::new(
905                1002,
906                "cd exceeds the maximum length of 4".to_string(),
907            ));
908        }
909        self.fmly.validate()?;
910        Ok(())
911    }
912}
913
914// BankTransactionCodeStructure6: Specifies the sub-product family within a specific family.
915#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
916pub struct BankTransactionCodeStructure6 {
917    #[serde(rename = "Cd")]
918    pub cd: String,
919    #[serde(rename = "SubFmlyCd")]
920    pub sub_fmly_cd: String,
921}
922
923impl BankTransactionCodeStructure6 {
924    pub fn validate(&self) -> Result<(), ValidationError> {
925        if self.cd.chars().count() < 1 {
926            return Err(ValidationError::new(
927                1001,
928                "cd is shorter than the minimum length of 1".to_string(),
929            ));
930        }
931        if self.cd.chars().count() > 4 {
932            return Err(ValidationError::new(
933                1002,
934                "cd exceeds the maximum length of 4".to_string(),
935            ));
936        }
937        if self.sub_fmly_cd.chars().count() < 1 {
938            return Err(ValidationError::new(
939                1001,
940                "sub_fmly_cd is shorter than the minimum length of 1".to_string(),
941            ));
942        }
943        if self.sub_fmly_cd.chars().count() > 4 {
944            return Err(ValidationError::new(
945                1002,
946                "sub_fmly_cd exceeds the maximum length of 4".to_string(),
947            ));
948        }
949        Ok(())
950    }
951}
952
953// BatchInformation21: Indicates whether the batch entry is a credit or a debit entry.
954#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
955pub struct BatchInformation21 {
956    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
957    pub msg_id: Option<String>,
958    #[serde(rename = "PmtInfId", skip_serializing_if = "Option::is_none")]
959    pub pmt_inf_id: Option<String>,
960    #[serde(rename = "NbOfTxs", skip_serializing_if = "Option::is_none")]
961    pub nb_of_txs: Option<String>,
962    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
963    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
964    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
965    pub cdt_dbt_ind: Option<CreditDebitCode>,
966}
967
968impl BatchInformation21 {
969    pub fn validate(&self) -> Result<(), ValidationError> {
970        if let Some(ref val) = self.msg_id {
971            if val.chars().count() < 1 {
972                return Err(ValidationError::new(
973                    1001,
974                    "msg_id is shorter than the minimum length of 1".to_string(),
975                ));
976            }
977            if val.chars().count() > 35 {
978                return Err(ValidationError::new(
979                    1002,
980                    "msg_id exceeds the maximum length of 35".to_string(),
981                ));
982            }
983            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
984            if !pattern.is_match(val) {
985                return Err(ValidationError::new(
986                    1005,
987                    "msg_id does not match the required pattern".to_string(),
988                ));
989            }
990        }
991        if let Some(ref val) = self.pmt_inf_id {
992            if val.chars().count() < 1 {
993                return Err(ValidationError::new(
994                    1001,
995                    "pmt_inf_id is shorter than the minimum length of 1".to_string(),
996                ));
997            }
998            if val.chars().count() > 35 {
999                return Err(ValidationError::new(
1000                    1002,
1001                    "pmt_inf_id exceeds the maximum length of 35".to_string(),
1002                ));
1003            }
1004            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1005            if !pattern.is_match(val) {
1006                return Err(ValidationError::new(
1007                    1005,
1008                    "pmt_inf_id does not match the required pattern".to_string(),
1009                ));
1010            }
1011        }
1012        if let Some(ref val) = self.nb_of_txs {
1013            let pattern = Regex::new("[0-9]{1,15}").unwrap();
1014            if !pattern.is_match(val) {
1015                return Err(ValidationError::new(
1016                    1005,
1017                    "nb_of_txs does not match the required pattern".to_string(),
1018                ));
1019            }
1020        }
1021        if let Some(ref val) = self.ttl_amt {
1022            val.validate()?
1023        }
1024        if let Some(ref val) = self.cdt_dbt_ind {
1025            val.validate()?
1026        }
1027        Ok(())
1028    }
1029}
1030
1031// BranchAndFinancialInstitutionIdentification61: Identifies a specific branch of a financial institution.
1032//
1033// Usage: This component should be used in case the identification information in the financial institution component does not provide identification up to branch level.
1034#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1035pub struct BranchAndFinancialInstitutionIdentification61 {
1036    #[serde(rename = "FinInstnId")]
1037    pub fin_instn_id: FinancialInstitutionIdentification181,
1038    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
1039    pub brnch_id: Option<BranchData31>,
1040}
1041
1042impl BranchAndFinancialInstitutionIdentification61 {
1043    pub fn validate(&self) -> Result<(), ValidationError> {
1044        self.fin_instn_id.validate()?;
1045        if let Some(ref val) = self.brnch_id {
1046            val.validate()?
1047        }
1048        Ok(())
1049    }
1050}
1051
1052// BranchAndFinancialInstitutionIdentification62: Identifies a specific branch of a financial institution.
1053//
1054// Usage: This component should be used in case the identification information in the financial institution component does not provide identification up to branch level.
1055#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1056pub struct BranchAndFinancialInstitutionIdentification62 {
1057    #[serde(rename = "FinInstnId")]
1058    pub fin_instn_id: FinancialInstitutionIdentification181,
1059    #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
1060    pub brnch_id: Option<BranchData32>,
1061}
1062
1063impl BranchAndFinancialInstitutionIdentification62 {
1064    pub fn validate(&self) -> Result<(), ValidationError> {
1065        self.fin_instn_id.validate()?;
1066        if let Some(ref val) = self.brnch_id {
1067            val.validate()?
1068        }
1069        Ok(())
1070    }
1071}
1072
1073// BranchData31: Information that locates and identifies a specific address, as defined by postal services.
1074#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1075pub struct BranchData31 {
1076    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1077    pub id: Option<String>,
1078    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1079    pub lei: Option<String>,
1080    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1081    pub nm: Option<String>,
1082    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1083    pub pstl_adr: Option<PostalAddress242>,
1084}
1085
1086impl BranchData31 {
1087    pub fn validate(&self) -> Result<(), ValidationError> {
1088        if let Some(ref val) = self.id {
1089            if val.chars().count() < 1 {
1090                return Err(ValidationError::new(
1091                    1001,
1092                    "id is shorter than the minimum length of 1".to_string(),
1093                ));
1094            }
1095            if val.chars().count() > 35 {
1096                return Err(ValidationError::new(
1097                    1002,
1098                    "id exceeds the maximum length of 35".to_string(),
1099                ));
1100            }
1101            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1102            if !pattern.is_match(val) {
1103                return Err(ValidationError::new(
1104                    1005,
1105                    "id does not match the required pattern".to_string(),
1106                ));
1107            }
1108        }
1109        if let Some(ref val) = self.lei {
1110            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1111            if !pattern.is_match(val) {
1112                return Err(ValidationError::new(
1113                    1005,
1114                    "lei does not match the required pattern".to_string(),
1115                ));
1116            }
1117        }
1118        if let Some(ref val) = self.nm {
1119            if val.chars().count() < 1 {
1120                return Err(ValidationError::new(
1121                    1001,
1122                    "nm is shorter than the minimum length of 1".to_string(),
1123                ));
1124            }
1125            if val.chars().count() > 140 {
1126                return Err(ValidationError::new(
1127                    1002,
1128                    "nm exceeds the maximum length of 140".to_string(),
1129                ));
1130            }
1131            let pattern = Regex::new(
1132                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1133            )
1134            .unwrap();
1135            if !pattern.is_match(val) {
1136                return Err(ValidationError::new(
1137                    1005,
1138                    "nm does not match the required pattern".to_string(),
1139                ));
1140            }
1141        }
1142        if let Some(ref val) = self.pstl_adr {
1143            val.validate()?
1144        }
1145        Ok(())
1146    }
1147}
1148
1149// BranchData32: Information that locates and identifies a specific address, as defined by postal services.
1150#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1151pub struct BranchData32 {
1152    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1153    pub id: Option<String>,
1154    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1155    pub lei: Option<String>,
1156    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1157    pub nm: Option<String>,
1158    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1159    pub pstl_adr: Option<PostalAddress241>,
1160}
1161
1162impl BranchData32 {
1163    pub fn validate(&self) -> Result<(), ValidationError> {
1164        if let Some(ref val) = self.id {
1165            if val.chars().count() < 1 {
1166                return Err(ValidationError::new(
1167                    1001,
1168                    "id is shorter than the minimum length of 1".to_string(),
1169                ));
1170            }
1171            if val.chars().count() > 35 {
1172                return Err(ValidationError::new(
1173                    1002,
1174                    "id exceeds the maximum length of 35".to_string(),
1175                ));
1176            }
1177            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1178            if !pattern.is_match(val) {
1179                return Err(ValidationError::new(
1180                    1005,
1181                    "id does not match the required pattern".to_string(),
1182                ));
1183            }
1184        }
1185        if let Some(ref val) = self.lei {
1186            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1187            if !pattern.is_match(val) {
1188                return Err(ValidationError::new(
1189                    1005,
1190                    "lei does not match the required pattern".to_string(),
1191                ));
1192            }
1193        }
1194        if let Some(ref val) = self.nm {
1195            if val.chars().count() < 1 {
1196                return Err(ValidationError::new(
1197                    1001,
1198                    "nm is shorter than the minimum length of 1".to_string(),
1199                ));
1200            }
1201            if val.chars().count() > 140 {
1202                return Err(ValidationError::new(
1203                    1002,
1204                    "nm exceeds the maximum length of 140".to_string(),
1205                ));
1206            }
1207            let pattern = Regex::new(
1208                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1209            )
1210            .unwrap();
1211            if !pattern.is_match(val) {
1212                return Err(ValidationError::new(
1213                    1005,
1214                    "nm does not match the required pattern".to_string(),
1215                ));
1216            }
1217        }
1218        if let Some(ref val) = self.pstl_adr {
1219            val.validate()?
1220        }
1221        Ok(())
1222    }
1223}
1224
1225// CSCManagement1Code: No card security code imprint.
1226#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1227pub enum CSCManagement1Code {
1228    #[default]
1229    #[serde(rename = "PRST")]
1230    CodePRST,
1231    #[serde(rename = "BYPS")]
1232    CodeBYPS,
1233    #[serde(rename = "UNRD")]
1234    CodeUNRD,
1235    #[serde(rename = "NCSC")]
1236    CodeNCSC,
1237}
1238
1239impl CSCManagement1Code {
1240    pub fn validate(&self) -> Result<(), ValidationError> {
1241        Ok(())
1242    }
1243}
1244
1245// CardAggregated21: Date range on which the globalisation applies.
1246#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1247pub struct CardAggregated21 {
1248    #[serde(rename = "AddtlSvc", skip_serializing_if = "Option::is_none")]
1249    pub addtl_svc: Option<CardPaymentServiceType2Code>,
1250    #[serde(rename = "TxCtgy", skip_serializing_if = "Option::is_none")]
1251    pub tx_ctgy: Option<String>,
1252    #[serde(rename = "SaleRcncltnId", skip_serializing_if = "Option::is_none")]
1253    pub sale_rcncltn_id: Option<String>,
1254    #[serde(rename = "SeqNbRg", skip_serializing_if = "Option::is_none")]
1255    pub seq_nb_rg: Option<CardSequenceNumberRange11>,
1256    #[serde(rename = "TxDtRg", skip_serializing_if = "Option::is_none")]
1257    pub tx_dt_rg: Option<DateOrDateTimePeriod1Choice1>,
1258}
1259
1260impl CardAggregated21 {
1261    pub fn validate(&self) -> Result<(), ValidationError> {
1262        if let Some(ref val) = self.addtl_svc {
1263            val.validate()?
1264        }
1265        if let Some(ref val) = self.tx_ctgy {
1266            if val.chars().count() < 1 {
1267                return Err(ValidationError::new(
1268                    1001,
1269                    "tx_ctgy is shorter than the minimum length of 1".to_string(),
1270                ));
1271            }
1272            if val.chars().count() > 4 {
1273                return Err(ValidationError::new(
1274                    1002,
1275                    "tx_ctgy exceeds the maximum length of 4".to_string(),
1276                ));
1277            }
1278        }
1279        if let Some(ref val) = self.sale_rcncltn_id {
1280            if val.chars().count() < 1 {
1281                return Err(ValidationError::new(
1282                    1001,
1283                    "sale_rcncltn_id is shorter than the minimum length of 1".to_string(),
1284                ));
1285            }
1286            if val.chars().count() > 35 {
1287                return Err(ValidationError::new(
1288                    1002,
1289                    "sale_rcncltn_id exceeds the maximum length of 35".to_string(),
1290                ));
1291            }
1292            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1293            if !pattern.is_match(val) {
1294                return Err(ValidationError::new(
1295                    1005,
1296                    "sale_rcncltn_id does not match the required pattern".to_string(),
1297                ));
1298            }
1299        }
1300        if let Some(ref val) = self.seq_nb_rg {
1301            val.validate()?
1302        }
1303        if let Some(ref val) = self.tx_dt_rg {
1304            val.validate()?
1305        }
1306        Ok(())
1307    }
1308}
1309
1310// CardDataReading1Code: Contactless proximity reader, with application conform to the standard EMV (standard initiated by Europay, Mastercard and Visa).
1311#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1312pub enum CardDataReading1Code {
1313    #[default]
1314    #[serde(rename = "TAGC")]
1315    CodeTAGC,
1316    #[serde(rename = "PHYS")]
1317    CodePHYS,
1318    #[serde(rename = "BRCD")]
1319    CodeBRCD,
1320    #[serde(rename = "MGST")]
1321    CodeMGST,
1322    #[serde(rename = "CICC")]
1323    CodeCICC,
1324    #[serde(rename = "DFLE")]
1325    CodeDFLE,
1326    #[serde(rename = "CTLS")]
1327    CodeCTLS,
1328    #[serde(rename = "ECTL")]
1329    CodeECTL,
1330}
1331
1332impl CardDataReading1Code {
1333    pub fn validate(&self) -> Result<(), ValidationError> {
1334        Ok(())
1335    }
1336}
1337
1338// CardEntry41: Prepaid account for the transfer or loading of an amount of money.
1339#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1340pub struct CardEntry41 {
1341    #[serde(rename = "Card", skip_serializing_if = "Option::is_none")]
1342    pub card: Option<PaymentCard41>,
1343    #[serde(rename = "POI", skip_serializing_if = "Option::is_none")]
1344    pub poi: Option<PointOfInteraction11>,
1345    #[serde(rename = "AggtdNtry", skip_serializing_if = "Option::is_none")]
1346    pub aggtd_ntry: Option<CardAggregated21>,
1347    #[serde(rename = "PrePdAcct", skip_serializing_if = "Option::is_none")]
1348    pub pre_pd_acct: Option<CashAccount382>,
1349}
1350
1351impl CardEntry41 {
1352    pub fn validate(&self) -> Result<(), ValidationError> {
1353        if let Some(ref val) = self.card {
1354            val.validate()?
1355        }
1356        if let Some(ref val) = self.poi {
1357            val.validate()?
1358        }
1359        if let Some(ref val) = self.aggtd_ntry {
1360            val.validate()?
1361        }
1362        if let Some(ref val) = self.pre_pd_acct {
1363            val.validate()?
1364        }
1365        Ok(())
1366    }
1367}
1368
1369// CardIndividualTransaction21: Sequential number of the validation of the cash deposit.
1370// Usage: The sequential number is increased incrementally for each transaction.
1371#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1372pub struct CardIndividualTransaction21 {
1373    #[serde(rename = "ICCRltdData", skip_serializing_if = "Option::is_none")]
1374    pub icc_rltd_data: Option<String>,
1375    #[serde(rename = "PmtCntxt", skip_serializing_if = "Option::is_none")]
1376    pub pmt_cntxt: Option<PaymentContext3>,
1377    #[serde(rename = "AddtlSvc", skip_serializing_if = "Option::is_none")]
1378    pub addtl_svc: Option<CardPaymentServiceType2Code>,
1379    #[serde(rename = "TxCtgy", skip_serializing_if = "Option::is_none")]
1380    pub tx_ctgy: Option<String>,
1381    #[serde(rename = "SaleRcncltnId", skip_serializing_if = "Option::is_none")]
1382    pub sale_rcncltn_id: Option<String>,
1383    #[serde(rename = "SaleRefNb", skip_serializing_if = "Option::is_none")]
1384    pub sale_ref_nb: Option<String>,
1385    #[serde(rename = "RePresntmntRsn", skip_serializing_if = "Option::is_none")]
1386    pub re_presntmnt_rsn: Option<String>,
1387    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
1388    pub seq_nb: Option<String>,
1389    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
1390    pub tx_id: Option<TransactionIdentifier11>,
1391    #[serde(rename = "Pdct", skip_serializing_if = "Option::is_none")]
1392    pub pdct: Option<Product21>,
1393    #[serde(rename = "VldtnDt", skip_serializing_if = "Option::is_none")]
1394    pub vldtn_dt: Option<String>,
1395    #[serde(rename = "VldtnSeqNb", skip_serializing_if = "Option::is_none")]
1396    pub vldtn_seq_nb: Option<String>,
1397}
1398
1399impl CardIndividualTransaction21 {
1400    pub fn validate(&self) -> Result<(), ValidationError> {
1401        if let Some(ref val) = self.icc_rltd_data {
1402            if val.chars().count() < 1 {
1403                return Err(ValidationError::new(
1404                    1001,
1405                    "icc_rltd_data is shorter than the minimum length of 1".to_string(),
1406                ));
1407            }
1408            if val.chars().count() > 1025 {
1409                return Err(ValidationError::new(
1410                    1002,
1411                    "icc_rltd_data exceeds the maximum length of 1025".to_string(),
1412                ));
1413            }
1414            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1415            if !pattern.is_match(val) {
1416                return Err(ValidationError::new(
1417                    1005,
1418                    "icc_rltd_data does not match the required pattern".to_string(),
1419                ));
1420            }
1421        }
1422        if let Some(ref val) = self.pmt_cntxt {
1423            val.validate()?
1424        }
1425        if let Some(ref val) = self.addtl_svc {
1426            val.validate()?
1427        }
1428        if let Some(ref val) = self.tx_ctgy {
1429            if val.chars().count() < 1 {
1430                return Err(ValidationError::new(
1431                    1001,
1432                    "tx_ctgy is shorter than the minimum length of 1".to_string(),
1433                ));
1434            }
1435            if val.chars().count() > 4 {
1436                return Err(ValidationError::new(
1437                    1002,
1438                    "tx_ctgy exceeds the maximum length of 4".to_string(),
1439                ));
1440            }
1441        }
1442        if let Some(ref val) = self.sale_rcncltn_id {
1443            if val.chars().count() < 1 {
1444                return Err(ValidationError::new(
1445                    1001,
1446                    "sale_rcncltn_id is shorter than the minimum length of 1".to_string(),
1447                ));
1448            }
1449            if val.chars().count() > 35 {
1450                return Err(ValidationError::new(
1451                    1002,
1452                    "sale_rcncltn_id exceeds the maximum length of 35".to_string(),
1453                ));
1454            }
1455            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1456            if !pattern.is_match(val) {
1457                return Err(ValidationError::new(
1458                    1005,
1459                    "sale_rcncltn_id does not match the required pattern".to_string(),
1460                ));
1461            }
1462        }
1463        if let Some(ref val) = self.sale_ref_nb {
1464            if val.chars().count() < 1 {
1465                return Err(ValidationError::new(
1466                    1001,
1467                    "sale_ref_nb is shorter than the minimum length of 1".to_string(),
1468                ));
1469            }
1470            if val.chars().count() > 35 {
1471                return Err(ValidationError::new(
1472                    1002,
1473                    "sale_ref_nb exceeds the maximum length of 35".to_string(),
1474                ));
1475            }
1476            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1477            if !pattern.is_match(val) {
1478                return Err(ValidationError::new(
1479                    1005,
1480                    "sale_ref_nb does not match the required pattern".to_string(),
1481                ));
1482            }
1483        }
1484        if let Some(ref val) = self.re_presntmnt_rsn {
1485            if val.chars().count() < 1 {
1486                return Err(ValidationError::new(
1487                    1001,
1488                    "re_presntmnt_rsn is shorter than the minimum length of 1".to_string(),
1489                ));
1490            }
1491            if val.chars().count() > 4 {
1492                return Err(ValidationError::new(
1493                    1002,
1494                    "re_presntmnt_rsn exceeds the maximum length of 4".to_string(),
1495                ));
1496            }
1497        }
1498        if let Some(ref val) = self.seq_nb {
1499            if val.chars().count() < 1 {
1500                return Err(ValidationError::new(
1501                    1001,
1502                    "seq_nb is shorter than the minimum length of 1".to_string(),
1503                ));
1504            }
1505            if val.chars().count() > 35 {
1506                return Err(ValidationError::new(
1507                    1002,
1508                    "seq_nb exceeds the maximum length of 35".to_string(),
1509                ));
1510            }
1511            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1512            if !pattern.is_match(val) {
1513                return Err(ValidationError::new(
1514                    1005,
1515                    "seq_nb does not match the required pattern".to_string(),
1516                ));
1517            }
1518        }
1519        if let Some(ref val) = self.tx_id {
1520            val.validate()?
1521        }
1522        if let Some(ref val) = self.pdct {
1523            val.validate()?
1524        }
1525        if let Some(ref val) = self.vldtn_seq_nb {
1526            if val.chars().count() < 1 {
1527                return Err(ValidationError::new(
1528                    1001,
1529                    "vldtn_seq_nb is shorter than the minimum length of 1".to_string(),
1530                ));
1531            }
1532            if val.chars().count() > 35 {
1533                return Err(ValidationError::new(
1534                    1002,
1535                    "vldtn_seq_nb exceeds the maximum length of 35".to_string(),
1536                ));
1537            }
1538            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1539            if !pattern.is_match(val) {
1540                return Err(ValidationError::new(
1541                    1005,
1542                    "vldtn_seq_nb does not match the required pattern".to_string(),
1543                ));
1544            }
1545        }
1546        Ok(())
1547    }
1548}
1549
1550// CardPaymentServiceType2Code: Voice authorisation.
1551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1552pub enum CardPaymentServiceType2Code {
1553    #[default]
1554    #[serde(rename = "AGGR")]
1555    CodeAGGR,
1556    #[serde(rename = "DCCV")]
1557    CodeDCCV,
1558    #[serde(rename = "GRTT")]
1559    CodeGRTT,
1560    #[serde(rename = "INSP")]
1561    CodeINSP,
1562    #[serde(rename = "LOYT")]
1563    CodeLOYT,
1564    #[serde(rename = "NRES")]
1565    CodeNRES,
1566    #[serde(rename = "PUCO")]
1567    CodePUCO,
1568    #[serde(rename = "RECP")]
1569    CodeRECP,
1570    #[serde(rename = "SOAF")]
1571    CodeSOAF,
1572    #[serde(rename = "UNAF")]
1573    CodeUNAF,
1574    #[serde(rename = "VCAU")]
1575    CodeVCAU,
1576}
1577
1578impl CardPaymentServiceType2Code {
1579    pub fn validate(&self) -> Result<(), ValidationError> {
1580        Ok(())
1581    }
1582}
1583
1584// CardSecurityInformation1: Card security code (CSC).
1585#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1586pub struct CardSecurityInformation1 {
1587    #[serde(rename = "CSCMgmt")]
1588    pub csc_mgmt: CSCManagement1Code,
1589    #[serde(rename = "CSCVal", skip_serializing_if = "Option::is_none")]
1590    pub csc_val: Option<String>,
1591}
1592
1593impl CardSecurityInformation1 {
1594    pub fn validate(&self) -> Result<(), ValidationError> {
1595        self.csc_mgmt.validate()?;
1596        if let Some(ref val) = self.csc_val {
1597            let pattern = Regex::new("[0-9]{3,4}").unwrap();
1598            if !pattern.is_match(val) {
1599                return Err(ValidationError::new(
1600                    1005,
1601                    "csc_val does not match the required pattern".to_string(),
1602                ));
1603            }
1604        }
1605        Ok(())
1606    }
1607}
1608
1609// CardSequenceNumberRange11: CardSequenceNumberRange1: LastTransactionSequenceNumberMessage element to be finalised once feedback from Card SEG has been received.
1610#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1611pub struct CardSequenceNumberRange11 {
1612    #[serde(rename = "FrstTx", skip_serializing_if = "Option::is_none")]
1613    pub frst_tx: Option<String>,
1614    #[serde(rename = "LastTx", skip_serializing_if = "Option::is_none")]
1615    pub last_tx: Option<String>,
1616}
1617
1618impl CardSequenceNumberRange11 {
1619    pub fn validate(&self) -> Result<(), ValidationError> {
1620        if let Some(ref val) = self.frst_tx {
1621            if val.chars().count() < 1 {
1622                return Err(ValidationError::new(
1623                    1001,
1624                    "frst_tx is shorter than the minimum length of 1".to_string(),
1625                ));
1626            }
1627            if val.chars().count() > 35 {
1628                return Err(ValidationError::new(
1629                    1002,
1630                    "frst_tx exceeds the maximum length of 35".to_string(),
1631                ));
1632            }
1633            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1634            if !pattern.is_match(val) {
1635                return Err(ValidationError::new(
1636                    1005,
1637                    "frst_tx does not match the required pattern".to_string(),
1638                ));
1639            }
1640        }
1641        if let Some(ref val) = self.last_tx {
1642            if val.chars().count() < 1 {
1643                return Err(ValidationError::new(
1644                    1001,
1645                    "last_tx is shorter than the minimum length of 1".to_string(),
1646                ));
1647            }
1648            if val.chars().count() > 35 {
1649                return Err(ValidationError::new(
1650                    1002,
1651                    "last_tx exceeds the maximum length of 35".to_string(),
1652                ));
1653            }
1654            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1655            if !pattern.is_match(val) {
1656                return Err(ValidationError::new(
1657                    1005,
1658                    "last_tx does not match the required pattern".to_string(),
1659                ));
1660            }
1661        }
1662        Ok(())
1663    }
1664}
1665
1666// CardTransaction171: Prepaid account for the transfer or loading of an amount of money.
1667#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1668pub struct CardTransaction171 {
1669    #[serde(rename = "Card", skip_serializing_if = "Option::is_none")]
1670    pub card: Option<PaymentCard41>,
1671    #[serde(rename = "POI", skip_serializing_if = "Option::is_none")]
1672    pub poi: Option<PointOfInteraction12>,
1673    #[serde(rename = "Tx", skip_serializing_if = "Option::is_none")]
1674    pub tx: Option<CardTransaction3Choice1>,
1675    #[serde(rename = "PrePdAcct", skip_serializing_if = "Option::is_none")]
1676    pub pre_pd_acct: Option<CashAccount382>,
1677}
1678
1679impl CardTransaction171 {
1680    pub fn validate(&self) -> Result<(), ValidationError> {
1681        if let Some(ref val) = self.card {
1682            val.validate()?
1683        }
1684        if let Some(ref val) = self.poi {
1685            val.validate()?
1686        }
1687        if let Some(ref val) = self.tx {
1688            val.validate()?
1689        }
1690        if let Some(ref val) = self.pre_pd_acct {
1691            val.validate()?
1692        }
1693        Ok(())
1694    }
1695}
1696
1697// CardTransaction3Choice1: Card transaction details for the individual transaction, as recorded at the POI (point of interaction).
1698#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1699pub struct CardTransaction3Choice1 {
1700    #[serde(rename = "Aggtd", skip_serializing_if = "Option::is_none")]
1701    pub aggtd: Option<CardAggregated21>,
1702    #[serde(rename = "Indv", skip_serializing_if = "Option::is_none")]
1703    pub indv: Option<CardIndividualTransaction21>,
1704}
1705
1706impl CardTransaction3Choice1 {
1707    pub fn validate(&self) -> Result<(), ValidationError> {
1708        if let Some(ref val) = self.aggtd {
1709            val.validate()?
1710        }
1711        if let Some(ref val) = self.indv {
1712            val.validate()?
1713        }
1714        Ok(())
1715    }
1716}
1717
1718// CardholderAuthentication2: Entity or object in charge of verifying the cardholder authenticity.
1719#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1720pub struct CardholderAuthentication2 {
1721    #[serde(rename = "AuthntcnMtd")]
1722    pub authntcn_mtd: AuthenticationMethod1Code,
1723    #[serde(rename = "AuthntcnNtty")]
1724    pub authntcn_ntty: AuthenticationEntity1Code,
1725}
1726
1727impl CardholderAuthentication2 {
1728    pub fn validate(&self) -> Result<(), ValidationError> {
1729        self.authntcn_mtd.validate()?;
1730        self.authntcn_ntty.validate()?;
1731        Ok(())
1732    }
1733}
1734
1735// CardholderVerificationCapability1Code: Three domain secure (three domain secure authentication of the cardholder).
1736#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1737pub enum CardholderVerificationCapability1Code {
1738    #[default]
1739    #[serde(rename = "MNSG")]
1740    CodeMNSG,
1741    #[serde(rename = "NPIN")]
1742    CodeNPIN,
1743    #[serde(rename = "FCPN")]
1744    CodeFCPN,
1745    #[serde(rename = "FEPN")]
1746    CodeFEPN,
1747    #[serde(rename = "FDSG")]
1748    CodeFDSG,
1749    #[serde(rename = "FBIO")]
1750    CodeFBIO,
1751    #[serde(rename = "MNVR")]
1752    CodeMNVR,
1753    #[serde(rename = "FBIG")]
1754    CodeFBIG,
1755    #[serde(rename = "APKI")]
1756    CodeAPKI,
1757    #[serde(rename = "PKIS")]
1758    CodePKIS,
1759    #[serde(rename = "CHDT")]
1760    CodeCHDT,
1761    #[serde(rename = "SCEC")]
1762    CodeSCEC,
1763}
1764
1765impl CardholderVerificationCapability1Code {
1766    pub fn validate(&self) -> Result<(), ValidationError> {
1767        Ok(())
1768    }
1769}
1770
1771// CashAccount381: Specifies an alternate assumed name for the identification of the account.
1772#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1773pub struct CashAccount381 {
1774    #[serde(rename = "Id")]
1775    pub id: AccountIdentification4Choice1,
1776    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1777    pub tp: Option<CashAccountType2Choice1>,
1778    #[serde(rename = "Ccy")]
1779    pub ccy: String,
1780    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1781    pub nm: Option<String>,
1782    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1783    pub prxy: Option<ProxyAccountIdentification11>,
1784}
1785
1786impl CashAccount381 {
1787    pub fn validate(&self) -> Result<(), ValidationError> {
1788        self.id.validate()?;
1789        if let Some(ref val) = self.tp {
1790            val.validate()?
1791        }
1792        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1793        if !pattern.is_match(&self.ccy) {
1794            return Err(ValidationError::new(
1795                1005,
1796                "ccy does not match the required pattern".to_string(),
1797            ));
1798        }
1799        if let Some(ref val) = self.nm {
1800            if val.chars().count() < 1 {
1801                return Err(ValidationError::new(
1802                    1001,
1803                    "nm is shorter than the minimum length of 1".to_string(),
1804                ));
1805            }
1806            if val.chars().count() > 70 {
1807                return Err(ValidationError::new(
1808                    1002,
1809                    "nm exceeds the maximum length of 70".to_string(),
1810                ));
1811            }
1812            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1813            if !pattern.is_match(val) {
1814                return Err(ValidationError::new(
1815                    1005,
1816                    "nm does not match the required pattern".to_string(),
1817                ));
1818            }
1819        }
1820        if let Some(ref val) = self.prxy {
1821            val.validate()?
1822        }
1823        Ok(())
1824    }
1825}
1826
1827// CashAccount382: Specifies an alternate assumed name for the identification of the account.
1828#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1829pub struct CashAccount382 {
1830    #[serde(rename = "Id")]
1831    pub id: AccountIdentification4Choice1,
1832    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1833    pub tp: Option<CashAccountType2Choice1>,
1834    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
1835    pub ccy: Option<String>,
1836    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1837    pub nm: Option<String>,
1838    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1839    pub prxy: Option<ProxyAccountIdentification12>,
1840}
1841
1842impl CashAccount382 {
1843    pub fn validate(&self) -> Result<(), ValidationError> {
1844        self.id.validate()?;
1845        if let Some(ref val) = self.tp {
1846            val.validate()?
1847        }
1848        if let Some(ref val) = self.ccy {
1849            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1850            if !pattern.is_match(val) {
1851                return Err(ValidationError::new(
1852                    1005,
1853                    "ccy does not match the required pattern".to_string(),
1854                ));
1855            }
1856        }
1857        if let Some(ref val) = self.nm {
1858            if val.chars().count() < 1 {
1859                return Err(ValidationError::new(
1860                    1001,
1861                    "nm is shorter than the minimum length of 1".to_string(),
1862                ));
1863            }
1864            if val.chars().count() > 70 {
1865                return Err(ValidationError::new(
1866                    1002,
1867                    "nm exceeds the maximum length of 70".to_string(),
1868                ));
1869            }
1870            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1871            if !pattern.is_match(val) {
1872                return Err(ValidationError::new(
1873                    1005,
1874                    "nm does not match the required pattern".to_string(),
1875                ));
1876            }
1877        }
1878        if let Some(ref val) = self.prxy {
1879            val.validate()?
1880        }
1881        Ok(())
1882    }
1883}
1884
1885// CashAccount383: Specifies an alternate assumed name for the identification of the account.
1886#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1887pub struct CashAccount383 {
1888    #[serde(rename = "Id")]
1889    pub id: AccountIdentification4Choice1,
1890    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1891    pub tp: Option<CashAccountType2Choice1>,
1892    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
1893    pub ccy: Option<String>,
1894    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1895    pub nm: Option<String>,
1896    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1897    pub prxy: Option<ProxyAccountIdentification11>,
1898}
1899
1900impl CashAccount383 {
1901    pub fn validate(&self) -> Result<(), ValidationError> {
1902        self.id.validate()?;
1903        if let Some(ref val) = self.tp {
1904            val.validate()?
1905        }
1906        if let Some(ref val) = self.ccy {
1907            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1908            if !pattern.is_match(val) {
1909                return Err(ValidationError::new(
1910                    1005,
1911                    "ccy does not match the required pattern".to_string(),
1912                ));
1913            }
1914        }
1915        if let Some(ref val) = self.nm {
1916            if val.chars().count() < 1 {
1917                return Err(ValidationError::new(
1918                    1001,
1919                    "nm is shorter than the minimum length of 1".to_string(),
1920                ));
1921            }
1922            if val.chars().count() > 70 {
1923                return Err(ValidationError::new(
1924                    1002,
1925                    "nm exceeds the maximum length of 70".to_string(),
1926                ));
1927            }
1928            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1929            if !pattern.is_match(val) {
1930                return Err(ValidationError::new(
1931                    1005,
1932                    "nm does not match the required pattern".to_string(),
1933                ));
1934            }
1935        }
1936        if let Some(ref val) = self.prxy {
1937            val.validate()?
1938        }
1939        Ok(())
1940    }
1941}
1942
1943// CashAccount391: Party that manages the account on behalf of the account owner, that is manages the registration and booking of entries on the account, calculates balances on the account and provides information about the account.
1944#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1945pub struct CashAccount391 {
1946    #[serde(rename = "Id")]
1947    pub id: AccountIdentification4Choice1,
1948    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1949    pub tp: Option<CashAccountType2Choice1>,
1950    #[serde(rename = "Ccy")]
1951    pub ccy: String,
1952    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1953    pub nm: Option<String>,
1954    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
1955    pub prxy: Option<ProxyAccountIdentification11>,
1956    #[serde(rename = "Ownr", skip_serializing_if = "Option::is_none")]
1957    pub ownr: Option<PartyIdentification1352>,
1958    #[serde(rename = "Svcr", skip_serializing_if = "Option::is_none")]
1959    pub svcr: Option<BranchAndFinancialInstitutionIdentification61>,
1960}
1961
1962impl CashAccount391 {
1963    pub fn validate(&self) -> Result<(), ValidationError> {
1964        self.id.validate()?;
1965        if let Some(ref val) = self.tp {
1966            val.validate()?
1967        }
1968        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
1969        if !pattern.is_match(&self.ccy) {
1970            return Err(ValidationError::new(
1971                1005,
1972                "ccy does not match the required pattern".to_string(),
1973            ));
1974        }
1975        if let Some(ref val) = self.nm {
1976            if val.chars().count() < 1 {
1977                return Err(ValidationError::new(
1978                    1001,
1979                    "nm is shorter than the minimum length of 1".to_string(),
1980                ));
1981            }
1982            if val.chars().count() > 70 {
1983                return Err(ValidationError::new(
1984                    1002,
1985                    "nm exceeds the maximum length of 70".to_string(),
1986                ));
1987            }
1988            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1989            if !pattern.is_match(val) {
1990                return Err(ValidationError::new(
1991                    1005,
1992                    "nm does not match the required pattern".to_string(),
1993                ));
1994            }
1995        }
1996        if let Some(ref val) = self.prxy {
1997            val.validate()?
1998        }
1999        if let Some(ref val) = self.ownr {
2000            val.validate()?
2001        }
2002        if let Some(ref val) = self.svcr {
2003            val.validate()?
2004        }
2005        Ok(())
2006    }
2007}
2008
2009// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
2010#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2011pub struct CashAccountType2Choice1 {
2012    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2013    pub cd: Option<String>,
2014    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2015    pub prtry: Option<String>,
2016}
2017
2018impl CashAccountType2Choice1 {
2019    pub fn validate(&self) -> Result<(), ValidationError> {
2020        if let Some(ref val) = self.cd {
2021            if val.chars().count() < 1 {
2022                return Err(ValidationError::new(
2023                    1001,
2024                    "cd is shorter than the minimum length of 1".to_string(),
2025                ));
2026            }
2027            if val.chars().count() > 4 {
2028                return Err(ValidationError::new(
2029                    1002,
2030                    "cd exceeds the maximum length of 4".to_string(),
2031                ));
2032            }
2033        }
2034        if let Some(ref val) = self.prtry {
2035            if val.chars().count() < 1 {
2036                return Err(ValidationError::new(
2037                    1001,
2038                    "prtry is shorter than the minimum length of 1".to_string(),
2039                ));
2040            }
2041            if val.chars().count() > 35 {
2042                return Err(ValidationError::new(
2043                    1002,
2044                    "prtry exceeds the maximum length of 35".to_string(),
2045                ));
2046            }
2047            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2048            if !pattern.is_match(val) {
2049                return Err(ValidationError::new(
2050                    1005,
2051                    "prtry does not match the required pattern".to_string(),
2052                ));
2053            }
2054        }
2055        Ok(())
2056    }
2057}
2058
2059// CashAvailability1: Indicates whether the availability balance is a credit or a debit balance.
2060// Usage: A zero balance is considered to be a credit balance.
2061#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2062pub struct CashAvailability1 {
2063    #[serde(rename = "Dt")]
2064    pub dt: CashAvailabilityDate1Choice,
2065    #[serde(rename = "Amt")]
2066    pub amt: ActiveOrHistoricCurrencyAndAmount,
2067    #[serde(rename = "CdtDbtInd")]
2068    pub cdt_dbt_ind: CreditDebitCode,
2069}
2070
2071impl CashAvailability1 {
2072    pub fn validate(&self) -> Result<(), ValidationError> {
2073        self.dt.validate()?;
2074        self.amt.validate()?;
2075        self.cdt_dbt_ind.validate()?;
2076        Ok(())
2077    }
2078}
2079
2080// CashAvailabilityDate1Choice: Identifies the actual availability date.
2081#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2082pub struct CashAvailabilityDate1Choice {
2083    #[serde(rename = "NbOfDays", skip_serializing_if = "Option::is_none")]
2084    pub nb_of_days: Option<String>,
2085    #[serde(rename = "ActlDt", skip_serializing_if = "Option::is_none")]
2086    pub actl_dt: Option<String>,
2087}
2088
2089impl CashAvailabilityDate1Choice {
2090    pub fn validate(&self) -> Result<(), ValidationError> {
2091        if let Some(ref val) = self.nb_of_days {
2092            let pattern = Regex::new("[\\+]{0,1}[0-9]{1,15}").unwrap();
2093            if !pattern.is_match(val) {
2094                return Err(ValidationError::new(
2095                    1005,
2096                    "nb_of_days does not match the required pattern".to_string(),
2097                ));
2098            }
2099        }
2100        Ok(())
2101    }
2102}
2103
2104// CashBalance81: Set of elements used to indicate when the booked amount of money will become available, that is can be accessed and starts generating interest.
2105//
2106// Usage: This type of information is used in the US and is linked to particular instruments such as cheques.
2107// Example: When a cheque is deposited, it will be booked on the deposit day, but the amount of money will only be accessible as of the indicated availability day (according to national banking regulations).
2108#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2109pub struct CashBalance81 {
2110    #[serde(rename = "Tp")]
2111    pub tp: BalanceType131,
2112    #[serde(rename = "CdtLine", skip_serializing_if = "Option::is_none")]
2113    pub cdt_line: Option<Vec<CreditLine31>>,
2114    #[serde(rename = "Amt")]
2115    pub amt: ActiveOrHistoricCurrencyAndAmount,
2116    #[serde(rename = "CdtDbtInd")]
2117    pub cdt_dbt_ind: CreditDebitCode,
2118    #[serde(rename = "Dt")]
2119    pub dt: DateAndDateTime2Choice1,
2120    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
2121    pub avlbty: Option<Vec<CashAvailability1>>,
2122}
2123
2124impl CashBalance81 {
2125    pub fn validate(&self) -> Result<(), ValidationError> {
2126        self.tp.validate()?;
2127        if let Some(ref vec) = self.cdt_line {
2128            for item in vec {
2129                item.validate()?
2130            }
2131        }
2132        self.amt.validate()?;
2133        self.cdt_dbt_ind.validate()?;
2134        self.dt.validate()?;
2135        if let Some(ref vec) = self.avlbty {
2136            for item in vec {
2137                item.validate()?
2138            }
2139        }
2140        Ok(())
2141    }
2142}
2143
2144// CashDeposit1: Specifies the total amount of money in the cash deposit, that is the note denomination times the number of notes.
2145#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2146pub struct CashDeposit1 {
2147    #[serde(rename = "NoteDnmtn")]
2148    pub note_dnmtn: ActiveCurrencyAndAmount,
2149    #[serde(rename = "NbOfNotes")]
2150    pub nb_of_notes: String,
2151    #[serde(rename = "Amt")]
2152    pub amt: ActiveCurrencyAndAmount,
2153}
2154
2155impl CashDeposit1 {
2156    pub fn validate(&self) -> Result<(), ValidationError> {
2157        self.note_dnmtn.validate()?;
2158        let pattern = Regex::new("[0-9]{1,15}").unwrap();
2159        if !pattern.is_match(&self.nb_of_notes) {
2160            return Err(ValidationError::new(
2161                1005,
2162                "nb_of_notes does not match the required pattern".to_string(),
2163            ));
2164        }
2165        self.amt.validate()?;
2166        Ok(())
2167    }
2168}
2169
2170// ChargeBearerType1Code: Charges are to be applied following the rules agreed in the service level and/or scheme.
2171#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2172pub enum ChargeBearerType1Code {
2173    #[default]
2174    #[serde(rename = "DEBT")]
2175    CodeDEBT,
2176    #[serde(rename = "CRED")]
2177    CodeCRED,
2178    #[serde(rename = "SHAR")]
2179    CodeSHAR,
2180    #[serde(rename = "SLEV")]
2181    CodeSLEV,
2182}
2183
2184impl ChargeBearerType1Code {
2185    pub fn validate(&self) -> Result<(), ValidationError> {
2186        Ok(())
2187    }
2188}
2189
2190// ChargeType3Choice1: Type of charge in a proprietary form, as defined by the issuer.
2191#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2192pub struct ChargeType3Choice1 {
2193    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2194    pub cd: Option<String>,
2195    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2196    pub prtry: Option<GenericIdentification31>,
2197}
2198
2199impl ChargeType3Choice1 {
2200    pub fn validate(&self) -> Result<(), ValidationError> {
2201        if let Some(ref val) = self.cd {
2202            if val.chars().count() < 1 {
2203                return Err(ValidationError::new(
2204                    1001,
2205                    "cd is shorter than the minimum length of 1".to_string(),
2206                ));
2207            }
2208            if val.chars().count() > 4 {
2209                return Err(ValidationError::new(
2210                    1002,
2211                    "cd exceeds the maximum length of 4".to_string(),
2212                ));
2213            }
2214        }
2215        if let Some(ref val) = self.prtry {
2216            val.validate()?
2217        }
2218        Ok(())
2219    }
2220}
2221
2222// Charges61: Provides details of the individual charges record.
2223#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2224pub struct Charges61 {
2225    #[serde(rename = "TtlChrgsAndTaxAmt", skip_serializing_if = "Option::is_none")]
2226    pub ttl_chrgs_and_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2227    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
2228    pub rcrd: Option<Vec<ChargesRecord31>>,
2229}
2230
2231impl Charges61 {
2232    pub fn validate(&self) -> Result<(), ValidationError> {
2233        if let Some(ref val) = self.ttl_chrgs_and_tax_amt {
2234            val.validate()?
2235        }
2236        if let Some(ref vec) = self.rcrd {
2237            for item in vec {
2238                item.validate()?
2239            }
2240        }
2241        Ok(())
2242    }
2243}
2244
2245// ChargesRecord31: Provides details on the tax applied to charges.
2246#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2247pub struct ChargesRecord31 {
2248    #[serde(rename = "Amt")]
2249    pub amt: ActiveOrHistoricCurrencyAndAmount,
2250    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
2251    pub cdt_dbt_ind: Option<CreditDebitCode>,
2252    #[serde(rename = "ChrgInclInd", skip_serializing_if = "Option::is_none")]
2253    pub chrg_incl_ind: Option<bool>,
2254    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2255    pub tp: Option<ChargeType3Choice1>,
2256    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
2257    pub rate: Option<f64>,
2258    #[serde(rename = "Br", skip_serializing_if = "Option::is_none")]
2259    pub br: Option<ChargeBearerType1Code>,
2260    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
2261    pub agt: Option<BranchAndFinancialInstitutionIdentification61>,
2262    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
2263    pub tax: Option<TaxCharges21>,
2264}
2265
2266impl ChargesRecord31 {
2267    pub fn validate(&self) -> Result<(), ValidationError> {
2268        self.amt.validate()?;
2269        if let Some(ref val) = self.cdt_dbt_ind {
2270            val.validate()?
2271        }
2272        if let Some(ref val) = self.tp {
2273            val.validate()?
2274        }
2275        if let Some(ref val) = self.br {
2276            val.validate()?
2277        }
2278        if let Some(ref val) = self.agt {
2279            val.validate()?
2280        }
2281        if let Some(ref val) = self.tax {
2282            val.validate()?
2283        }
2284        Ok(())
2285    }
2286}
2287
2288// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
2289#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2290pub struct ClearingSystemIdentification2Choice1 {
2291    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2292    pub cd: Option<String>,
2293}
2294
2295impl ClearingSystemIdentification2Choice1 {
2296    pub fn validate(&self) -> Result<(), ValidationError> {
2297        if let Some(ref val) = self.cd {
2298            if val.chars().count() < 1 {
2299                return Err(ValidationError::new(
2300                    1001,
2301                    "cd is shorter than the minimum length of 1".to_string(),
2302                ));
2303            }
2304            if val.chars().count() > 5 {
2305                return Err(ValidationError::new(
2306                    1002,
2307                    "cd exceeds the maximum length of 5".to_string(),
2308                ));
2309            }
2310        }
2311        Ok(())
2312    }
2313}
2314
2315// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
2316#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2317pub struct ClearingSystemMemberIdentification21 {
2318    #[serde(rename = "ClrSysId")]
2319    pub clr_sys_id: ClearingSystemIdentification2Choice1,
2320    #[serde(rename = "MmbId")]
2321    pub mmb_id: String,
2322}
2323
2324impl ClearingSystemMemberIdentification21 {
2325    pub fn validate(&self) -> Result<(), ValidationError> {
2326        self.clr_sys_id.validate()?;
2327        if self.mmb_id.chars().count() < 1 {
2328            return Err(ValidationError::new(
2329                1001,
2330                "mmb_id is shorter than the minimum length of 1".to_string(),
2331            ));
2332        }
2333        if self.mmb_id.chars().count() > 28 {
2334            return Err(ValidationError::new(
2335                1002,
2336                "mmb_id exceeds the maximum length of 28".to_string(),
2337            ));
2338        }
2339        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2340        if !pattern.is_match(&self.mmb_id) {
2341            return Err(ValidationError::new(
2342                1005,
2343                "mmb_id does not match the required pattern".to_string(),
2344            ));
2345        }
2346        Ok(())
2347    }
2348}
2349
2350// Contact41: Name by which a party is known and which is usually used to identify that party.
2351#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2352pub struct Contact41 {
2353    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2354    pub nm: Option<String>,
2355}
2356
2357impl Contact41 {
2358    pub fn validate(&self) -> Result<(), ValidationError> {
2359        if let Some(ref val) = self.nm {
2360            if val.chars().count() < 1 {
2361                return Err(ValidationError::new(
2362                    1001,
2363                    "nm is shorter than the minimum length of 1".to_string(),
2364                ));
2365            }
2366            if val.chars().count() > 140 {
2367                return Err(ValidationError::new(
2368                    1002,
2369                    "nm exceeds the maximum length of 140".to_string(),
2370                ));
2371            }
2372            let pattern = Regex::new(
2373                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2374            )
2375            .unwrap();
2376            if !pattern.is_match(val) {
2377                return Err(ValidationError::new(
2378                    1005,
2379                    "nm does not match the required pattern".to_string(),
2380                ));
2381            }
2382        }
2383        Ok(())
2384    }
2385}
2386
2387// Contact42: Preferred method used to reach the contact.
2388#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2389pub struct Contact42 {
2390    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2391    pub nm: Option<String>,
2392    #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
2393    pub prefrd_mtd: Option<PreferredContactMethod1Code>,
2394}
2395
2396impl Contact42 {
2397    pub fn validate(&self) -> Result<(), ValidationError> {
2398        if let Some(ref val) = self.nm {
2399            if val.chars().count() < 1 {
2400                return Err(ValidationError::new(
2401                    1001,
2402                    "nm is shorter than the minimum length of 1".to_string(),
2403                ));
2404            }
2405            if val.chars().count() > 140 {
2406                return Err(ValidationError::new(
2407                    1002,
2408                    "nm exceeds the maximum length of 140".to_string(),
2409                ));
2410            }
2411            let pattern = Regex::new(
2412                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2413            )
2414            .unwrap();
2415            if !pattern.is_match(val) {
2416                return Err(ValidationError::new(
2417                    1005,
2418                    "nm does not match the required pattern".to_string(),
2419                ));
2420            }
2421        }
2422        if let Some(ref val) = self.prefrd_mtd {
2423            val.validate()?
2424        }
2425        Ok(())
2426    }
2427}
2428
2429// CopyDuplicate1Code: Message is for information/confirmation purposes. It is a duplicate of a message previously sent.
2430#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2431pub enum CopyDuplicate1Code {
2432    #[default]
2433    #[serde(rename = "CODU")]
2434    CodeCODU,
2435    #[serde(rename = "COPY")]
2436    CodeCOPY,
2437    #[serde(rename = "DUPL")]
2438    CodeDUPL,
2439}
2440
2441impl CopyDuplicate1Code {
2442    pub fn validate(&self) -> Result<(), ValidationError> {
2443        Ok(())
2444    }
2445}
2446
2447// CorporateAction91: Identification of a corporate action assigned by an official central body/entity within a given market.
2448#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2449pub struct CorporateAction91 {
2450    #[serde(rename = "EvtTp")]
2451    pub evt_tp: String,
2452    #[serde(rename = "EvtId")]
2453    pub evt_id: String,
2454}
2455
2456impl CorporateAction91 {
2457    pub fn validate(&self) -> Result<(), ValidationError> {
2458        if self.evt_tp.chars().count() < 1 {
2459            return Err(ValidationError::new(
2460                1001,
2461                "evt_tp is shorter than the minimum length of 1".to_string(),
2462            ));
2463        }
2464        if self.evt_tp.chars().count() > 35 {
2465            return Err(ValidationError::new(
2466                1002,
2467                "evt_tp exceeds the maximum length of 35".to_string(),
2468            ));
2469        }
2470        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2471        if !pattern.is_match(&self.evt_tp) {
2472            return Err(ValidationError::new(
2473                1005,
2474                "evt_tp does not match the required pattern".to_string(),
2475            ));
2476        }
2477        if self.evt_id.chars().count() < 1 {
2478            return Err(ValidationError::new(
2479                1001,
2480                "evt_id is shorter than the minimum length of 1".to_string(),
2481            ));
2482        }
2483        if self.evt_id.chars().count() > 35 {
2484            return Err(ValidationError::new(
2485                1002,
2486                "evt_id exceeds the maximum length of 35".to_string(),
2487            ));
2488        }
2489        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2490        if !pattern.is_match(&self.evt_id) {
2491            return Err(ValidationError::new(
2492                1005,
2493                "evt_id does not match the required pattern".to_string(),
2494            ));
2495        }
2496        Ok(())
2497    }
2498}
2499
2500// CreditDebitCode: Operation is a decrease.
2501#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2502pub enum CreditDebitCode {
2503    #[default]
2504    #[serde(rename = "CRDT")]
2505    CodeCRDT,
2506    #[serde(rename = "DBIT")]
2507    CodeDBIT,
2508}
2509
2510impl CreditDebitCode {
2511    pub fn validate(&self) -> Result<(), ValidationError> {
2512        Ok(())
2513    }
2514}
2515
2516// CreditLine31: Date of the credit line provided when multiple credit lines may be provided.
2517#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2518pub struct CreditLine31 {
2519    #[serde(rename = "Incl")]
2520    pub incl: bool,
2521    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2522    pub tp: Option<CreditLineType1Choice1>,
2523    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
2524    pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2525    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2526    pub dt: Option<DateAndDateTime2Choice1>,
2527}
2528
2529impl CreditLine31 {
2530    pub fn validate(&self) -> Result<(), ValidationError> {
2531        if let Some(ref val) = self.tp {
2532            val.validate()?
2533        }
2534        if let Some(ref val) = self.amt {
2535            val.validate()?
2536        }
2537        if let Some(ref val) = self.dt {
2538            val.validate()?
2539        }
2540        Ok(())
2541    }
2542}
2543
2544// CreditLineType1Choice1: Type of the credit line, in a proprietary form.
2545#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2546pub struct CreditLineType1Choice1 {
2547    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2548    pub cd: Option<String>,
2549    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2550    pub prtry: Option<String>,
2551}
2552
2553impl CreditLineType1Choice1 {
2554    pub fn validate(&self) -> Result<(), ValidationError> {
2555        if let Some(ref val) = self.cd {
2556            if val.chars().count() < 1 {
2557                return Err(ValidationError::new(
2558                    1001,
2559                    "cd is shorter than the minimum length of 1".to_string(),
2560                ));
2561            }
2562            if val.chars().count() > 4 {
2563                return Err(ValidationError::new(
2564                    1002,
2565                    "cd exceeds the maximum length of 4".to_string(),
2566                ));
2567            }
2568        }
2569        if let Some(ref val) = self.prtry {
2570            if val.chars().count() < 1 {
2571                return Err(ValidationError::new(
2572                    1001,
2573                    "prtry is shorter than the minimum length of 1".to_string(),
2574                ));
2575            }
2576            if val.chars().count() > 35 {
2577                return Err(ValidationError::new(
2578                    1002,
2579                    "prtry exceeds the maximum length of 35".to_string(),
2580                ));
2581            }
2582            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2583            if !pattern.is_match(val) {
2584                return Err(ValidationError::new(
2585                    1005,
2586                    "prtry does not match the required pattern".to_string(),
2587                ));
2588            }
2589        }
2590        Ok(())
2591    }
2592}
2593
2594// CreditorReferenceInformation21: Unique reference, as assigned by the creditor, to unambiguously refer to the payment transaction.
2595//
2596// 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.
2597//
2598// 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.
2599#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2600pub struct CreditorReferenceInformation21 {
2601    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2602    pub tp: Option<CreditorReferenceType21>,
2603    #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
2604    pub ref_attr: Option<String>,
2605}
2606
2607impl CreditorReferenceInformation21 {
2608    pub fn validate(&self) -> Result<(), ValidationError> {
2609        if let Some(ref val) = self.tp {
2610            val.validate()?
2611        }
2612        if let Some(ref val) = self.ref_attr {
2613            if val.chars().count() < 1 {
2614                return Err(ValidationError::new(
2615                    1001,
2616                    "ref_attr is shorter than the minimum length of 1".to_string(),
2617                ));
2618            }
2619            if val.chars().count() > 35 {
2620                return Err(ValidationError::new(
2621                    1002,
2622                    "ref_attr exceeds the maximum length of 35".to_string(),
2623                ));
2624            }
2625            let pattern = Regex::new(
2626                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2627            )
2628            .unwrap();
2629            if !pattern.is_match(val) {
2630                return Err(ValidationError::new(
2631                    1005,
2632                    "ref_attr does not match the required pattern".to_string(),
2633                ));
2634            }
2635        }
2636        Ok(())
2637    }
2638}
2639
2640// CreditorReferenceType1Choice: Creditor reference type, in a proprietary form.
2641#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2642pub struct CreditorReferenceType1Choice {
2643    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2644    pub cd: Option<DocumentType3Code>,
2645    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2646    pub prtry: Option<String>,
2647}
2648
2649impl CreditorReferenceType1Choice {
2650    pub fn validate(&self) -> Result<(), ValidationError> {
2651        if let Some(ref val) = self.cd {
2652            val.validate()?
2653        }
2654        if let Some(ref val) = self.prtry {
2655            if val.chars().count() < 1 {
2656                return Err(ValidationError::new(
2657                    1001,
2658                    "prtry is shorter than the minimum length of 1".to_string(),
2659                ));
2660            }
2661            if val.chars().count() > 35 {
2662                return Err(ValidationError::new(
2663                    1002,
2664                    "prtry exceeds the maximum length of 35".to_string(),
2665                ));
2666            }
2667        }
2668        Ok(())
2669    }
2670}
2671
2672// CreditorReferenceType21: Entity that assigns the credit reference type.
2673#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2674pub struct CreditorReferenceType21 {
2675    #[serde(rename = "CdOrPrtry")]
2676    pub cd_or_prtry: CreditorReferenceType1Choice,
2677    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2678    pub issr: Option<String>,
2679}
2680
2681impl CreditorReferenceType21 {
2682    pub fn validate(&self) -> Result<(), ValidationError> {
2683        self.cd_or_prtry.validate()?;
2684        if let Some(ref val) = self.issr {
2685            if val.chars().count() < 1 {
2686                return Err(ValidationError::new(
2687                    1001,
2688                    "issr is shorter than the minimum length of 1".to_string(),
2689                ));
2690            }
2691            if val.chars().count() > 35 {
2692                return Err(ValidationError::new(
2693                    1002,
2694                    "issr exceeds the maximum length of 35".to_string(),
2695                ));
2696            }
2697            let pattern = Regex::new(
2698                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2699            )
2700            .unwrap();
2701            if !pattern.is_match(val) {
2702                return Err(ValidationError::new(
2703                    1005,
2704                    "issr does not match the required pattern".to_string(),
2705                ));
2706            }
2707        }
2708        Ok(())
2709    }
2710}
2711
2712// CurrencyExchange5: Date and time at which an exchange rate is quoted.
2713#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2714pub struct CurrencyExchange5 {
2715    #[serde(rename = "SrcCcy")]
2716    pub src_ccy: String,
2717    #[serde(rename = "TrgtCcy", skip_serializing_if = "Option::is_none")]
2718    pub trgt_ccy: Option<String>,
2719    #[serde(rename = "UnitCcy", skip_serializing_if = "Option::is_none")]
2720    pub unit_ccy: Option<String>,
2721    #[serde(rename = "XchgRate")]
2722    pub xchg_rate: f64,
2723    #[serde(rename = "CtrctId", skip_serializing_if = "Option::is_none")]
2724    pub ctrct_id: Option<String>,
2725    #[serde(rename = "QtnDt", skip_serializing_if = "Option::is_none")]
2726    pub qtn_dt: Option<String>,
2727}
2728
2729impl CurrencyExchange5 {
2730    pub fn validate(&self) -> Result<(), ValidationError> {
2731        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2732        if !pattern.is_match(&self.src_ccy) {
2733            return Err(ValidationError::new(
2734                1005,
2735                "src_ccy does not match the required pattern".to_string(),
2736            ));
2737        }
2738        if let Some(ref val) = self.trgt_ccy {
2739            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2740            if !pattern.is_match(val) {
2741                return Err(ValidationError::new(
2742                    1005,
2743                    "trgt_ccy does not match the required pattern".to_string(),
2744                ));
2745            }
2746        }
2747        if let Some(ref val) = self.unit_ccy {
2748            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2749            if !pattern.is_match(val) {
2750                return Err(ValidationError::new(
2751                    1005,
2752                    "unit_ccy does not match the required pattern".to_string(),
2753                ));
2754            }
2755        }
2756        if let Some(ref val) = self.ctrct_id {
2757            if val.chars().count() < 1 {
2758                return Err(ValidationError::new(
2759                    1001,
2760                    "ctrct_id is shorter than the minimum length of 1".to_string(),
2761                ));
2762            }
2763            if val.chars().count() > 35 {
2764                return Err(ValidationError::new(
2765                    1002,
2766                    "ctrct_id exceeds the maximum length of 35".to_string(),
2767                ));
2768            }
2769        }
2770        Ok(())
2771    }
2772}
2773
2774// CurrencyExchange51: Date and time at which an exchange rate is quoted.
2775#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2776pub struct CurrencyExchange51 {
2777    #[serde(rename = "SrcCcy")]
2778    pub src_ccy: String,
2779    #[serde(rename = "TrgtCcy", skip_serializing_if = "Option::is_none")]
2780    pub trgt_ccy: Option<String>,
2781    #[serde(rename = "UnitCcy", skip_serializing_if = "Option::is_none")]
2782    pub unit_ccy: Option<String>,
2783    #[serde(rename = "XchgRate")]
2784    pub xchg_rate: f64,
2785    #[serde(rename = "CtrctId", skip_serializing_if = "Option::is_none")]
2786    pub ctrct_id: Option<String>,
2787    #[serde(rename = "QtnDt", skip_serializing_if = "Option::is_none")]
2788    pub qtn_dt: Option<String>,
2789}
2790
2791impl CurrencyExchange51 {
2792    pub fn validate(&self) -> Result<(), ValidationError> {
2793        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2794        if !pattern.is_match(&self.src_ccy) {
2795            return Err(ValidationError::new(
2796                1005,
2797                "src_ccy does not match the required pattern".to_string(),
2798            ));
2799        }
2800        if let Some(ref val) = self.trgt_ccy {
2801            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2802            if !pattern.is_match(val) {
2803                return Err(ValidationError::new(
2804                    1005,
2805                    "trgt_ccy does not match the required pattern".to_string(),
2806                ));
2807            }
2808        }
2809        if let Some(ref val) = self.unit_ccy {
2810            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2811            if !pattern.is_match(val) {
2812                return Err(ValidationError::new(
2813                    1005,
2814                    "unit_ccy does not match the required pattern".to_string(),
2815                ));
2816            }
2817        }
2818        if let Some(ref val) = self.ctrct_id {
2819            if val.chars().count() < 1 {
2820                return Err(ValidationError::new(
2821                    1001,
2822                    "ctrct_id is shorter than the minimum length of 1".to_string(),
2823                ));
2824            }
2825            if val.chars().count() > 35 {
2826                return Err(ValidationError::new(
2827                    1002,
2828                    "ctrct_id exceeds the maximum length of 35".to_string(),
2829                ));
2830            }
2831            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2832            if !pattern.is_match(val) {
2833                return Err(ValidationError::new(
2834                    1005,
2835                    "ctrct_id does not match the required pattern".to_string(),
2836                ));
2837            }
2838        }
2839        if let Some(ref val) = self.qtn_dt {
2840            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2841            if !pattern.is_match(val) {
2842                return Err(ValidationError::new(
2843                    1005,
2844                    "qtn_dt does not match the required pattern".to_string(),
2845                ));
2846            }
2847        }
2848        Ok(())
2849    }
2850}
2851
2852// CurrencyExchange52: Date and time at which an exchange rate is quoted.
2853#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2854pub struct CurrencyExchange52 {
2855    #[serde(rename = "SrcCcy")]
2856    pub src_ccy: String,
2857    #[serde(rename = "TrgtCcy", skip_serializing_if = "Option::is_none")]
2858    pub trgt_ccy: Option<String>,
2859    #[serde(rename = "UnitCcy", skip_serializing_if = "Option::is_none")]
2860    pub unit_ccy: Option<String>,
2861    #[serde(rename = "XchgRate")]
2862    pub xchg_rate: f64,
2863    #[serde(rename = "CtrctId", skip_serializing_if = "Option::is_none")]
2864    pub ctrct_id: Option<String>,
2865    #[serde(rename = "QtnDt", skip_serializing_if = "Option::is_none")]
2866    pub qtn_dt: Option<String>,
2867}
2868
2869impl CurrencyExchange52 {
2870    pub fn validate(&self) -> Result<(), ValidationError> {
2871        let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2872        if !pattern.is_match(&self.src_ccy) {
2873            return Err(ValidationError::new(
2874                1005,
2875                "src_ccy does not match the required pattern".to_string(),
2876            ));
2877        }
2878        if let Some(ref val) = self.trgt_ccy {
2879            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2880            if !pattern.is_match(val) {
2881                return Err(ValidationError::new(
2882                    1005,
2883                    "trgt_ccy does not match the required pattern".to_string(),
2884                ));
2885            }
2886        }
2887        if let Some(ref val) = self.unit_ccy {
2888            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
2889            if !pattern.is_match(val) {
2890                return Err(ValidationError::new(
2891                    1005,
2892                    "unit_ccy does not match the required pattern".to_string(),
2893                ));
2894            }
2895        }
2896        if let Some(ref val) = self.ctrct_id {
2897            if val.chars().count() < 1 {
2898                return Err(ValidationError::new(
2899                    1001,
2900                    "ctrct_id is shorter than the minimum length of 1".to_string(),
2901                ));
2902            }
2903            if val.chars().count() > 35 {
2904                return Err(ValidationError::new(
2905                    1002,
2906                    "ctrct_id exceeds the maximum length of 35".to_string(),
2907                ));
2908            }
2909            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2910            if !pattern.is_match(val) {
2911                return Err(ValidationError::new(
2912                    1005,
2913                    "ctrct_id does not match the required pattern".to_string(),
2914                ));
2915            }
2916        }
2917        Ok(())
2918    }
2919}
2920
2921// DateAndDateTime2Choice: Specified date and time.
2922#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2923pub struct DateAndDateTime2Choice {
2924    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2925    pub dt: Option<String>,
2926    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
2927    pub dt_tm: Option<String>,
2928}
2929
2930impl DateAndDateTime2Choice {
2931    pub fn validate(&self) -> Result<(), ValidationError> {
2932        Ok(())
2933    }
2934}
2935
2936// DateAndDateTime2Choice1: Specified date and time.
2937#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2938pub struct DateAndDateTime2Choice1 {
2939    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2940    pub dt: Option<String>,
2941    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
2942    pub dt_tm: Option<String>,
2943}
2944
2945impl DateAndDateTime2Choice1 {
2946    pub fn validate(&self) -> Result<(), ValidationError> {
2947        if let Some(ref val) = self.dt_tm {
2948            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2949            if !pattern.is_match(val) {
2950                return Err(ValidationError::new(
2951                    1005,
2952                    "dt_tm does not match the required pattern".to_string(),
2953                ));
2954            }
2955        }
2956        Ok(())
2957    }
2958}
2959
2960// DateAndPlaceOfBirth11: Country where a person was born.
2961#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2962pub struct DateAndPlaceOfBirth11 {
2963    #[serde(rename = "BirthDt")]
2964    pub birth_dt: String,
2965    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
2966    pub prvc_of_birth: Option<String>,
2967    #[serde(rename = "CityOfBirth")]
2968    pub city_of_birth: String,
2969    #[serde(rename = "CtryOfBirth")]
2970    pub ctry_of_birth: String,
2971}
2972
2973impl DateAndPlaceOfBirth11 {
2974    pub fn validate(&self) -> Result<(), ValidationError> {
2975        if let Some(ref val) = self.prvc_of_birth {
2976            if val.chars().count() < 1 {
2977                return Err(ValidationError::new(
2978                    1001,
2979                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
2980                ));
2981            }
2982            if val.chars().count() > 35 {
2983                return Err(ValidationError::new(
2984                    1002,
2985                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
2986                ));
2987            }
2988            let pattern = Regex::new(
2989                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2990            )
2991            .unwrap();
2992            if !pattern.is_match(val) {
2993                return Err(ValidationError::new(
2994                    1005,
2995                    "prvc_of_birth does not match the required pattern".to_string(),
2996                ));
2997            }
2998        }
2999        if self.city_of_birth.chars().count() < 1 {
3000            return Err(ValidationError::new(
3001                1001,
3002                "city_of_birth is shorter than the minimum length of 1".to_string(),
3003            ));
3004        }
3005        if self.city_of_birth.chars().count() > 35 {
3006            return Err(ValidationError::new(
3007                1002,
3008                "city_of_birth exceeds the maximum length of 35".to_string(),
3009            ));
3010        }
3011        let pattern =
3012            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
3013                .unwrap();
3014        if !pattern.is_match(&self.city_of_birth) {
3015            return Err(ValidationError::new(
3016                1005,
3017                "city_of_birth does not match the required pattern".to_string(),
3018            ));
3019        }
3020        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3021        if !pattern.is_match(&self.ctry_of_birth) {
3022            return Err(ValidationError::new(
3023                1005,
3024                "ctry_of_birth does not match the required pattern".to_string(),
3025            ));
3026        }
3027        Ok(())
3028    }
3029}
3030
3031// DateOrDateTimePeriod1Choice1: Period expressed a dates and times.
3032#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3033pub struct DateOrDateTimePeriod1Choice1 {
3034    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3035    pub dt: Option<DatePeriod2>,
3036    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
3037    pub dt_tm: Option<DateTimePeriod11>,
3038}
3039
3040impl DateOrDateTimePeriod1Choice1 {
3041    pub fn validate(&self) -> Result<(), ValidationError> {
3042        if let Some(ref val) = self.dt {
3043            val.validate()?
3044        }
3045        if let Some(ref val) = self.dt_tm {
3046            val.validate()?
3047        }
3048        Ok(())
3049    }
3050}
3051
3052// DatePeriod2: End date of the range.
3053#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3054pub struct DatePeriod2 {
3055    #[serde(rename = "FrDt")]
3056    pub fr_dt: String,
3057    #[serde(rename = "ToDt")]
3058    pub to_dt: String,
3059}
3060
3061impl DatePeriod2 {
3062    pub fn validate(&self) -> Result<(), ValidationError> {
3063        Ok(())
3064    }
3065}
3066
3067// DateTimePeriod11: Date and time at which the period ends.
3068#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3069pub struct DateTimePeriod11 {
3070    #[serde(rename = "FrDtTm")]
3071    pub fr_dt_tm: String,
3072    #[serde(rename = "ToDtTm")]
3073    pub to_dt_tm: String,
3074}
3075
3076impl DateTimePeriod11 {
3077    pub fn validate(&self) -> Result<(), ValidationError> {
3078        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
3079        if !pattern.is_match(&self.fr_dt_tm) {
3080            return Err(ValidationError::new(
3081                1005,
3082                "fr_dt_tm does not match the required pattern".to_string(),
3083            ));
3084        }
3085        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
3086        if !pattern.is_match(&self.to_dt_tm) {
3087            return Err(ValidationError::new(
3088                1005,
3089                "to_dt_tm does not match the required pattern".to_string(),
3090            ));
3091        }
3092        Ok(())
3093    }
3094}
3095
3096// DiscountAmountAndType11: Amount of money, which has been typed.
3097#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3098pub struct DiscountAmountAndType11 {
3099    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3100    pub tp: Option<DiscountAmountType1Choice1>,
3101    #[serde(rename = "Amt")]
3102    pub amt: ActiveOrHistoricCurrencyAndAmount,
3103}
3104
3105impl DiscountAmountAndType11 {
3106    pub fn validate(&self) -> Result<(), ValidationError> {
3107        if let Some(ref val) = self.tp {
3108            val.validate()?
3109        }
3110        self.amt.validate()?;
3111        Ok(())
3112    }
3113}
3114
3115// DiscountAmountType1Choice1: Specifies the amount type, in a free-text form.
3116#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3117pub struct DiscountAmountType1Choice1 {
3118    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3119    pub cd: Option<String>,
3120    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3121    pub prtry: Option<String>,
3122}
3123
3124impl DiscountAmountType1Choice1 {
3125    pub fn validate(&self) -> Result<(), ValidationError> {
3126        if let Some(ref val) = self.cd {
3127            if val.chars().count() < 1 {
3128                return Err(ValidationError::new(
3129                    1001,
3130                    "cd is shorter than the minimum length of 1".to_string(),
3131                ));
3132            }
3133            if val.chars().count() > 4 {
3134                return Err(ValidationError::new(
3135                    1002,
3136                    "cd exceeds the maximum length of 4".to_string(),
3137                ));
3138            }
3139        }
3140        if let Some(ref val) = self.prtry {
3141            if val.chars().count() < 1 {
3142                return Err(ValidationError::new(
3143                    1001,
3144                    "prtry is shorter than the minimum length of 1".to_string(),
3145                ));
3146            }
3147            if val.chars().count() > 35 {
3148                return Err(ValidationError::new(
3149                    1002,
3150                    "prtry exceeds the maximum length of 35".to_string(),
3151                ));
3152            }
3153            let pattern = Regex::new(
3154                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3155            )
3156            .unwrap();
3157            if !pattern.is_match(val) {
3158                return Err(ValidationError::new(
3159                    1005,
3160                    "prtry does not match the required pattern".to_string(),
3161                ));
3162            }
3163        }
3164        Ok(())
3165    }
3166}
3167
3168// DisplayCapabilities1: Number of columns of the display component.
3169#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3170pub struct DisplayCapabilities1 {
3171    #[serde(rename = "DispTp")]
3172    pub disp_tp: UserInterface2Code,
3173    #[serde(rename = "NbOfLines")]
3174    pub nb_of_lines: String,
3175    #[serde(rename = "LineWidth")]
3176    pub line_width: String,
3177}
3178
3179impl DisplayCapabilities1 {
3180    pub fn validate(&self) -> Result<(), ValidationError> {
3181        self.disp_tp.validate()?;
3182        let pattern = Regex::new("[0-9]{1,3}").unwrap();
3183        if !pattern.is_match(&self.nb_of_lines) {
3184            return Err(ValidationError::new(
3185                1005,
3186                "nb_of_lines does not match the required pattern".to_string(),
3187            ));
3188        }
3189        let pattern = Regex::new("[0-9]{1,3}").unwrap();
3190        if !pattern.is_match(&self.line_width) {
3191            return Err(ValidationError::new(
3192                1005,
3193                "line_width does not match the required pattern".to_string(),
3194            ));
3195        }
3196        Ok(())
3197    }
3198}
3199
3200// DocumentAdjustment11: Provides further details on the document adjustment.
3201#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3202pub struct DocumentAdjustment11 {
3203    #[serde(rename = "Amt")]
3204    pub amt: ActiveOrHistoricCurrencyAndAmount,
3205    #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
3206    pub cdt_dbt_ind: Option<CreditDebitCode>,
3207    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
3208    pub rsn: Option<String>,
3209    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
3210    pub addtl_inf: Option<String>,
3211}
3212
3213impl DocumentAdjustment11 {
3214    pub fn validate(&self) -> Result<(), ValidationError> {
3215        self.amt.validate()?;
3216        if let Some(ref val) = self.cdt_dbt_ind {
3217            val.validate()?
3218        }
3219        if let Some(ref val) = self.rsn {
3220            if val.chars().count() < 1 {
3221                return Err(ValidationError::new(
3222                    1001,
3223                    "rsn is shorter than the minimum length of 1".to_string(),
3224                ));
3225            }
3226            if val.chars().count() > 4 {
3227                return Err(ValidationError::new(
3228                    1002,
3229                    "rsn exceeds the maximum length of 4".to_string(),
3230                ));
3231            }
3232            let pattern = Regex::new(
3233                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3234            )
3235            .unwrap();
3236            if !pattern.is_match(val) {
3237                return Err(ValidationError::new(
3238                    1005,
3239                    "rsn does not match the required pattern".to_string(),
3240                ));
3241            }
3242        }
3243        if let Some(ref val) = self.addtl_inf {
3244            if val.chars().count() < 1 {
3245                return Err(ValidationError::new(
3246                    1001,
3247                    "addtl_inf is shorter than the minimum length of 1".to_string(),
3248                ));
3249            }
3250            if val.chars().count() > 140 {
3251                return Err(ValidationError::new(
3252                    1002,
3253                    "addtl_inf exceeds the maximum length of 140".to_string(),
3254                ));
3255            }
3256            let pattern = Regex::new(
3257                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3258            )
3259            .unwrap();
3260            if !pattern.is_match(val) {
3261                return Err(ValidationError::new(
3262                    1005,
3263                    "addtl_inf does not match the required pattern".to_string(),
3264                ));
3265            }
3266        }
3267        Ok(())
3268    }
3269}
3270
3271// DocumentLineIdentification11: Date associated with the referred document line.
3272#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3273pub struct DocumentLineIdentification11 {
3274    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3275    pub tp: Option<DocumentLineType11>,
3276    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
3277    pub nb: Option<String>,
3278    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
3279    pub rltd_dt: Option<String>,
3280}
3281
3282impl DocumentLineIdentification11 {
3283    pub fn validate(&self) -> Result<(), ValidationError> {
3284        if let Some(ref val) = self.tp {
3285            val.validate()?
3286        }
3287        if let Some(ref val) = self.nb {
3288            if val.chars().count() < 1 {
3289                return Err(ValidationError::new(
3290                    1001,
3291                    "nb is shorter than the minimum length of 1".to_string(),
3292                ));
3293            }
3294            if val.chars().count() > 35 {
3295                return Err(ValidationError::new(
3296                    1002,
3297                    "nb exceeds the maximum length of 35".to_string(),
3298                ));
3299            }
3300            let pattern = Regex::new(
3301                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3302            )
3303            .unwrap();
3304            if !pattern.is_match(val) {
3305                return Err(ValidationError::new(
3306                    1005,
3307                    "nb does not match the required pattern".to_string(),
3308                ));
3309            }
3310        }
3311        Ok(())
3312    }
3313}
3314
3315// DocumentLineInformation11: Provides details on the amounts of the document line.
3316#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3317pub struct DocumentLineInformation11 {
3318    #[serde(rename = "Id")]
3319    pub id: Vec<DocumentLineIdentification11>,
3320    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
3321    pub desc: Option<String>,
3322    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
3323    pub amt: Option<RemittanceAmount31>,
3324}
3325
3326impl DocumentLineInformation11 {
3327    pub fn validate(&self) -> Result<(), ValidationError> {
3328        for item in &self.id {
3329            item.validate()?
3330        }
3331        if let Some(ref val) = self.desc {
3332            if val.chars().count() < 1 {
3333                return Err(ValidationError::new(
3334                    1001,
3335                    "desc is shorter than the minimum length of 1".to_string(),
3336                ));
3337            }
3338            if val.chars().count() > 35 {
3339                return Err(ValidationError::new(
3340                    1002,
3341                    "desc exceeds the maximum length of 35".to_string(),
3342                ));
3343            }
3344            let pattern = Regex::new(
3345                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3346            )
3347            .unwrap();
3348            if !pattern.is_match(val) {
3349                return Err(ValidationError::new(
3350                    1005,
3351                    "desc does not match the required pattern".to_string(),
3352                ));
3353            }
3354        }
3355        if let Some(ref val) = self.amt {
3356            val.validate()?
3357        }
3358        Ok(())
3359    }
3360}
3361
3362// DocumentLineType1Choice1: Proprietary identification of the type of the remittance document.
3363#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3364pub struct DocumentLineType1Choice1 {
3365    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3366    pub cd: Option<String>,
3367    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3368    pub prtry: Option<String>,
3369}
3370
3371impl DocumentLineType1Choice1 {
3372    pub fn validate(&self) -> Result<(), ValidationError> {
3373        if let Some(ref val) = self.cd {
3374            if val.chars().count() < 1 {
3375                return Err(ValidationError::new(
3376                    1001,
3377                    "cd is shorter than the minimum length of 1".to_string(),
3378                ));
3379            }
3380            if val.chars().count() > 4 {
3381                return Err(ValidationError::new(
3382                    1002,
3383                    "cd exceeds the maximum length of 4".to_string(),
3384                ));
3385            }
3386        }
3387        if let Some(ref val) = self.prtry {
3388            if val.chars().count() < 1 {
3389                return Err(ValidationError::new(
3390                    1001,
3391                    "prtry is shorter than the minimum length of 1".to_string(),
3392                ));
3393            }
3394            if val.chars().count() > 35 {
3395                return Err(ValidationError::new(
3396                    1002,
3397                    "prtry exceeds the maximum length of 35".to_string(),
3398                ));
3399            }
3400            let pattern = Regex::new(
3401                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3402            )
3403            .unwrap();
3404            if !pattern.is_match(val) {
3405                return Err(ValidationError::new(
3406                    1005,
3407                    "prtry does not match the required pattern".to_string(),
3408                ));
3409            }
3410        }
3411        Ok(())
3412    }
3413}
3414
3415// DocumentLineType11: Identification of the issuer of the reference document line identificationtype.
3416#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3417pub struct DocumentLineType11 {
3418    #[serde(rename = "CdOrPrtry")]
3419    pub cd_or_prtry: DocumentLineType1Choice1,
3420    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3421    pub issr: Option<String>,
3422}
3423
3424impl DocumentLineType11 {
3425    pub fn validate(&self) -> Result<(), ValidationError> {
3426        self.cd_or_prtry.validate()?;
3427        if let Some(ref val) = self.issr {
3428            if val.chars().count() < 1 {
3429                return Err(ValidationError::new(
3430                    1001,
3431                    "issr is shorter than the minimum length of 1".to_string(),
3432                ));
3433            }
3434            if val.chars().count() > 35 {
3435                return Err(ValidationError::new(
3436                    1002,
3437                    "issr exceeds the maximum length of 35".to_string(),
3438                ));
3439            }
3440            let pattern = Regex::new(
3441                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3442            )
3443            .unwrap();
3444            if !pattern.is_match(val) {
3445                return Err(ValidationError::new(
3446                    1005,
3447                    "issr does not match the required pattern".to_string(),
3448                ));
3449            }
3450        }
3451        Ok(())
3452    }
3453}
3454
3455// DocumentType3Code: Document is a structured communication reference provided by the creditor to identify the referred transaction.
3456#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3457pub enum DocumentType3Code {
3458    #[default]
3459    #[serde(rename = "RADM")]
3460    CodeRADM,
3461    #[serde(rename = "RPIN")]
3462    CodeRPIN,
3463    #[serde(rename = "FXDR")]
3464    CodeFXDR,
3465    #[serde(rename = "DISP")]
3466    CodeDISP,
3467    #[serde(rename = "PUOR")]
3468    CodePUOR,
3469    #[serde(rename = "SCOR")]
3470    CodeSCOR,
3471}
3472
3473impl DocumentType3Code {
3474    pub fn validate(&self) -> Result<(), ValidationError> {
3475        Ok(())
3476    }
3477}
3478
3479// DocumentType6Code: Document is a purchase order.
3480#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3481pub enum DocumentType6Code {
3482    #[default]
3483    #[serde(rename = "MSIN")]
3484    CodeMSIN,
3485    #[serde(rename = "CNFA")]
3486    CodeCNFA,
3487    #[serde(rename = "DNFA")]
3488    CodeDNFA,
3489    #[serde(rename = "CINV")]
3490    CodeCINV,
3491    #[serde(rename = "CREN")]
3492    CodeCREN,
3493    #[serde(rename = "DEBN")]
3494    CodeDEBN,
3495    #[serde(rename = "HIRI")]
3496    CodeHIRI,
3497    #[serde(rename = "SBIN")]
3498    CodeSBIN,
3499    #[serde(rename = "CMCN")]
3500    CodeCMCN,
3501    #[serde(rename = "SOAC")]
3502    CodeSOAC,
3503    #[serde(rename = "DISP")]
3504    CodeDISP,
3505    #[serde(rename = "BOLD")]
3506    CodeBOLD,
3507    #[serde(rename = "VCHR")]
3508    CodeVCHR,
3509    #[serde(rename = "AROI")]
3510    CodeAROI,
3511    #[serde(rename = "TSUT")]
3512    CodeTSUT,
3513    #[serde(rename = "PUOR")]
3514    CodePUOR,
3515}
3516
3517impl DocumentType6Code {
3518    pub fn validate(&self) -> Result<(), ValidationError> {
3519        Ok(())
3520    }
3521}
3522
3523// EntryDetails91: Provides information on the underlying transaction(s).
3524#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3525pub struct EntryDetails91 {
3526    #[serde(rename = "Btch", skip_serializing_if = "Option::is_none")]
3527    pub btch: Option<BatchInformation21>,
3528    #[serde(rename = "TxDtls")]
3529    pub tx_dtls: EntryTransaction101,
3530}
3531
3532impl EntryDetails91 {
3533    pub fn validate(&self) -> Result<(), ValidationError> {
3534        if let Some(ref val) = self.btch {
3535            val.validate()?
3536        }
3537        self.tx_dtls.validate()?;
3538        Ok(())
3539    }
3540}
3541
3542// EntryStatus1Choice1: Entry status, in a coded form.
3543#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3544pub struct EntryStatus1Choice1 {
3545    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3546    pub cd: Option<ExternalEntryStatus1Codefixed>,
3547}
3548
3549impl EntryStatus1Choice1 {
3550    pub fn validate(&self) -> Result<(), ValidationError> {
3551        if let Some(ref val) = self.cd {
3552            val.validate()?
3553        }
3554        Ok(())
3555    }
3556}
3557
3558// EntryTransaction101: Further details of the transaction.
3559#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3560pub struct EntryTransaction101 {
3561    #[serde(rename = "Refs")]
3562    pub refs: TransactionReferences61,
3563    #[serde(rename = "Amt")]
3564    pub amt: ActiveOrHistoricCurrencyAndAmount,
3565    #[serde(rename = "CdtDbtInd")]
3566    pub cdt_dbt_ind: CreditDebitCode,
3567    #[serde(rename = "AmtDtls", skip_serializing_if = "Option::is_none")]
3568    pub amt_dtls: Option<AmountAndCurrencyExchange32>,
3569    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
3570    pub avlbty: Option<Vec<CashAvailability1>>,
3571    #[serde(rename = "BkTxCd", skip_serializing_if = "Option::is_none")]
3572    pub bk_tx_cd: Option<BankTransactionCodeStructure41>,
3573    #[serde(rename = "Chrgs", skip_serializing_if = "Option::is_none")]
3574    pub chrgs: Option<Charges61>,
3575    #[serde(rename = "Intrst", skip_serializing_if = "Option::is_none")]
3576    pub intrst: Option<TransactionInterest41>,
3577    #[serde(rename = "RltdPties", skip_serializing_if = "Option::is_none")]
3578    pub rltd_pties: Option<TransactionParties61>,
3579    #[serde(rename = "RltdAgts", skip_serializing_if = "Option::is_none")]
3580    pub rltd_agts: Option<TransactionAgents51>,
3581    #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
3582    pub lcl_instrm: Option<LocalInstrument2Choice1>,
3583    #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
3584    pub purp: Option<Purpose2Choice1>,
3585    #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
3586    pub rltd_rmt_inf: Option<Vec<RemittanceLocation71>>,
3587    #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
3588    pub rmt_inf: Option<RemittanceInformation161>,
3589    #[serde(rename = "RltdDts", skip_serializing_if = "Option::is_none")]
3590    pub rltd_dts: Option<TransactionDates31>,
3591    #[serde(rename = "RltdPric", skip_serializing_if = "Option::is_none")]
3592    pub rltd_pric: Option<TransactionPrice4Choice1>,
3593    #[serde(rename = "RltdQties", skip_serializing_if = "Option::is_none")]
3594    pub rltd_qties: Option<Vec<TransactionQuantities3Choice1>>,
3595    #[serde(rename = "FinInstrmId", skip_serializing_if = "Option::is_none")]
3596    pub fin_instrm_id: Option<SecurityIdentification191>,
3597    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
3598    pub tax: Option<TaxInformation81>,
3599    #[serde(rename = "RtrInf", skip_serializing_if = "Option::is_none")]
3600    pub rtr_inf: Option<PaymentReturnReason51>,
3601    #[serde(rename = "CorpActn", skip_serializing_if = "Option::is_none")]
3602    pub corp_actn: Option<CorporateAction91>,
3603    #[serde(rename = "SfkpgAcct", skip_serializing_if = "Option::is_none")]
3604    pub sfkpg_acct: Option<SecuritiesAccount191>,
3605    #[serde(rename = "CshDpst", skip_serializing_if = "Option::is_none")]
3606    pub csh_dpst: Option<Vec<CashDeposit1>>,
3607    #[serde(rename = "CardTx", skip_serializing_if = "Option::is_none")]
3608    pub card_tx: Option<CardTransaction171>,
3609    #[serde(rename = "AddtlTxInf", skip_serializing_if = "Option::is_none")]
3610    pub addtl_tx_inf: Option<String>,
3611}
3612
3613impl EntryTransaction101 {
3614    pub fn validate(&self) -> Result<(), ValidationError> {
3615        self.refs.validate()?;
3616        self.amt.validate()?;
3617        self.cdt_dbt_ind.validate()?;
3618        if let Some(ref val) = self.amt_dtls {
3619            val.validate()?
3620        }
3621        if let Some(ref vec) = self.avlbty {
3622            for item in vec {
3623                item.validate()?
3624            }
3625        }
3626        if let Some(ref val) = self.bk_tx_cd {
3627            val.validate()?
3628        }
3629        if let Some(ref val) = self.chrgs {
3630            val.validate()?
3631        }
3632        if let Some(ref val) = self.intrst {
3633            val.validate()?
3634        }
3635        if let Some(ref val) = self.rltd_pties {
3636            val.validate()?
3637        }
3638        if let Some(ref val) = self.rltd_agts {
3639            val.validate()?
3640        }
3641        if let Some(ref val) = self.lcl_instrm {
3642            val.validate()?
3643        }
3644        if let Some(ref val) = self.purp {
3645            val.validate()?
3646        }
3647        if let Some(ref vec) = self.rltd_rmt_inf {
3648            for item in vec {
3649                item.validate()?
3650            }
3651        }
3652        if let Some(ref val) = self.rmt_inf {
3653            val.validate()?
3654        }
3655        if let Some(ref val) = self.rltd_dts {
3656            val.validate()?
3657        }
3658        if let Some(ref val) = self.rltd_pric {
3659            val.validate()?
3660        }
3661        if let Some(ref vec) = self.rltd_qties {
3662            for item in vec {
3663                item.validate()?
3664            }
3665        }
3666        if let Some(ref val) = self.fin_instrm_id {
3667            val.validate()?
3668        }
3669        if let Some(ref val) = self.tax {
3670            val.validate()?
3671        }
3672        if let Some(ref val) = self.rtr_inf {
3673            val.validate()?
3674        }
3675        if let Some(ref val) = self.corp_actn {
3676            val.validate()?
3677        }
3678        if let Some(ref val) = self.sfkpg_acct {
3679            val.validate()?
3680        }
3681        if let Some(ref vec) = self.csh_dpst {
3682            for item in vec {
3683                item.validate()?
3684            }
3685        }
3686        if let Some(ref val) = self.card_tx {
3687            val.validate()?
3688        }
3689        if let Some(ref val) = self.addtl_tx_inf {
3690            if val.chars().count() < 1 {
3691                return Err(ValidationError::new(
3692                    1001,
3693                    "addtl_tx_inf is shorter than the minimum length of 1".to_string(),
3694                ));
3695            }
3696            if val.chars().count() > 500 {
3697                return Err(ValidationError::new(
3698                    1002,
3699                    "addtl_tx_inf exceeds the maximum length of 500".to_string(),
3700                ));
3701            }
3702            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3703            if !pattern.is_match(val) {
3704                return Err(ValidationError::new(
3705                    1005,
3706                    "addtl_tx_inf does not match the required pattern".to_string(),
3707                ));
3708            }
3709        }
3710        Ok(())
3711    }
3712}
3713
3714// ExternalEntryStatus1Code_fixed: BOOK
3715#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3716pub enum ExternalEntryStatus1Codefixed {
3717    #[default]
3718    #[serde(rename = "BOOK")]
3719    CodeBOOK,
3720}
3721
3722impl ExternalEntryStatus1Codefixed {
3723    pub fn validate(&self) -> Result<(), ValidationError> {
3724        Ok(())
3725    }
3726}
3727
3728// FinancialIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
3729#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3730pub struct FinancialIdentificationSchemeName1Choice1 {
3731    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3732    pub cd: Option<String>,
3733    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3734    pub prtry: Option<String>,
3735}
3736
3737impl FinancialIdentificationSchemeName1Choice1 {
3738    pub fn validate(&self) -> Result<(), ValidationError> {
3739        if let Some(ref val) = self.cd {
3740            if val.chars().count() < 1 {
3741                return Err(ValidationError::new(
3742                    1001,
3743                    "cd is shorter than the minimum length of 1".to_string(),
3744                ));
3745            }
3746            if val.chars().count() > 4 {
3747                return Err(ValidationError::new(
3748                    1002,
3749                    "cd exceeds the maximum length of 4".to_string(),
3750                ));
3751            }
3752        }
3753        if let Some(ref val) = self.prtry {
3754            if val.chars().count() < 1 {
3755                return Err(ValidationError::new(
3756                    1001,
3757                    "prtry is shorter than the minimum length of 1".to_string(),
3758                ));
3759            }
3760            if val.chars().count() > 35 {
3761                return Err(ValidationError::new(
3762                    1002,
3763                    "prtry exceeds the maximum length of 35".to_string(),
3764                ));
3765            }
3766            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3767            if !pattern.is_match(val) {
3768                return Err(ValidationError::new(
3769                    1005,
3770                    "prtry does not match the required pattern".to_string(),
3771                ));
3772            }
3773        }
3774        Ok(())
3775    }
3776}
3777
3778// FinancialInstitutionIdentification181: Unique identification of an agent, as assigned by an institution, using an identification scheme.
3779#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3780pub struct FinancialInstitutionIdentification181 {
3781    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
3782    pub bicfi: Option<String>,
3783    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
3784    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
3785    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
3786    pub lei: Option<String>,
3787    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3788    pub nm: Option<String>,
3789    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3790    pub pstl_adr: Option<PostalAddress242>,
3791    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3792    pub othr: Option<GenericFinancialIdentification11>,
3793}
3794
3795impl FinancialInstitutionIdentification181 {
3796    pub fn validate(&self) -> Result<(), ValidationError> {
3797        if let Some(ref val) = self.bicfi {
3798            let pattern =
3799                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
3800            if !pattern.is_match(val) {
3801                return Err(ValidationError::new(
3802                    1005,
3803                    "bicfi does not match the required pattern".to_string(),
3804                ));
3805            }
3806        }
3807        if let Some(ref val) = self.clr_sys_mmb_id {
3808            val.validate()?
3809        }
3810        if let Some(ref val) = self.lei {
3811            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
3812            if !pattern.is_match(val) {
3813                return Err(ValidationError::new(
3814                    1005,
3815                    "lei does not match the required pattern".to_string(),
3816                ));
3817            }
3818        }
3819        if let Some(ref val) = self.nm {
3820            if val.chars().count() < 1 {
3821                return Err(ValidationError::new(
3822                    1001,
3823                    "nm is shorter than the minimum length of 1".to_string(),
3824                ));
3825            }
3826            if val.chars().count() > 140 {
3827                return Err(ValidationError::new(
3828                    1002,
3829                    "nm exceeds the maximum length of 140".to_string(),
3830                ));
3831            }
3832            let pattern = Regex::new(
3833                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3834            )
3835            .unwrap();
3836            if !pattern.is_match(val) {
3837                return Err(ValidationError::new(
3838                    1005,
3839                    "nm does not match the required pattern".to_string(),
3840                ));
3841            }
3842        }
3843        if let Some(ref val) = self.pstl_adr {
3844            val.validate()?
3845        }
3846        if let Some(ref val) = self.othr {
3847            val.validate()?
3848        }
3849        Ok(())
3850    }
3851}
3852
3853// FinancialInstrumentQuantity1Choice: Quantity expressed as an amount representing the current amortised face amount of a bond, for example, a periodic reduction/increase of a bond's principal amount.
3854#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3855pub struct FinancialInstrumentQuantity1Choice {
3856    #[serde(rename = "Unit", skip_serializing_if = "Option::is_none")]
3857    pub unit: Option<f64>,
3858    #[serde(rename = "FaceAmt", skip_serializing_if = "Option::is_none")]
3859    pub face_amt: Option<f64>,
3860    #[serde(rename = "AmtsdVal", skip_serializing_if = "Option::is_none")]
3861    pub amtsd_val: Option<f64>,
3862}
3863
3864impl FinancialInstrumentQuantity1Choice {
3865    pub fn validate(&self) -> Result<(), ValidationError> {
3866        if let Some(ref val) = self.face_amt {
3867            if *val < 0.000000 {
3868                return Err(ValidationError::new(
3869                    1003,
3870                    "face_amt is less than the minimum value of 0.000000".to_string(),
3871                ));
3872            }
3873        }
3874        if let Some(ref val) = self.amtsd_val {
3875            if *val < 0.000000 {
3876                return Err(ValidationError::new(
3877                    1003,
3878                    "amtsd_val is less than the minimum value of 0.000000".to_string(),
3879                ));
3880            }
3881        }
3882        Ok(())
3883    }
3884}
3885
3886// FromToAmountRange1: Upper boundary of a range of amount values.
3887#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3888pub struct FromToAmountRange1 {
3889    #[serde(rename = "FrAmt")]
3890    pub fr_amt: AmountRangeBoundary1,
3891    #[serde(rename = "ToAmt")]
3892    pub to_amt: AmountRangeBoundary1,
3893}
3894
3895impl FromToAmountRange1 {
3896    pub fn validate(&self) -> Result<(), ValidationError> {
3897        self.fr_amt.validate()?;
3898        self.to_amt.validate()?;
3899        Ok(())
3900    }
3901}
3902
3903// Garnishment31: Indicates if the employment of the person to whom the garnishment applies (that is, the ultimate debtor) has been terminated.
3904#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3905pub struct Garnishment31 {
3906    #[serde(rename = "Tp")]
3907    pub tp: GarnishmentType11,
3908    #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
3909    pub grnshee: Option<PartyIdentification1353>,
3910    #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
3911    pub grnshmt_admstr: Option<PartyIdentification1353>,
3912    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3913    pub ref_nb: Option<String>,
3914    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3915    pub dt: Option<String>,
3916    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3917    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3918    #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
3919    pub fmly_mdcl_insrnc_ind: Option<bool>,
3920    #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
3921    pub mplyee_termntn_ind: Option<bool>,
3922}
3923
3924impl Garnishment31 {
3925    pub fn validate(&self) -> Result<(), ValidationError> {
3926        self.tp.validate()?;
3927        if let Some(ref val) = self.grnshee {
3928            val.validate()?
3929        }
3930        if let Some(ref val) = self.grnshmt_admstr {
3931            val.validate()?
3932        }
3933        if let Some(ref val) = self.ref_nb {
3934            if val.chars().count() < 1 {
3935                return Err(ValidationError::new(
3936                    1001,
3937                    "ref_nb is shorter than the minimum length of 1".to_string(),
3938                ));
3939            }
3940            if val.chars().count() > 140 {
3941                return Err(ValidationError::new(
3942                    1002,
3943                    "ref_nb exceeds the maximum length of 140".to_string(),
3944                ));
3945            }
3946            let pattern = Regex::new(
3947                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3948            )
3949            .unwrap();
3950            if !pattern.is_match(val) {
3951                return Err(ValidationError::new(
3952                    1005,
3953                    "ref_nb does not match the required pattern".to_string(),
3954                ));
3955            }
3956        }
3957        if let Some(ref val) = self.rmtd_amt {
3958            val.validate()?
3959        }
3960        Ok(())
3961    }
3962}
3963
3964// GarnishmentType1Choice1: Proprietary identification of the type of garnishment.
3965#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3966pub struct GarnishmentType1Choice1 {
3967    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3968    pub cd: Option<String>,
3969    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3970    pub prtry: Option<String>,
3971}
3972
3973impl GarnishmentType1Choice1 {
3974    pub fn validate(&self) -> Result<(), ValidationError> {
3975        if let Some(ref val) = self.cd {
3976            if val.chars().count() < 1 {
3977                return Err(ValidationError::new(
3978                    1001,
3979                    "cd is shorter than the minimum length of 1".to_string(),
3980                ));
3981            }
3982            if val.chars().count() > 4 {
3983                return Err(ValidationError::new(
3984                    1002,
3985                    "cd exceeds the maximum length of 4".to_string(),
3986                ));
3987            }
3988        }
3989        if let Some(ref val) = self.prtry {
3990            if val.chars().count() < 1 {
3991                return Err(ValidationError::new(
3992                    1001,
3993                    "prtry is shorter than the minimum length of 1".to_string(),
3994                ));
3995            }
3996            if val.chars().count() > 35 {
3997                return Err(ValidationError::new(
3998                    1002,
3999                    "prtry exceeds the maximum length of 35".to_string(),
4000                ));
4001            }
4002            let pattern = Regex::new(
4003                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4004            )
4005            .unwrap();
4006            if !pattern.is_match(val) {
4007                return Err(ValidationError::new(
4008                    1005,
4009                    "prtry does not match the required pattern".to_string(),
4010                ));
4011            }
4012        }
4013        Ok(())
4014    }
4015}
4016
4017// GarnishmentType11: Identification of the issuer of the garnishment type.
4018#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4019pub struct GarnishmentType11 {
4020    #[serde(rename = "CdOrPrtry")]
4021    pub cd_or_prtry: GarnishmentType1Choice1,
4022    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4023    pub issr: Option<String>,
4024}
4025
4026impl GarnishmentType11 {
4027    pub fn validate(&self) -> Result<(), ValidationError> {
4028        self.cd_or_prtry.validate()?;
4029        if let Some(ref val) = self.issr {
4030            if val.chars().count() < 1 {
4031                return Err(ValidationError::new(
4032                    1001,
4033                    "issr 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                    "issr exceeds the maximum length of 35".to_string(),
4040                ));
4041            }
4042            let pattern = Regex::new(
4043                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4044            )
4045            .unwrap();
4046            if !pattern.is_match(val) {
4047                return Err(ValidationError::new(
4048                    1005,
4049                    "issr does not match the required pattern".to_string(),
4050                ));
4051            }
4052        }
4053        Ok(())
4054    }
4055}
4056
4057// GenericAccountIdentification11: Entity that assigns the identification.
4058#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4059pub struct GenericAccountIdentification11 {
4060    #[serde(rename = "Id")]
4061    pub id: String,
4062    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4063    pub schme_nm: Option<AccountSchemeName1Choice1>,
4064    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4065    pub issr: Option<String>,
4066}
4067
4068impl GenericAccountIdentification11 {
4069    pub fn validate(&self) -> Result<(), ValidationError> {
4070        if self.id.chars().count() < 1 {
4071            return Err(ValidationError::new(
4072                1001,
4073                "id is shorter than the minimum length of 1".to_string(),
4074            ));
4075        }
4076        if self.id.chars().count() > 34 {
4077            return Err(ValidationError::new(
4078                1002,
4079                "id exceeds the maximum length of 34".to_string(),
4080            ));
4081        }
4082        let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
4083        if !pattern.is_match(&self.id) {
4084            return Err(ValidationError::new(
4085                1005,
4086                "id does not match the required pattern".to_string(),
4087            ));
4088        }
4089        if let Some(ref val) = self.schme_nm {
4090            val.validate()?
4091        }
4092        if let Some(ref val) = self.issr {
4093            if val.chars().count() < 1 {
4094                return Err(ValidationError::new(
4095                    1001,
4096                    "issr is shorter than the minimum length of 1".to_string(),
4097                ));
4098            }
4099            if val.chars().count() > 35 {
4100                return Err(ValidationError::new(
4101                    1002,
4102                    "issr exceeds the maximum length of 35".to_string(),
4103                ));
4104            }
4105            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4106            if !pattern.is_match(val) {
4107                return Err(ValidationError::new(
4108                    1005,
4109                    "issr does not match the required pattern".to_string(),
4110                ));
4111            }
4112        }
4113        Ok(())
4114    }
4115}
4116
4117// GenericFinancialIdentification11: Entity that assigns the identification.
4118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4119pub struct GenericFinancialIdentification11 {
4120    #[serde(rename = "Id")]
4121    pub id: String,
4122    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4123    pub schme_nm: Option<FinancialIdentificationSchemeName1Choice1>,
4124    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4125    pub issr: Option<String>,
4126}
4127
4128impl GenericFinancialIdentification11 {
4129    pub fn validate(&self) -> Result<(), ValidationError> {
4130        if self.id.chars().count() < 1 {
4131            return Err(ValidationError::new(
4132                1001,
4133                "id is shorter than the minimum length of 1".to_string(),
4134            ));
4135        }
4136        if self.id.chars().count() > 35 {
4137            return Err(ValidationError::new(
4138                1002,
4139                "id exceeds the maximum length of 35".to_string(),
4140            ));
4141        }
4142        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4143        if !pattern.is_match(&self.id) {
4144            return Err(ValidationError::new(
4145                1005,
4146                "id does not match the required pattern".to_string(),
4147            ));
4148        }
4149        if let Some(ref val) = self.schme_nm {
4150            val.validate()?
4151        }
4152        if let Some(ref val) = self.issr {
4153            if val.chars().count() < 1 {
4154                return Err(ValidationError::new(
4155                    1001,
4156                    "issr is shorter than the minimum length of 1".to_string(),
4157                ));
4158            }
4159            if val.chars().count() > 35 {
4160                return Err(ValidationError::new(
4161                    1002,
4162                    "issr exceeds the maximum length of 35".to_string(),
4163                ));
4164            }
4165            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4166            if !pattern.is_match(val) {
4167                return Err(ValidationError::new(
4168                    1005,
4169                    "issr does not match the required pattern".to_string(),
4170                ));
4171            }
4172        }
4173        Ok(())
4174    }
4175}
4176
4177// GenericIdentification11: Entity that assigns the identification.
4178#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4179pub struct GenericIdentification11 {
4180    #[serde(rename = "Id")]
4181    pub id: String,
4182    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4183    pub schme_nm: Option<String>,
4184    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4185    pub issr: Option<String>,
4186}
4187
4188impl GenericIdentification11 {
4189    pub fn validate(&self) -> Result<(), ValidationError> {
4190        if self.id.chars().count() < 1 {
4191            return Err(ValidationError::new(
4192                1001,
4193                "id is shorter than the minimum length of 1".to_string(),
4194            ));
4195        }
4196        if self.id.chars().count() > 35 {
4197            return Err(ValidationError::new(
4198                1002,
4199                "id exceeds the maximum length of 35".to_string(),
4200            ));
4201        }
4202        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4203        if !pattern.is_match(&self.id) {
4204            return Err(ValidationError::new(
4205                1005,
4206                "id does not match the required pattern".to_string(),
4207            ));
4208        }
4209        if let Some(ref val) = self.schme_nm {
4210            if val.chars().count() < 1 {
4211                return Err(ValidationError::new(
4212                    1001,
4213                    "schme_nm 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                    "schme_nm exceeds the maximum length of 35".to_string(),
4220                ));
4221            }
4222            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4223            if !pattern.is_match(val) {
4224                return Err(ValidationError::new(
4225                    1005,
4226                    "schme_nm does not match the required pattern".to_string(),
4227                ));
4228            }
4229        }
4230        if let Some(ref val) = self.issr {
4231            if val.chars().count() < 1 {
4232                return Err(ValidationError::new(
4233                    1001,
4234                    "issr is shorter than the minimum length of 1".to_string(),
4235                ));
4236            }
4237            if val.chars().count() > 35 {
4238                return Err(ValidationError::new(
4239                    1002,
4240                    "issr exceeds the maximum length of 35".to_string(),
4241                ));
4242            }
4243            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4244            if !pattern.is_match(val) {
4245                return Err(ValidationError::new(
4246                    1005,
4247                    "issr does not match the required pattern".to_string(),
4248                ));
4249            }
4250        }
4251        Ok(())
4252    }
4253}
4254
4255// GenericIdentification301: Short textual description of the scheme.
4256#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4257pub struct GenericIdentification301 {
4258    #[serde(rename = "Id")]
4259    pub id: String,
4260    #[serde(rename = "Issr")]
4261    pub issr: String,
4262    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4263    pub schme_nm: Option<String>,
4264}
4265
4266impl GenericIdentification301 {
4267    pub fn validate(&self) -> Result<(), ValidationError> {
4268        let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
4269        if !pattern.is_match(&self.id) {
4270            return Err(ValidationError::new(
4271                1005,
4272                "id does not match the required pattern".to_string(),
4273            ));
4274        }
4275        if self.issr.chars().count() < 1 {
4276            return Err(ValidationError::new(
4277                1001,
4278                "issr is shorter than the minimum length of 1".to_string(),
4279            ));
4280        }
4281        if self.issr.chars().count() > 35 {
4282            return Err(ValidationError::new(
4283                1002,
4284                "issr exceeds the maximum length of 35".to_string(),
4285            ));
4286        }
4287        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4288        if !pattern.is_match(&self.issr) {
4289            return Err(ValidationError::new(
4290                1005,
4291                "issr does not match the required pattern".to_string(),
4292            ));
4293        }
4294        if let Some(ref val) = self.schme_nm {
4295            if val.chars().count() < 1 {
4296                return Err(ValidationError::new(
4297                    1001,
4298                    "schme_nm is shorter than the minimum length of 1".to_string(),
4299                ));
4300            }
4301            if val.chars().count() > 35 {
4302                return Err(ValidationError::new(
4303                    1002,
4304                    "schme_nm exceeds the maximum length of 35".to_string(),
4305                ));
4306            }
4307            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4308            if !pattern.is_match(val) {
4309                return Err(ValidationError::new(
4310                    1005,
4311                    "schme_nm does not match the required pattern".to_string(),
4312                ));
4313            }
4314        }
4315        Ok(())
4316    }
4317}
4318
4319// GenericIdentification302: Short textual description of the scheme.
4320#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4321pub struct GenericIdentification302 {
4322    #[serde(rename = "Id")]
4323    pub id: String,
4324    #[serde(rename = "Issr")]
4325    pub issr: String,
4326    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4327    pub schme_nm: Option<String>,
4328}
4329
4330impl GenericIdentification302 {
4331    pub fn validate(&self) -> Result<(), ValidationError> {
4332        let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
4333        if !pattern.is_match(&self.id) {
4334            return Err(ValidationError::new(
4335                1005,
4336                "id does not match the required pattern".to_string(),
4337            ));
4338        }
4339        if self.issr.chars().count() < 1 {
4340            return Err(ValidationError::new(
4341                1001,
4342                "issr is shorter than the minimum length of 1".to_string(),
4343            ));
4344        }
4345        if self.issr.chars().count() > 35 {
4346            return Err(ValidationError::new(
4347                1002,
4348                "issr exceeds the maximum length of 35".to_string(),
4349            ));
4350        }
4351        let pattern =
4352            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
4353                .unwrap();
4354        if !pattern.is_match(&self.issr) {
4355            return Err(ValidationError::new(
4356                1005,
4357                "issr does not match the required pattern".to_string(),
4358            ));
4359        }
4360        if let Some(ref val) = self.schme_nm {
4361            if val.chars().count() < 1 {
4362                return Err(ValidationError::new(
4363                    1001,
4364                    "schme_nm is shorter than the minimum length of 1".to_string(),
4365                ));
4366            }
4367            if val.chars().count() > 35 {
4368                return Err(ValidationError::new(
4369                    1002,
4370                    "schme_nm exceeds the maximum length of 35".to_string(),
4371                ));
4372            }
4373            let pattern = Regex::new(
4374                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4375            )
4376            .unwrap();
4377            if !pattern.is_match(val) {
4378                return Err(ValidationError::new(
4379                    1005,
4380                    "schme_nm does not match the required pattern".to_string(),
4381                ));
4382            }
4383        }
4384        Ok(())
4385    }
4386}
4387
4388// GenericIdentification321: Name of the entity.
4389#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4390pub struct GenericIdentification321 {
4391    #[serde(rename = "Id")]
4392    pub id: String,
4393    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4394    pub tp: Option<PartyType3Code>,
4395    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4396    pub issr: Option<PartyType4Code>,
4397    #[serde(rename = "ShrtNm", skip_serializing_if = "Option::is_none")]
4398    pub shrt_nm: Option<String>,
4399}
4400
4401impl GenericIdentification321 {
4402    pub fn validate(&self) -> Result<(), ValidationError> {
4403        if self.id.chars().count() < 1 {
4404            return Err(ValidationError::new(
4405                1001,
4406                "id is shorter than the minimum length of 1".to_string(),
4407            ));
4408        }
4409        if self.id.chars().count() > 35 {
4410            return Err(ValidationError::new(
4411                1002,
4412                "id exceeds the maximum length of 35".to_string(),
4413            ));
4414        }
4415        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4416        if !pattern.is_match(&self.id) {
4417            return Err(ValidationError::new(
4418                1005,
4419                "id does not match the required pattern".to_string(),
4420            ));
4421        }
4422        if let Some(ref val) = self.tp {
4423            val.validate()?
4424        }
4425        if let Some(ref val) = self.issr {
4426            val.validate()?
4427        }
4428        if let Some(ref val) = self.shrt_nm {
4429            if val.chars().count() < 1 {
4430                return Err(ValidationError::new(
4431                    1001,
4432                    "shrt_nm is shorter than the minimum length of 1".to_string(),
4433                ));
4434            }
4435            if val.chars().count() > 35 {
4436                return Err(ValidationError::new(
4437                    1002,
4438                    "shrt_nm exceeds the maximum length of 35".to_string(),
4439                ));
4440            }
4441            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4442            if !pattern.is_match(val) {
4443                return Err(ValidationError::new(
4444                    1005,
4445                    "shrt_nm does not match the required pattern".to_string(),
4446                ));
4447            }
4448        }
4449        Ok(())
4450    }
4451}
4452
4453// GenericIdentification31: Entity that assigns the identification.
4454#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4455pub struct GenericIdentification31 {
4456    #[serde(rename = "Id")]
4457    pub id: String,
4458    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4459    pub issr: Option<String>,
4460}
4461
4462impl GenericIdentification31 {
4463    pub fn validate(&self) -> Result<(), ValidationError> {
4464        if self.id.chars().count() < 1 {
4465            return Err(ValidationError::new(
4466                1001,
4467                "id is shorter than the minimum length of 1".to_string(),
4468            ));
4469        }
4470        if self.id.chars().count() > 35 {
4471            return Err(ValidationError::new(
4472                1002,
4473                "id exceeds the maximum length of 35".to_string(),
4474            ));
4475        }
4476        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4477        if !pattern.is_match(&self.id) {
4478            return Err(ValidationError::new(
4479                1005,
4480                "id does not match the required pattern".to_string(),
4481            ));
4482        }
4483        if let Some(ref val) = self.issr {
4484            if val.chars().count() < 1 {
4485                return Err(ValidationError::new(
4486                    1001,
4487                    "issr is shorter than the minimum length of 1".to_string(),
4488                ));
4489            }
4490            if val.chars().count() > 35 {
4491                return Err(ValidationError::new(
4492                    1002,
4493                    "issr exceeds the maximum length of 35".to_string(),
4494                ));
4495            }
4496            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4497            if !pattern.is_match(val) {
4498                return Err(ValidationError::new(
4499                    1005,
4500                    "issr does not match the required pattern".to_string(),
4501                ));
4502            }
4503        }
4504        Ok(())
4505    }
4506}
4507
4508// GenericOrganisationIdentification11: Entity that assigns the identification.
4509#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4510pub struct GenericOrganisationIdentification11 {
4511    #[serde(rename = "Id")]
4512    pub id: String,
4513    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4514    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
4515    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4516    pub issr: Option<String>,
4517}
4518
4519impl GenericOrganisationIdentification11 {
4520    pub fn validate(&self) -> Result<(), ValidationError> {
4521        if self.id.chars().count() < 1 {
4522            return Err(ValidationError::new(
4523                1001,
4524                "id is shorter than the minimum length of 1".to_string(),
4525            ));
4526        }
4527        if self.id.chars().count() > 35 {
4528            return Err(ValidationError::new(
4529                1002,
4530                "id exceeds the maximum length of 35".to_string(),
4531            ));
4532        }
4533        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4534        if !pattern.is_match(&self.id) {
4535            return Err(ValidationError::new(
4536                1005,
4537                "id does not match the required pattern".to_string(),
4538            ));
4539        }
4540        if let Some(ref val) = self.schme_nm {
4541            val.validate()?
4542        }
4543        if let Some(ref val) = self.issr {
4544            if val.chars().count() < 1 {
4545                return Err(ValidationError::new(
4546                    1001,
4547                    "issr is shorter than the minimum length of 1".to_string(),
4548                ));
4549            }
4550            if val.chars().count() > 35 {
4551                return Err(ValidationError::new(
4552                    1002,
4553                    "issr exceeds the maximum length of 35".to_string(),
4554                ));
4555            }
4556            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4557            if !pattern.is_match(val) {
4558                return Err(ValidationError::new(
4559                    1005,
4560                    "issr does not match the required pattern".to_string(),
4561                ));
4562            }
4563        }
4564        Ok(())
4565    }
4566}
4567
4568// GenericPersonIdentification11: Entity that assigns the identification.
4569#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4570pub struct GenericPersonIdentification11 {
4571    #[serde(rename = "Id")]
4572    pub id: String,
4573    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
4574    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
4575    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
4576    pub issr: Option<String>,
4577}
4578
4579impl GenericPersonIdentification11 {
4580    pub fn validate(&self) -> Result<(), ValidationError> {
4581        if self.id.chars().count() < 1 {
4582            return Err(ValidationError::new(
4583                1001,
4584                "id is shorter than the minimum length of 1".to_string(),
4585            ));
4586        }
4587        if self.id.chars().count() > 35 {
4588            return Err(ValidationError::new(
4589                1002,
4590                "id exceeds the maximum length of 35".to_string(),
4591            ));
4592        }
4593        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4594        if !pattern.is_match(&self.id) {
4595            return Err(ValidationError::new(
4596                1005,
4597                "id does not match the required pattern".to_string(),
4598            ));
4599        }
4600        if let Some(ref val) = self.schme_nm {
4601            val.validate()?
4602        }
4603        if let Some(ref val) = self.issr {
4604            if val.chars().count() < 1 {
4605                return Err(ValidationError::new(
4606                    1001,
4607                    "issr is shorter than the minimum length of 1".to_string(),
4608                ));
4609            }
4610            if val.chars().count() > 35 {
4611                return Err(ValidationError::new(
4612                    1002,
4613                    "issr exceeds the maximum length of 35".to_string(),
4614                ));
4615            }
4616            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4617            if !pattern.is_match(val) {
4618                return Err(ValidationError::new(
4619                    1005,
4620                    "issr does not match the required pattern".to_string(),
4621                ));
4622            }
4623        }
4624        Ok(())
4625    }
4626}
4627
4628// GroupHeader811: Further details of the message.
4629#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4630pub struct GroupHeader811 {
4631    #[serde(rename = "MsgId")]
4632    pub msg_id: String,
4633    #[serde(rename = "CreDtTm")]
4634    pub cre_dt_tm: String,
4635    #[serde(rename = "MsgRcpt", skip_serializing_if = "Option::is_none")]
4636    pub msg_rcpt: Option<PartyIdentification1351>,
4637    #[serde(rename = "OrgnlBizQry", skip_serializing_if = "Option::is_none")]
4638    pub orgnl_biz_qry: Option<OriginalBusinessQuery11>,
4639    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
4640    pub addtl_inf: Option<String>,
4641}
4642
4643impl GroupHeader811 {
4644    pub fn validate(&self) -> Result<(), ValidationError> {
4645        if self.msg_id.chars().count() < 1 {
4646            return Err(ValidationError::new(
4647                1001,
4648                "msg_id is shorter than the minimum length of 1".to_string(),
4649            ));
4650        }
4651        if self.msg_id.chars().count() > 35 {
4652            return Err(ValidationError::new(
4653                1002,
4654                "msg_id exceeds the maximum length of 35".to_string(),
4655            ));
4656        }
4657        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4658        if !pattern.is_match(&self.msg_id) {
4659            return Err(ValidationError::new(
4660                1005,
4661                "msg_id does not match the required pattern".to_string(),
4662            ));
4663        }
4664        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
4665        if !pattern.is_match(&self.cre_dt_tm) {
4666            return Err(ValidationError::new(
4667                1005,
4668                "cre_dt_tm does not match the required pattern".to_string(),
4669            ));
4670        }
4671        if let Some(ref val) = self.msg_rcpt {
4672            val.validate()?
4673        }
4674        if let Some(ref val) = self.orgnl_biz_qry {
4675            val.validate()?
4676        }
4677        if let Some(ref val) = self.addtl_inf {
4678            if val.chars().count() < 1 {
4679                return Err(ValidationError::new(
4680                    1001,
4681                    "addtl_inf is shorter than the minimum length of 1".to_string(),
4682                ));
4683            }
4684            if val.chars().count() > 500 {
4685                return Err(ValidationError::new(
4686                    1002,
4687                    "addtl_inf exceeds the maximum length of 500".to_string(),
4688                ));
4689            }
4690            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4691            if !pattern.is_match(val) {
4692                return Err(ValidationError::new(
4693                    1005,
4694                    "addtl_inf does not match the required pattern".to_string(),
4695                ));
4696            }
4697        }
4698        Ok(())
4699    }
4700}
4701
4702// IdentificationSource3Choice1: Unique and unambiguous identification source using a proprietary identification scheme.
4703#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4704pub struct IdentificationSource3Choice1 {
4705    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4706    pub cd: Option<String>,
4707    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4708    pub prtry: Option<String>,
4709}
4710
4711impl IdentificationSource3Choice1 {
4712    pub fn validate(&self) -> Result<(), ValidationError> {
4713        if let Some(ref val) = self.cd {
4714            if val.chars().count() < 1 {
4715                return Err(ValidationError::new(
4716                    1001,
4717                    "cd is shorter than the minimum length of 1".to_string(),
4718                ));
4719            }
4720            if val.chars().count() > 4 {
4721                return Err(ValidationError::new(
4722                    1002,
4723                    "cd exceeds the maximum length of 4".to_string(),
4724                ));
4725            }
4726        }
4727        if let Some(ref val) = self.prtry {
4728            if val.chars().count() < 1 {
4729                return Err(ValidationError::new(
4730                    1001,
4731                    "prtry is shorter than the minimum length of 1".to_string(),
4732                ));
4733            }
4734            if val.chars().count() > 35 {
4735                return Err(ValidationError::new(
4736                    1002,
4737                    "prtry exceeds the maximum length of 35".to_string(),
4738                ));
4739            }
4740            let pattern = Regex::new(
4741                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4742            )
4743            .unwrap();
4744            if !pattern.is_match(val) {
4745                return Err(ValidationError::new(
4746                    1005,
4747                    "prtry does not match the required pattern".to_string(),
4748                ));
4749            }
4750        }
4751        Ok(())
4752    }
4753}
4754
4755// ImpliedCurrencyAmountRange1Choice: Value that an amount must not match to be considered valid.
4756#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4757pub struct ImpliedCurrencyAmountRange1Choice {
4758    #[serde(rename = "FrAmt", skip_serializing_if = "Option::is_none")]
4759    pub fr_amt: Option<AmountRangeBoundary1>,
4760    #[serde(rename = "ToAmt", skip_serializing_if = "Option::is_none")]
4761    pub to_amt: Option<AmountRangeBoundary1>,
4762    #[serde(rename = "FrToAmt", skip_serializing_if = "Option::is_none")]
4763    pub fr_to_amt: Option<FromToAmountRange1>,
4764    #[serde(rename = "EQAmt", skip_serializing_if = "Option::is_none")]
4765    pub eq_amt: Option<f64>,
4766    #[serde(rename = "NEQAmt", skip_serializing_if = "Option::is_none")]
4767    pub neq_amt: Option<f64>,
4768}
4769
4770impl ImpliedCurrencyAmountRange1Choice {
4771    pub fn validate(&self) -> Result<(), ValidationError> {
4772        if let Some(ref val) = self.fr_amt {
4773            val.validate()?
4774        }
4775        if let Some(ref val) = self.to_amt {
4776            val.validate()?
4777        }
4778        if let Some(ref val) = self.fr_to_amt {
4779            val.validate()?
4780        }
4781        if let Some(ref val) = self.eq_amt {
4782            if *val < 0.000000 {
4783                return Err(ValidationError::new(
4784                    1003,
4785                    "eq_amt is less than the minimum value of 0.000000".to_string(),
4786                ));
4787            }
4788        }
4789        if let Some(ref val) = self.neq_amt {
4790            if *val < 0.000000 {
4791                return Err(ValidationError::new(
4792                    1003,
4793                    "neq_amt is less than the minimum value of 0.000000".to_string(),
4794                ));
4795            }
4796        }
4797        Ok(())
4798    }
4799}
4800
4801// InterestRecord21: Provides details on the tax applied to charges.
4802#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4803pub struct InterestRecord21 {
4804    #[serde(rename = "Amt")]
4805    pub amt: ActiveOrHistoricCurrencyAndAmount,
4806    #[serde(rename = "CdtDbtInd")]
4807    pub cdt_dbt_ind: CreditDebitCode,
4808    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4809    pub tp: Option<InterestType1Choice1>,
4810    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
4811    pub rate: Option<Rate41>,
4812    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
4813    pub fr_to_dt: Option<DateTimePeriod11>,
4814    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
4815    pub rsn: Option<String>,
4816    #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
4817    pub tax: Option<TaxCharges21>,
4818}
4819
4820impl InterestRecord21 {
4821    pub fn validate(&self) -> Result<(), ValidationError> {
4822        self.amt.validate()?;
4823        self.cdt_dbt_ind.validate()?;
4824        if let Some(ref val) = self.tp {
4825            val.validate()?
4826        }
4827        if let Some(ref val) = self.rate {
4828            val.validate()?
4829        }
4830        if let Some(ref val) = self.fr_to_dt {
4831            val.validate()?
4832        }
4833        if let Some(ref val) = self.rsn {
4834            if val.chars().count() < 1 {
4835                return Err(ValidationError::new(
4836                    1001,
4837                    "rsn is shorter than the minimum length of 1".to_string(),
4838                ));
4839            }
4840            if val.chars().count() > 35 {
4841                return Err(ValidationError::new(
4842                    1002,
4843                    "rsn exceeds the maximum length of 35".to_string(),
4844                ));
4845            }
4846            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4847            if !pattern.is_match(val) {
4848                return Err(ValidationError::new(
4849                    1005,
4850                    "rsn does not match the required pattern".to_string(),
4851                ));
4852            }
4853        }
4854        if let Some(ref val) = self.tax {
4855            val.validate()?
4856        }
4857        Ok(())
4858    }
4859}
4860
4861// InterestType1Choice1: Specifies the type of interest in uncoded form.
4862#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4863pub struct InterestType1Choice1 {
4864    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4865    pub cd: Option<InterestType1Code>,
4866    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4867    pub prtry: Option<String>,
4868}
4869
4870impl InterestType1Choice1 {
4871    pub fn validate(&self) -> Result<(), ValidationError> {
4872        if let Some(ref val) = self.cd {
4873            val.validate()?
4874        }
4875        if let Some(ref val) = self.prtry {
4876            if val.chars().count() < 1 {
4877                return Err(ValidationError::new(
4878                    1001,
4879                    "prtry is shorter than the minimum length of 1".to_string(),
4880                ));
4881            }
4882            if val.chars().count() > 35 {
4883                return Err(ValidationError::new(
4884                    1002,
4885                    "prtry exceeds the maximum length of 35".to_string(),
4886                ));
4887            }
4888            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4889            if !pattern.is_match(val) {
4890                return Err(ValidationError::new(
4891                    1005,
4892                    "prtry does not match the required pattern".to_string(),
4893                ));
4894            }
4895        }
4896        Ok(())
4897    }
4898}
4899
4900// InterestType1Code: Period of time between the end of a business day and the start of the next business day (usually the day after).
4901#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4902pub enum InterestType1Code {
4903    #[default]
4904    #[serde(rename = "INDY")]
4905    CodeINDY,
4906    #[serde(rename = "OVRN")]
4907    CodeOVRN,
4908}
4909
4910impl InterestType1Code {
4911    pub fn validate(&self) -> Result<(), ValidationError> {
4912        Ok(())
4913    }
4914}
4915
4916// LocalInstrument2Choice1: Specifies the local instrument, as a proprietary code.
4917#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4918pub struct LocalInstrument2Choice1 {
4919    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4920    pub cd: Option<String>,
4921    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4922    pub prtry: Option<String>,
4923}
4924
4925impl LocalInstrument2Choice1 {
4926    pub fn validate(&self) -> Result<(), ValidationError> {
4927        if let Some(ref val) = self.cd {
4928            if val.chars().count() < 1 {
4929                return Err(ValidationError::new(
4930                    1001,
4931                    "cd is shorter than the minimum length of 1".to_string(),
4932                ));
4933            }
4934            if val.chars().count() > 35 {
4935                return Err(ValidationError::new(
4936                    1002,
4937                    "cd exceeds the maximum length of 35".to_string(),
4938                ));
4939            }
4940        }
4941        if let Some(ref val) = self.prtry {
4942            if val.chars().count() < 1 {
4943                return Err(ValidationError::new(
4944                    1001,
4945                    "prtry is shorter than the minimum length of 1".to_string(),
4946                ));
4947            }
4948            if val.chars().count() > 35 {
4949                return Err(ValidationError::new(
4950                    1002,
4951                    "prtry exceeds the maximum length of 35".to_string(),
4952                ));
4953            }
4954            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4955            if !pattern.is_match(val) {
4956                return Err(ValidationError::new(
4957                    1005,
4958                    "prtry does not match the required pattern".to_string(),
4959                ));
4960            }
4961        }
4962        Ok(())
4963    }
4964}
4965
4966// MessageIdentification21: Specifies the identification of the message that will be used to provide additional details.
4967#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4968pub struct MessageIdentification21 {
4969    #[serde(rename = "MsgNmId", skip_serializing_if = "Option::is_none")]
4970    pub msg_nm_id: Option<String>,
4971    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
4972    pub msg_id: Option<String>,
4973}
4974
4975impl MessageIdentification21 {
4976    pub fn validate(&self) -> Result<(), ValidationError> {
4977        if let Some(ref val) = self.msg_nm_id {
4978            if val.chars().count() < 1 {
4979                return Err(ValidationError::new(
4980                    1001,
4981                    "msg_nm_id is shorter than the minimum length of 1".to_string(),
4982                ));
4983            }
4984            if val.chars().count() > 35 {
4985                return Err(ValidationError::new(
4986                    1002,
4987                    "msg_nm_id exceeds the maximum length of 35".to_string(),
4988                ));
4989            }
4990            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
4991            if !pattern.is_match(val) {
4992                return Err(ValidationError::new(
4993                    1005,
4994                    "msg_nm_id does not match the required pattern".to_string(),
4995                ));
4996            }
4997        }
4998        if let Some(ref val) = self.msg_id {
4999            if val.chars().count() < 1 {
5000                return Err(ValidationError::new(
5001                    1001,
5002                    "msg_id is shorter than the minimum length of 1".to_string(),
5003                ));
5004            }
5005            if val.chars().count() > 35 {
5006                return Err(ValidationError::new(
5007                    1002,
5008                    "msg_id exceeds the maximum length of 35".to_string(),
5009                ));
5010            }
5011            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5012            if !pattern.is_match(val) {
5013                return Err(ValidationError::new(
5014                    1005,
5015                    "msg_id does not match the required pattern".to_string(),
5016                ));
5017            }
5018        }
5019        Ok(())
5020    }
5021}
5022
5023// NameAndAddress161: Postal address of a party.
5024#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5025pub struct NameAndAddress161 {
5026    #[serde(rename = "Nm")]
5027    pub nm: String,
5028    #[serde(rename = "Adr")]
5029    pub adr: PostalAddress242,
5030}
5031
5032impl NameAndAddress161 {
5033    pub fn validate(&self) -> Result<(), ValidationError> {
5034        if self.nm.chars().count() < 1 {
5035            return Err(ValidationError::new(
5036                1001,
5037                "nm is shorter than the minimum length of 1".to_string(),
5038            ));
5039        }
5040        if self.nm.chars().count() > 140 {
5041            return Err(ValidationError::new(
5042                1002,
5043                "nm exceeds the maximum length of 140".to_string(),
5044            ));
5045        }
5046        let pattern =
5047            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
5048                .unwrap();
5049        if !pattern.is_match(&self.nm) {
5050            return Err(ValidationError::new(
5051                1005,
5052                "nm does not match the required pattern".to_string(),
5053            ));
5054        }
5055        self.adr.validate()?;
5056        Ok(())
5057    }
5058}
5059
5060// NumberAndSumOfTransactions1: Total of all individual entries included in the report.
5061#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5062pub struct NumberAndSumOfTransactions1 {
5063    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
5064    pub nb_of_ntries: Option<String>,
5065    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
5066    pub sum: Option<f64>,
5067}
5068
5069impl NumberAndSumOfTransactions1 {
5070    pub fn validate(&self) -> Result<(), ValidationError> {
5071        if let Some(ref val) = self.nb_of_ntries {
5072            let pattern = Regex::new("[0-9]{1,15}").unwrap();
5073            if !pattern.is_match(val) {
5074                return Err(ValidationError::new(
5075                    1005,
5076                    "nb_of_ntries does not match the required pattern".to_string(),
5077                ));
5078            }
5079        }
5080        Ok(())
5081    }
5082}
5083
5084// NumberAndSumOfTransactions4: Resulting debit or credit amount of the netted amounts for all debit and credit entries.
5085#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5086pub struct NumberAndSumOfTransactions4 {
5087    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
5088    pub nb_of_ntries: Option<String>,
5089    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
5090    pub sum: Option<f64>,
5091    #[serde(rename = "TtlNetNtry", skip_serializing_if = "Option::is_none")]
5092    pub ttl_net_ntry: Option<AmountAndDirection35>,
5093}
5094
5095impl NumberAndSumOfTransactions4 {
5096    pub fn validate(&self) -> Result<(), ValidationError> {
5097        if let Some(ref val) = self.nb_of_ntries {
5098            let pattern = Regex::new("[0-9]{1,15}").unwrap();
5099            if !pattern.is_match(val) {
5100                return Err(ValidationError::new(
5101                    1005,
5102                    "nb_of_ntries does not match the required pattern".to_string(),
5103                ));
5104            }
5105        }
5106        if let Some(ref val) = self.ttl_net_ntry {
5107            val.validate()?
5108        }
5109        Ok(())
5110    }
5111}
5112
5113// OnLineCapability1Code: Off-line capable with possible on-line requests to the acquirer.
5114#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5115pub enum OnLineCapability1Code {
5116    #[default]
5117    #[serde(rename = "OFLN")]
5118    CodeOFLN,
5119    #[serde(rename = "ONLN")]
5120    CodeONLN,
5121    #[serde(rename = "SMON")]
5122    CodeSMON,
5123}
5124
5125impl OnLineCapability1Code {
5126    pub fn validate(&self) -> Result<(), ValidationError> {
5127        Ok(())
5128    }
5129}
5130
5131// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
5132#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5133pub struct OrganisationIdentification291 {
5134    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
5135    pub any_bic: Option<String>,
5136    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
5137    pub lei: Option<String>,
5138    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
5139    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
5140}
5141
5142impl OrganisationIdentification291 {
5143    pub fn validate(&self) -> Result<(), ValidationError> {
5144        if let Some(ref val) = self.any_bic {
5145            let pattern =
5146                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
5147            if !pattern.is_match(val) {
5148                return Err(ValidationError::new(
5149                    1005,
5150                    "any_bic does not match the required pattern".to_string(),
5151                ));
5152            }
5153        }
5154        if let Some(ref val) = self.lei {
5155            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
5156            if !pattern.is_match(val) {
5157                return Err(ValidationError::new(
5158                    1005,
5159                    "lei does not match the required pattern".to_string(),
5160                ));
5161            }
5162        }
5163        if let Some(ref vec) = self.othr {
5164            for item in vec {
5165                item.validate()?
5166            }
5167        }
5168        Ok(())
5169    }
5170}
5171
5172// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
5173#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5174pub struct OrganisationIdentificationSchemeName1Choice1 {
5175    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
5176    pub cd: Option<String>,
5177    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
5178    pub prtry: Option<String>,
5179}
5180
5181impl OrganisationIdentificationSchemeName1Choice1 {
5182    pub fn validate(&self) -> Result<(), ValidationError> {
5183        if let Some(ref val) = self.cd {
5184            if val.chars().count() < 1 {
5185                return Err(ValidationError::new(
5186                    1001,
5187                    "cd is shorter than the minimum length of 1".to_string(),
5188                ));
5189            }
5190            if val.chars().count() > 4 {
5191                return Err(ValidationError::new(
5192                    1002,
5193                    "cd exceeds the maximum length of 4".to_string(),
5194                ));
5195            }
5196        }
5197        if let Some(ref val) = self.prtry {
5198            if val.chars().count() < 1 {
5199                return Err(ValidationError::new(
5200                    1001,
5201                    "prtry is shorter than the minimum length of 1".to_string(),
5202                ));
5203            }
5204            if val.chars().count() > 35 {
5205                return Err(ValidationError::new(
5206                    1002,
5207                    "prtry exceeds the maximum length of 35".to_string(),
5208                ));
5209            }
5210            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5211            if !pattern.is_match(val) {
5212                return Err(ValidationError::new(
5213                    1005,
5214                    "prtry does not match the required pattern".to_string(),
5215                ));
5216            }
5217        }
5218        Ok(())
5219    }
5220}
5221
5222// OriginalAndCurrentQuantities1: Quantity expressed as an amount representing the current amortised face amount of a bond, for example, a periodic reduction/increase of a bond's principal amount.
5223#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5224pub struct OriginalAndCurrentQuantities1 {
5225    #[serde(rename = "FaceAmt")]
5226    pub face_amt: f64,
5227    #[serde(rename = "AmtsdVal")]
5228    pub amtsd_val: f64,
5229}
5230
5231impl OriginalAndCurrentQuantities1 {
5232    pub fn validate(&self) -> Result<(), ValidationError> {
5233        Ok(())
5234    }
5235}
5236
5237// OriginalBusinessQuery11: Date and time at which the message was created.
5238#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5239pub struct OriginalBusinessQuery11 {
5240    #[serde(rename = "MsgId")]
5241    pub msg_id: String,
5242    #[serde(rename = "MsgNmId", skip_serializing_if = "Option::is_none")]
5243    pub msg_nm_id: Option<String>,
5244    #[serde(rename = "CreDtTm", skip_serializing_if = "Option::is_none")]
5245    pub cre_dt_tm: Option<String>,
5246}
5247
5248impl OriginalBusinessQuery11 {
5249    pub fn validate(&self) -> Result<(), ValidationError> {
5250        if self.msg_id.chars().count() < 1 {
5251            return Err(ValidationError::new(
5252                1001,
5253                "msg_id is shorter than the minimum length of 1".to_string(),
5254            ));
5255        }
5256        if self.msg_id.chars().count() > 35 {
5257            return Err(ValidationError::new(
5258                1002,
5259                "msg_id exceeds the maximum length of 35".to_string(),
5260            ));
5261        }
5262        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5263        if !pattern.is_match(&self.msg_id) {
5264            return Err(ValidationError::new(
5265                1005,
5266                "msg_id does not match the required pattern".to_string(),
5267            ));
5268        }
5269        if let Some(ref val) = self.msg_nm_id {
5270            if val.chars().count() < 1 {
5271                return Err(ValidationError::new(
5272                    1001,
5273                    "msg_nm_id is shorter than the minimum length of 1".to_string(),
5274                ));
5275            }
5276            if val.chars().count() > 35 {
5277                return Err(ValidationError::new(
5278                    1002,
5279                    "msg_nm_id exceeds the maximum length of 35".to_string(),
5280                ));
5281            }
5282            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5283            if !pattern.is_match(val) {
5284                return Err(ValidationError::new(
5285                    1005,
5286                    "msg_nm_id does not match the required pattern".to_string(),
5287                ));
5288            }
5289        }
5290        if let Some(ref val) = self.cre_dt_tm {
5291            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
5292            if !pattern.is_match(val) {
5293                return Err(ValidationError::new(
5294                    1005,
5295                    "cre_dt_tm does not match the required pattern".to_string(),
5296                ));
5297            }
5298        }
5299        Ok(())
5300    }
5301}
5302
5303// OtherIdentification11: Type of the identification.
5304#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5305pub struct OtherIdentification11 {
5306    #[serde(rename = "Id")]
5307    pub id: String,
5308    #[serde(rename = "Sfx", skip_serializing_if = "Option::is_none")]
5309    pub sfx: Option<String>,
5310    #[serde(rename = "Tp")]
5311    pub tp: IdentificationSource3Choice1,
5312}
5313
5314impl OtherIdentification11 {
5315    pub fn validate(&self) -> Result<(), ValidationError> {
5316        if self.id.chars().count() < 1 {
5317            return Err(ValidationError::new(
5318                1001,
5319                "id is shorter than the minimum length of 1".to_string(),
5320            ));
5321        }
5322        if self.id.chars().count() > 35 {
5323            return Err(ValidationError::new(
5324                1002,
5325                "id exceeds the maximum length of 35".to_string(),
5326            ));
5327        }
5328        let pattern =
5329            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
5330                .unwrap();
5331        if !pattern.is_match(&self.id) {
5332            return Err(ValidationError::new(
5333                1005,
5334                "id does not match the required pattern".to_string(),
5335            ));
5336        }
5337        if let Some(ref val) = self.sfx {
5338            if val.chars().count() < 1 {
5339                return Err(ValidationError::new(
5340                    1001,
5341                    "sfx is shorter than the minimum length of 1".to_string(),
5342                ));
5343            }
5344            if val.chars().count() > 16 {
5345                return Err(ValidationError::new(
5346                    1002,
5347                    "sfx exceeds the maximum length of 16".to_string(),
5348                ));
5349            }
5350            let pattern = Regex::new(
5351                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5352            )
5353            .unwrap();
5354            if !pattern.is_match(val) {
5355                return Err(ValidationError::new(
5356                    1005,
5357                    "sfx does not match the required pattern".to_string(),
5358                ));
5359            }
5360        }
5361        self.tp.validate()?;
5362        Ok(())
5363    }
5364}
5365
5366// POIComponentType1Code: Personal identification number (or PIN) entry device (PED).
5367#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5368pub enum POIComponentType1Code {
5369    #[default]
5370    #[serde(rename = "SOFT")]
5371    CodeSOFT,
5372    #[serde(rename = "EMVK")]
5373    CodeEMVK,
5374    #[serde(rename = "EMVO")]
5375    CodeEMVO,
5376    #[serde(rename = "MRIT")]
5377    CodeMRIT,
5378    #[serde(rename = "CHIT")]
5379    CodeCHIT,
5380    #[serde(rename = "SECM")]
5381    CodeSECM,
5382    #[serde(rename = "PEDV")]
5383    CodePEDV,
5384}
5385
5386impl POIComponentType1Code {
5387    pub fn validate(&self) -> Result<(), ValidationError> {
5388        Ok(())
5389    }
5390}
5391
5392// Pagination1: Indicates the last page.
5393#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5394pub struct Pagination1 {
5395    #[serde(rename = "PgNb")]
5396    pub pg_nb: String,
5397    #[serde(rename = "LastPgInd")]
5398    pub last_pg_ind: bool,
5399}
5400
5401impl Pagination1 {
5402    pub fn validate(&self) -> Result<(), ValidationError> {
5403        let pattern = Regex::new("[0-9]{1,5}").unwrap();
5404        if !pattern.is_match(&self.pg_nb) {
5405            return Err(ValidationError::new(
5406                1005,
5407                "pg_nb does not match the required pattern".to_string(),
5408            ));
5409        }
5410        Ok(())
5411    }
5412}
5413
5414// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
5415#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5416pub struct Party38Choice1 {
5417    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
5418    pub org_id: Option<OrganisationIdentification291>,
5419    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
5420    pub prvt_id: Option<PersonIdentification131>,
5421}
5422
5423impl Party38Choice1 {
5424    pub fn validate(&self) -> Result<(), ValidationError> {
5425        if let Some(ref val) = self.org_id {
5426            val.validate()?
5427        }
5428        if let Some(ref val) = self.prvt_id {
5429            val.validate()?
5430        }
5431        Ok(())
5432    }
5433}
5434
5435// Party40Choice1: Identification of a financial institution.
5436#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5437pub struct Party40Choice1 {
5438    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
5439    pub pty: Option<PartyIdentification1353>,
5440    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
5441    pub agt: Option<BranchAndFinancialInstitutionIdentification62>,
5442}
5443
5444impl Party40Choice1 {
5445    pub fn validate(&self) -> Result<(), ValidationError> {
5446        if let Some(ref val) = self.pty {
5447            val.validate()?
5448        }
5449        if let Some(ref val) = self.agt {
5450            val.validate()?
5451        }
5452        Ok(())
5453    }
5454}
5455
5456// Party40Choice2: Identification of a financial institution.
5457#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5458pub struct Party40Choice2 {
5459    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
5460    pub pty: Option<PartyIdentification1354>,
5461    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
5462    pub agt: Option<BranchAndFinancialInstitutionIdentification61>,
5463}
5464
5465impl Party40Choice2 {
5466    pub fn validate(&self) -> Result<(), ValidationError> {
5467        if let Some(ref val) = self.pty {
5468            val.validate()?
5469        }
5470        if let Some(ref val) = self.agt {
5471            val.validate()?
5472        }
5473        Ok(())
5474    }
5475}
5476
5477// Party40Choice3: Identification of a financial institution.
5478#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5479pub struct Party40Choice3 {
5480    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
5481    pub pty: Option<PartyIdentification1353>,
5482    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
5483    pub agt: Option<BranchAndFinancialInstitutionIdentification61>,
5484}
5485
5486impl Party40Choice3 {
5487    pub fn validate(&self) -> Result<(), ValidationError> {
5488        if let Some(ref val) = self.pty {
5489            val.validate()?
5490        }
5491        if let Some(ref val) = self.agt {
5492            val.validate()?
5493        }
5494        Ok(())
5495    }
5496}
5497
5498// PartyIdentification1351: Set of elements used to indicate how to contact the party.
5499#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5500pub struct PartyIdentification1351 {
5501    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
5502    pub nm: Option<String>,
5503    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
5504    pub pstl_adr: Option<PostalAddress241>,
5505    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
5506    pub id: Option<Party38Choice1>,
5507    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
5508    pub ctct_dtls: Option<Contact41>,
5509}
5510
5511impl PartyIdentification1351 {
5512    pub fn validate(&self) -> Result<(), ValidationError> {
5513        if let Some(ref val) = self.nm {
5514            if val.chars().count() < 1 {
5515                return Err(ValidationError::new(
5516                    1001,
5517                    "nm is shorter than the minimum length of 1".to_string(),
5518                ));
5519            }
5520            if val.chars().count() > 140 {
5521                return Err(ValidationError::new(
5522                    1002,
5523                    "nm exceeds the maximum length of 140".to_string(),
5524                ));
5525            }
5526            let pattern = Regex::new(
5527                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5528            )
5529            .unwrap();
5530            if !pattern.is_match(val) {
5531                return Err(ValidationError::new(
5532                    1005,
5533                    "nm does not match the required pattern".to_string(),
5534                ));
5535            }
5536        }
5537        if let Some(ref val) = self.pstl_adr {
5538            val.validate()?
5539        }
5540        if let Some(ref val) = self.id {
5541            val.validate()?
5542        }
5543        if let Some(ref val) = self.ctct_dtls {
5544            val.validate()?
5545        }
5546        Ok(())
5547    }
5548}
5549
5550// 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.
5551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5552pub struct PartyIdentification1352 {
5553    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
5554    pub nm: Option<String>,
5555    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
5556    pub pstl_adr: Option<PostalAddress242>,
5557    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
5558    pub id: Option<Party38Choice1>,
5559    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
5560    pub ctry_of_res: Option<String>,
5561}
5562
5563impl PartyIdentification1352 {
5564    pub fn validate(&self) -> Result<(), ValidationError> {
5565        if let Some(ref val) = self.nm {
5566            if val.chars().count() < 1 {
5567                return Err(ValidationError::new(
5568                    1001,
5569                    "nm is shorter than the minimum length of 1".to_string(),
5570                ));
5571            }
5572            if val.chars().count() > 140 {
5573                return Err(ValidationError::new(
5574                    1002,
5575                    "nm exceeds the maximum length of 140".to_string(),
5576                ));
5577            }
5578            let pattern = Regex::new(
5579                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5580            )
5581            .unwrap();
5582            if !pattern.is_match(val) {
5583                return Err(ValidationError::new(
5584                    1005,
5585                    "nm does not match the required pattern".to_string(),
5586                ));
5587            }
5588        }
5589        if let Some(ref val) = self.pstl_adr {
5590            val.validate()?
5591        }
5592        if let Some(ref val) = self.id {
5593            val.validate()?
5594        }
5595        if let Some(ref val) = self.ctry_of_res {
5596            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5597            if !pattern.is_match(val) {
5598                return Err(ValidationError::new(
5599                    1005,
5600                    "ctry_of_res does not match the required pattern".to_string(),
5601                ));
5602            }
5603        }
5604        Ok(())
5605    }
5606}
5607
5608// PartyIdentification1353: Set of elements used to indicate how to contact the party.
5609#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5610pub struct PartyIdentification1353 {
5611    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
5612    pub nm: Option<String>,
5613    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
5614    pub pstl_adr: Option<PostalAddress242>,
5615    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
5616    pub id: Option<Party38Choice1>,
5617    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
5618    pub ctry_of_res: Option<String>,
5619    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
5620    pub ctct_dtls: Option<Contact41>,
5621}
5622
5623impl PartyIdentification1353 {
5624    pub fn validate(&self) -> Result<(), ValidationError> {
5625        if let Some(ref val) = self.nm {
5626            if val.chars().count() < 1 {
5627                return Err(ValidationError::new(
5628                    1001,
5629                    "nm is shorter than the minimum length of 1".to_string(),
5630                ));
5631            }
5632            if val.chars().count() > 140 {
5633                return Err(ValidationError::new(
5634                    1002,
5635                    "nm exceeds the maximum length of 140".to_string(),
5636                ));
5637            }
5638            let pattern = Regex::new(
5639                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5640            )
5641            .unwrap();
5642            if !pattern.is_match(val) {
5643                return Err(ValidationError::new(
5644                    1005,
5645                    "nm does not match the required pattern".to_string(),
5646                ));
5647            }
5648        }
5649        if let Some(ref val) = self.pstl_adr {
5650            val.validate()?
5651        }
5652        if let Some(ref val) = self.id {
5653            val.validate()?
5654        }
5655        if let Some(ref val) = self.ctry_of_res {
5656            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5657            if !pattern.is_match(val) {
5658                return Err(ValidationError::new(
5659                    1005,
5660                    "ctry_of_res does not match the required pattern".to_string(),
5661                ));
5662            }
5663        }
5664        if let Some(ref val) = self.ctct_dtls {
5665            val.validate()?
5666        }
5667        Ok(())
5668    }
5669}
5670
5671// PartyIdentification1354: Set of elements used to indicate how to contact the party.
5672#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5673pub struct PartyIdentification1354 {
5674    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
5675    pub nm: Option<String>,
5676    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
5677    pub pstl_adr: Option<PostalAddress242>,
5678    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
5679    pub id: Option<Party38Choice1>,
5680    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
5681    pub ctry_of_res: Option<String>,
5682    #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
5683    pub ctct_dtls: Option<Contact42>,
5684}
5685
5686impl PartyIdentification1354 {
5687    pub fn validate(&self) -> Result<(), ValidationError> {
5688        if let Some(ref val) = self.nm {
5689            if val.chars().count() < 1 {
5690                return Err(ValidationError::new(
5691                    1001,
5692                    "nm is shorter than the minimum length of 1".to_string(),
5693                ));
5694            }
5695            if val.chars().count() > 140 {
5696                return Err(ValidationError::new(
5697                    1002,
5698                    "nm exceeds the maximum length of 140".to_string(),
5699                ));
5700            }
5701            let pattern = Regex::new(
5702                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5703            )
5704            .unwrap();
5705            if !pattern.is_match(val) {
5706                return Err(ValidationError::new(
5707                    1005,
5708                    "nm does not match the required pattern".to_string(),
5709                ));
5710            }
5711        }
5712        if let Some(ref val) = self.pstl_adr {
5713            val.validate()?
5714        }
5715        if let Some(ref val) = self.id {
5716            val.validate()?
5717        }
5718        if let Some(ref val) = self.ctry_of_res {
5719            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5720            if !pattern.is_match(val) {
5721                return Err(ValidationError::new(
5722                    1005,
5723                    "ctry_of_res does not match the required pattern".to_string(),
5724                ));
5725            }
5726        }
5727        if let Some(ref val) = self.ctct_dtls {
5728            val.validate()?
5729        }
5730        Ok(())
5731    }
5732}
5733
5734// PartyType3Code: Party to whom the card issuer delegates to authorise card payment transactions.
5735#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5736pub enum PartyType3Code {
5737    #[default]
5738    #[serde(rename = "OPOI")]
5739    CodeOPOI,
5740    #[serde(rename = "MERC")]
5741    CodeMERC,
5742    #[serde(rename = "ACCP")]
5743    CodeACCP,
5744    #[serde(rename = "ITAG")]
5745    CodeITAG,
5746    #[serde(rename = "ACQR")]
5747    CodeACQR,
5748    #[serde(rename = "CISS")]
5749    CodeCISS,
5750    #[serde(rename = "DLIS")]
5751    CodeDLIS,
5752}
5753
5754impl PartyType3Code {
5755    pub fn validate(&self) -> Result<(), ValidationError> {
5756        Ok(())
5757    }
5758}
5759
5760// PartyType4Code: Tax authority.
5761#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5762pub enum PartyType4Code {
5763    #[default]
5764    #[serde(rename = "MERC")]
5765    CodeMERC,
5766    #[serde(rename = "ACCP")]
5767    CodeACCP,
5768    #[serde(rename = "ITAG")]
5769    CodeITAG,
5770    #[serde(rename = "ACQR")]
5771    CodeACQR,
5772    #[serde(rename = "CISS")]
5773    CodeCISS,
5774    #[serde(rename = "TAXH")]
5775    CodeTAXH,
5776}
5777
5778impl PartyType4Code {
5779    pub fn validate(&self) -> Result<(), ValidationError> {
5780        Ok(())
5781    }
5782}
5783
5784// PaymentCard41: Additional card issuer specific data.
5785#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5786pub struct PaymentCard41 {
5787    #[serde(rename = "PlainCardData", skip_serializing_if = "Option::is_none")]
5788    pub plain_card_data: Option<PlainCardData11>,
5789    #[serde(rename = "CardCtryCd", skip_serializing_if = "Option::is_none")]
5790    pub card_ctry_cd: Option<String>,
5791    #[serde(rename = "CardBrnd", skip_serializing_if = "Option::is_none")]
5792    pub card_brnd: Option<GenericIdentification11>,
5793    #[serde(rename = "AddtlCardData", skip_serializing_if = "Option::is_none")]
5794    pub addtl_card_data: Option<String>,
5795}
5796
5797impl PaymentCard41 {
5798    pub fn validate(&self) -> Result<(), ValidationError> {
5799        if let Some(ref val) = self.plain_card_data {
5800            val.validate()?
5801        }
5802        if let Some(ref val) = self.card_ctry_cd {
5803            let pattern = Regex::new("[0-9]{3}").unwrap();
5804            if !pattern.is_match(val) {
5805                return Err(ValidationError::new(
5806                    1005,
5807                    "card_ctry_cd does not match the required pattern".to_string(),
5808                ));
5809            }
5810        }
5811        if let Some(ref val) = self.card_brnd {
5812            val.validate()?
5813        }
5814        if let Some(ref val) = self.addtl_card_data {
5815            if val.chars().count() < 1 {
5816                return Err(ValidationError::new(
5817                    1001,
5818                    "addtl_card_data is shorter than the minimum length of 1".to_string(),
5819                ));
5820            }
5821            if val.chars().count() > 70 {
5822                return Err(ValidationError::new(
5823                    1002,
5824                    "addtl_card_data exceeds the maximum length of 70".to_string(),
5825                ));
5826            }
5827            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5828            if !pattern.is_match(val) {
5829                return Err(ValidationError::new(
5830                    1005,
5831                    "addtl_card_data does not match the required pattern".to_string(),
5832                ));
5833            }
5834        }
5835        Ok(())
5836    }
5837}
5838
5839// PaymentContext3: Method used to authenticate a cardholder.
5840#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5841pub struct PaymentContext3 {
5842    #[serde(rename = "CardPres", skip_serializing_if = "Option::is_none")]
5843    pub card_pres: Option<bool>,
5844    #[serde(rename = "CrdhldrPres", skip_serializing_if = "Option::is_none")]
5845    pub crdhldr_pres: Option<bool>,
5846    #[serde(rename = "OnLineCntxt", skip_serializing_if = "Option::is_none")]
5847    pub on_line_cntxt: Option<bool>,
5848    #[serde(rename = "AttndncCntxt", skip_serializing_if = "Option::is_none")]
5849    pub attndnc_cntxt: Option<AttendanceContext1Code>,
5850    #[serde(rename = "TxEnvt", skip_serializing_if = "Option::is_none")]
5851    pub tx_envt: Option<TransactionEnvironment1Code>,
5852    #[serde(rename = "TxChanl", skip_serializing_if = "Option::is_none")]
5853    pub tx_chanl: Option<TransactionChannel1Code>,
5854    #[serde(rename = "AttndntMsgCpbl", skip_serializing_if = "Option::is_none")]
5855    pub attndnt_msg_cpbl: Option<bool>,
5856    #[serde(rename = "AttndntLang", skip_serializing_if = "Option::is_none")]
5857    pub attndnt_lang: Option<String>,
5858    #[serde(rename = "CardDataNtryMd")]
5859    pub card_data_ntry_md: CardDataReading1Code,
5860    #[serde(rename = "FllbckInd", skip_serializing_if = "Option::is_none")]
5861    pub fllbck_ind: Option<bool>,
5862    #[serde(rename = "AuthntcnMtd", skip_serializing_if = "Option::is_none")]
5863    pub authntcn_mtd: Option<CardholderAuthentication2>,
5864}
5865
5866impl PaymentContext3 {
5867    pub fn validate(&self) -> Result<(), ValidationError> {
5868        if let Some(ref val) = self.attndnc_cntxt {
5869            val.validate()?
5870        }
5871        if let Some(ref val) = self.tx_envt {
5872            val.validate()?
5873        }
5874        if let Some(ref val) = self.tx_chanl {
5875            val.validate()?
5876        }
5877        if let Some(ref val) = self.attndnt_lang {
5878            let pattern = Regex::new("[a-z]{2,2}").unwrap();
5879            if !pattern.is_match(val) {
5880                return Err(ValidationError::new(
5881                    1005,
5882                    "attndnt_lang does not match the required pattern".to_string(),
5883                ));
5884            }
5885        }
5886        self.card_data_ntry_md.validate()?;
5887        if let Some(ref val) = self.authntcn_mtd {
5888            val.validate()?
5889        }
5890        Ok(())
5891    }
5892}
5893
5894// PaymentReturnReason51: Further details on the return reason.
5895#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5896pub struct PaymentReturnReason51 {
5897    #[serde(rename = "OrgnlBkTxCd", skip_serializing_if = "Option::is_none")]
5898    pub orgnl_bk_tx_cd: Option<BankTransactionCodeStructure41>,
5899    #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
5900    pub orgtr: Option<PartyIdentification1354>,
5901    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
5902    pub rsn: Option<ReturnReason5Choice1>,
5903    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
5904    pub addtl_inf: Option<Vec<String>>,
5905}
5906
5907impl PaymentReturnReason51 {
5908    pub fn validate(&self) -> Result<(), ValidationError> {
5909        if let Some(ref val) = self.orgnl_bk_tx_cd {
5910            val.validate()?
5911        }
5912        if let Some(ref val) = self.orgtr {
5913            val.validate()?
5914        }
5915        if let Some(ref val) = self.rsn {
5916            val.validate()?
5917        }
5918        if let Some(ref vec) = self.addtl_inf {
5919            for item in vec {
5920                if item.chars().count() < 1 {
5921                    return Err(ValidationError::new(
5922                        1001,
5923                        "addtl_inf is shorter than the minimum length of 1".to_string(),
5924                    ));
5925                }
5926                if item.chars().count() > 105 {
5927                    return Err(ValidationError::new(
5928                        1002,
5929                        "addtl_inf exceeds the maximum length of 105".to_string(),
5930                    ));
5931                }
5932                let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
5933                if !pattern.is_match(&item) {
5934                    return Err(ValidationError::new(
5935                        1005,
5936                        "addtl_inf does not match the required pattern".to_string(),
5937                    ));
5938                }
5939            }
5940        }
5941        Ok(())
5942    }
5943}
5944
5945// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
5946#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5947pub struct PersonIdentification131 {
5948    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
5949    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
5950    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
5951    pub othr: Option<Vec<GenericPersonIdentification11>>,
5952}
5953
5954impl PersonIdentification131 {
5955    pub fn validate(&self) -> Result<(), ValidationError> {
5956        if let Some(ref val) = self.dt_and_plc_of_birth {
5957            val.validate()?
5958        }
5959        if let Some(ref vec) = self.othr {
5960            for item in vec {
5961                item.validate()?
5962            }
5963        }
5964        Ok(())
5965    }
5966}
5967
5968// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
5969#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5970pub struct PersonIdentificationSchemeName1Choice1 {
5971    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
5972    pub cd: Option<String>,
5973    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
5974    pub prtry: Option<String>,
5975}
5976
5977impl PersonIdentificationSchemeName1Choice1 {
5978    pub fn validate(&self) -> Result<(), ValidationError> {
5979        if let Some(ref val) = self.cd {
5980            if val.chars().count() < 1 {
5981                return Err(ValidationError::new(
5982                    1001,
5983                    "cd is shorter than the minimum length of 1".to_string(),
5984                ));
5985            }
5986            if val.chars().count() > 4 {
5987                return Err(ValidationError::new(
5988                    1002,
5989                    "cd exceeds the maximum length of 4".to_string(),
5990                ));
5991            }
5992        }
5993        if let Some(ref val) = self.prtry {
5994            if val.chars().count() < 1 {
5995                return Err(ValidationError::new(
5996                    1001,
5997                    "prtry is shorter than the minimum length of 1".to_string(),
5998                ));
5999            }
6000            if val.chars().count() > 35 {
6001                return Err(ValidationError::new(
6002                    1002,
6003                    "prtry exceeds the maximum length of 35".to_string(),
6004                ));
6005            }
6006            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6007            if !pattern.is_match(val) {
6008                return Err(ValidationError::new(
6009                    1005,
6010                    "prtry does not match the required pattern".to_string(),
6011                ));
6012            }
6013        }
6014        Ok(())
6015    }
6016}
6017
6018// PlainCardData11: Card security code (CSC) associated with the card performing the transaction.
6019#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6020pub struct PlainCardData11 {
6021    #[serde(rename = "PAN")]
6022    pub pan: String,
6023    #[serde(rename = "CardSeqNb", skip_serializing_if = "Option::is_none")]
6024    pub card_seq_nb: Option<String>,
6025    #[serde(rename = "FctvDt", skip_serializing_if = "Option::is_none")]
6026    pub fctv_dt: Option<String>,
6027    #[serde(rename = "XpryDt")]
6028    pub xpry_dt: String,
6029    #[serde(rename = "SvcCd", skip_serializing_if = "Option::is_none")]
6030    pub svc_cd: Option<String>,
6031    #[serde(rename = "TrckData", skip_serializing_if = "Option::is_none")]
6032    pub trck_data: Option<Vec<TrackData11>>,
6033    #[serde(rename = "CardSctyCd", skip_serializing_if = "Option::is_none")]
6034    pub card_scty_cd: Option<CardSecurityInformation1>,
6035}
6036
6037impl PlainCardData11 {
6038    pub fn validate(&self) -> Result<(), ValidationError> {
6039        let pattern = Regex::new("[0-9]{8,28}").unwrap();
6040        if !pattern.is_match(&self.pan) {
6041            return Err(ValidationError::new(
6042                1005,
6043                "pan does not match the required pattern".to_string(),
6044            ));
6045        }
6046        if let Some(ref val) = self.card_seq_nb {
6047            let pattern = Regex::new("[0-9]{2,3}").unwrap();
6048            if !pattern.is_match(val) {
6049                return Err(ValidationError::new(
6050                    1005,
6051                    "card_seq_nb does not match the required pattern".to_string(),
6052                ));
6053            }
6054        }
6055        if let Some(ref val) = self.svc_cd {
6056            let pattern = Regex::new("[0-9]{3}").unwrap();
6057            if !pattern.is_match(val) {
6058                return Err(ValidationError::new(
6059                    1005,
6060                    "svc_cd does not match the required pattern".to_string(),
6061                ));
6062            }
6063        }
6064        if let Some(ref vec) = self.trck_data {
6065            for item in vec {
6066                item.validate()?
6067            }
6068        }
6069        if let Some(ref val) = self.card_scty_cd {
6070            val.validate()?
6071        }
6072        Ok(())
6073    }
6074}
6075
6076// PointOfInteraction11: Data related to a component of the POI performing the transaction.
6077#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6078pub struct PointOfInteraction11 {
6079    #[serde(rename = "Id")]
6080    pub id: GenericIdentification321,
6081    #[serde(rename = "SysNm", skip_serializing_if = "Option::is_none")]
6082    pub sys_nm: Option<String>,
6083    #[serde(rename = "GrpId", skip_serializing_if = "Option::is_none")]
6084    pub grp_id: Option<String>,
6085    #[serde(rename = "Cpblties", skip_serializing_if = "Option::is_none")]
6086    pub cpblties: Option<PointOfInteractionCapabilities1>,
6087    #[serde(rename = "Cmpnt", skip_serializing_if = "Option::is_none")]
6088    pub cmpnt: Option<Vec<PointOfInteractionComponent11>>,
6089}
6090
6091impl PointOfInteraction11 {
6092    pub fn validate(&self) -> Result<(), ValidationError> {
6093        self.id.validate()?;
6094        if let Some(ref val) = self.sys_nm {
6095            if val.chars().count() < 1 {
6096                return Err(ValidationError::new(
6097                    1001,
6098                    "sys_nm is shorter than the minimum length of 1".to_string(),
6099                ));
6100            }
6101            if val.chars().count() > 70 {
6102                return Err(ValidationError::new(
6103                    1002,
6104                    "sys_nm exceeds the maximum length of 70".to_string(),
6105                ));
6106            }
6107            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6108            if !pattern.is_match(val) {
6109                return Err(ValidationError::new(
6110                    1005,
6111                    "sys_nm does not match the required pattern".to_string(),
6112                ));
6113            }
6114        }
6115        if let Some(ref val) = self.grp_id {
6116            if val.chars().count() < 1 {
6117                return Err(ValidationError::new(
6118                    1001,
6119                    "grp_id is shorter than the minimum length of 1".to_string(),
6120                ));
6121            }
6122            if val.chars().count() > 35 {
6123                return Err(ValidationError::new(
6124                    1002,
6125                    "grp_id exceeds the maximum length of 35".to_string(),
6126                ));
6127            }
6128            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6129            if !pattern.is_match(val) {
6130                return Err(ValidationError::new(
6131                    1005,
6132                    "grp_id does not match the required pattern".to_string(),
6133                ));
6134            }
6135        }
6136        if let Some(ref val) = self.cpblties {
6137            val.validate()?
6138        }
6139        if let Some(ref vec) = self.cmpnt {
6140            for item in vec {
6141                item.validate()?
6142            }
6143        }
6144        Ok(())
6145    }
6146}
6147
6148// PointOfInteraction12: Data related to a component of the POI performing the transaction.
6149#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6150pub struct PointOfInteraction12 {
6151    #[serde(rename = "Id")]
6152    pub id: GenericIdentification321,
6153    #[serde(rename = "SysNm", skip_serializing_if = "Option::is_none")]
6154    pub sys_nm: Option<String>,
6155    #[serde(rename = "GrpId", skip_serializing_if = "Option::is_none")]
6156    pub grp_id: Option<String>,
6157    #[serde(rename = "Cpblties", skip_serializing_if = "Option::is_none")]
6158    pub cpblties: Option<PointOfInteractionCapabilities1>,
6159    #[serde(rename = "Cmpnt", skip_serializing_if = "Option::is_none")]
6160    pub cmpnt: Option<Vec<PointOfInteractionComponent12>>,
6161}
6162
6163impl PointOfInteraction12 {
6164    pub fn validate(&self) -> Result<(), ValidationError> {
6165        self.id.validate()?;
6166        if let Some(ref val) = self.sys_nm {
6167            if val.chars().count() < 1 {
6168                return Err(ValidationError::new(
6169                    1001,
6170                    "sys_nm is shorter than the minimum length of 1".to_string(),
6171                ));
6172            }
6173            if val.chars().count() > 70 {
6174                return Err(ValidationError::new(
6175                    1002,
6176                    "sys_nm exceeds the maximum length of 70".to_string(),
6177                ));
6178            }
6179            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6180            if !pattern.is_match(val) {
6181                return Err(ValidationError::new(
6182                    1005,
6183                    "sys_nm does not match the required pattern".to_string(),
6184                ));
6185            }
6186        }
6187        if let Some(ref val) = self.grp_id {
6188            if val.chars().count() < 1 {
6189                return Err(ValidationError::new(
6190                    1001,
6191                    "grp_id is shorter than the minimum length of 1".to_string(),
6192                ));
6193            }
6194            if val.chars().count() > 35 {
6195                return Err(ValidationError::new(
6196                    1002,
6197                    "grp_id exceeds the maximum length of 35".to_string(),
6198                ));
6199            }
6200            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6201            if !pattern.is_match(val) {
6202                return Err(ValidationError::new(
6203                    1005,
6204                    "grp_id does not match the required pattern".to_string(),
6205                ));
6206            }
6207        }
6208        if let Some(ref val) = self.cpblties {
6209            val.validate()?
6210        }
6211        if let Some(ref vec) = self.cmpnt {
6212            for item in vec {
6213                item.validate()?
6214            }
6215        }
6216        Ok(())
6217    }
6218}
6219
6220// PointOfInteractionCapabilities1: Number of columns of the printer component.
6221#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6222pub struct PointOfInteractionCapabilities1 {
6223    #[serde(rename = "CardRdngCpblties", skip_serializing_if = "Option::is_none")]
6224    pub card_rdng_cpblties: Option<Vec<CardDataReading1Code>>,
6225    #[serde(
6226        rename = "CrdhldrVrfctnCpblties",
6227        skip_serializing_if = "Option::is_none"
6228    )]
6229    pub crdhldr_vrfctn_cpblties: Option<Vec<CardholderVerificationCapability1Code>>,
6230    #[serde(rename = "OnLineCpblties", skip_serializing_if = "Option::is_none")]
6231    pub on_line_cpblties: Option<OnLineCapability1Code>,
6232    #[serde(rename = "DispCpblties", skip_serializing_if = "Option::is_none")]
6233    pub disp_cpblties: Option<Vec<DisplayCapabilities1>>,
6234    #[serde(rename = "PrtLineWidth", skip_serializing_if = "Option::is_none")]
6235    pub prt_line_width: Option<String>,
6236}
6237
6238impl PointOfInteractionCapabilities1 {
6239    pub fn validate(&self) -> Result<(), ValidationError> {
6240        if let Some(ref vec) = self.card_rdng_cpblties {
6241            for item in vec {
6242                item.validate()?
6243            }
6244        }
6245        if let Some(ref vec) = self.crdhldr_vrfctn_cpblties {
6246            for item in vec {
6247                item.validate()?
6248            }
6249        }
6250        if let Some(ref val) = self.on_line_cpblties {
6251            val.validate()?
6252        }
6253        if let Some(ref vec) = self.disp_cpblties {
6254            for item in vec {
6255                item.validate()?
6256            }
6257        }
6258        if let Some(ref val) = self.prt_line_width {
6259            let pattern = Regex::new("[0-9]{1,3}").unwrap();
6260            if !pattern.is_match(val) {
6261                return Err(ValidationError::new(
6262                    1005,
6263                    "prt_line_width does not match the required pattern".to_string(),
6264                ));
6265            }
6266        }
6267        Ok(())
6268    }
6269}
6270
6271// PointOfInteractionComponent11: Unique approval number for a component, delivered by a certification body.
6272// Usage: More than one approval number could be present, when assigned by different bodies. The certification body identification must be provided within the approval number (for example at the beginning of the value).
6273#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6274pub struct PointOfInteractionComponent11 {
6275    #[serde(rename = "POICmpntTp")]
6276    pub poi_cmpnt_tp: POIComponentType1Code,
6277    #[serde(rename = "ManfctrId", skip_serializing_if = "Option::is_none")]
6278    pub manfctr_id: Option<String>,
6279    #[serde(rename = "Mdl", skip_serializing_if = "Option::is_none")]
6280    pub mdl: Option<String>,
6281    #[serde(rename = "VrsnNb", skip_serializing_if = "Option::is_none")]
6282    pub vrsn_nb: Option<String>,
6283    #[serde(rename = "SrlNb", skip_serializing_if = "Option::is_none")]
6284    pub srl_nb: Option<String>,
6285    #[serde(rename = "ApprvlNb", skip_serializing_if = "Option::is_none")]
6286    pub apprvl_nb: Option<Vec<String>>,
6287}
6288
6289impl PointOfInteractionComponent11 {
6290    pub fn validate(&self) -> Result<(), ValidationError> {
6291        self.poi_cmpnt_tp.validate()?;
6292        if let Some(ref val) = self.manfctr_id {
6293            if val.chars().count() < 1 {
6294                return Err(ValidationError::new(
6295                    1001,
6296                    "manfctr_id is shorter than the minimum length of 1".to_string(),
6297                ));
6298            }
6299            if val.chars().count() > 35 {
6300                return Err(ValidationError::new(
6301                    1002,
6302                    "manfctr_id exceeds the maximum length of 35".to_string(),
6303                ));
6304            }
6305            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6306            if !pattern.is_match(val) {
6307                return Err(ValidationError::new(
6308                    1005,
6309                    "manfctr_id does not match the required pattern".to_string(),
6310                ));
6311            }
6312        }
6313        if let Some(ref val) = self.mdl {
6314            if val.chars().count() < 1 {
6315                return Err(ValidationError::new(
6316                    1001,
6317                    "mdl is shorter than the minimum length of 1".to_string(),
6318                ));
6319            }
6320            if val.chars().count() > 35 {
6321                return Err(ValidationError::new(
6322                    1002,
6323                    "mdl exceeds the maximum length of 35".to_string(),
6324                ));
6325            }
6326            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6327            if !pattern.is_match(val) {
6328                return Err(ValidationError::new(
6329                    1005,
6330                    "mdl does not match the required pattern".to_string(),
6331                ));
6332            }
6333        }
6334        if let Some(ref val) = self.vrsn_nb {
6335            if val.chars().count() < 1 {
6336                return Err(ValidationError::new(
6337                    1001,
6338                    "vrsn_nb is shorter than the minimum length of 1".to_string(),
6339                ));
6340            }
6341            if val.chars().count() > 16 {
6342                return Err(ValidationError::new(
6343                    1002,
6344                    "vrsn_nb exceeds the maximum length of 16".to_string(),
6345                ));
6346            }
6347            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6348            if !pattern.is_match(val) {
6349                return Err(ValidationError::new(
6350                    1005,
6351                    "vrsn_nb does not match the required pattern".to_string(),
6352                ));
6353            }
6354        }
6355        if let Some(ref val) = self.srl_nb {
6356            if val.chars().count() < 1 {
6357                return Err(ValidationError::new(
6358                    1001,
6359                    "srl_nb is shorter than the minimum length of 1".to_string(),
6360                ));
6361            }
6362            if val.chars().count() > 35 {
6363                return Err(ValidationError::new(
6364                    1002,
6365                    "srl_nb exceeds the maximum length of 35".to_string(),
6366                ));
6367            }
6368            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6369            if !pattern.is_match(val) {
6370                return Err(ValidationError::new(
6371                    1005,
6372                    "srl_nb does not match the required pattern".to_string(),
6373                ));
6374            }
6375        }
6376        if let Some(ref vec) = self.apprvl_nb {
6377            for item in vec {
6378                if item.chars().count() < 1 {
6379                    return Err(ValidationError::new(
6380                        1001,
6381                        "apprvl_nb is shorter than the minimum length of 1".to_string(),
6382                    ));
6383                }
6384                if item.chars().count() > 70 {
6385                    return Err(ValidationError::new(
6386                        1002,
6387                        "apprvl_nb exceeds the maximum length of 70".to_string(),
6388                    ));
6389                }
6390                let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6391                if !pattern.is_match(&item) {
6392                    return Err(ValidationError::new(
6393                        1005,
6394                        "apprvl_nb does not match the required pattern".to_string(),
6395                    ));
6396                }
6397            }
6398        }
6399        Ok(())
6400    }
6401}
6402
6403// PointOfInteractionComponent12: Unique approval number for a component, delivered by a certification body.
6404// Usage: More than one approval number could be present, when assigned by different bodies. The certification body identification must be provided within the approval number (for example at the beginning of the value).
6405#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6406pub struct PointOfInteractionComponent12 {
6407    #[serde(rename = "POICmpntTp")]
6408    pub poi_cmpnt_tp: POIComponentType1Code,
6409    #[serde(rename = "ManfctrId", skip_serializing_if = "Option::is_none")]
6410    pub manfctr_id: Option<String>,
6411    #[serde(rename = "Mdl", skip_serializing_if = "Option::is_none")]
6412    pub mdl: Option<String>,
6413    #[serde(rename = "VrsnNb", skip_serializing_if = "Option::is_none")]
6414    pub vrsn_nb: Option<String>,
6415    #[serde(rename = "SrlNb", skip_serializing_if = "Option::is_none")]
6416    pub srl_nb: Option<String>,
6417    #[serde(rename = "ApprvlNb", skip_serializing_if = "Option::is_none")]
6418    pub apprvl_nb: Option<Vec<String>>,
6419}
6420
6421impl PointOfInteractionComponent12 {
6422    pub fn validate(&self) -> Result<(), ValidationError> {
6423        self.poi_cmpnt_tp.validate()?;
6424        if let Some(ref val) = self.manfctr_id {
6425            if val.chars().count() < 1 {
6426                return Err(ValidationError::new(
6427                    1001,
6428                    "manfctr_id is shorter than the minimum length of 1".to_string(),
6429                ));
6430            }
6431            if val.chars().count() > 35 {
6432                return Err(ValidationError::new(
6433                    1002,
6434                    "manfctr_id exceeds the maximum length of 35".to_string(),
6435                ));
6436            }
6437            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6438            if !pattern.is_match(val) {
6439                return Err(ValidationError::new(
6440                    1005,
6441                    "manfctr_id does not match the required pattern".to_string(),
6442                ));
6443            }
6444        }
6445        if let Some(ref val) = self.mdl {
6446            if val.chars().count() < 1 {
6447                return Err(ValidationError::new(
6448                    1001,
6449                    "mdl is shorter than the minimum length of 1".to_string(),
6450                ));
6451            }
6452            if val.chars().count() > 35 {
6453                return Err(ValidationError::new(
6454                    1002,
6455                    "mdl exceeds the maximum length of 35".to_string(),
6456                ));
6457            }
6458            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6459            if !pattern.is_match(val) {
6460                return Err(ValidationError::new(
6461                    1005,
6462                    "mdl does not match the required pattern".to_string(),
6463                ));
6464            }
6465        }
6466        if let Some(ref val) = self.vrsn_nb {
6467            if val.chars().count() < 1 {
6468                return Err(ValidationError::new(
6469                    1001,
6470                    "vrsn_nb is shorter than the minimum length of 1".to_string(),
6471                ));
6472            }
6473            if val.chars().count() > 16 {
6474                return Err(ValidationError::new(
6475                    1002,
6476                    "vrsn_nb exceeds the maximum length of 16".to_string(),
6477                ));
6478            }
6479            let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
6480            if !pattern.is_match(val) {
6481                return Err(ValidationError::new(
6482                    1005,
6483                    "vrsn_nb does not match the required pattern".to_string(),
6484                ));
6485            }
6486        }
6487        if let Some(ref val) = self.srl_nb {
6488            if val.chars().count() < 1 {
6489                return Err(ValidationError::new(
6490                    1001,
6491                    "srl_nb is shorter than the minimum length of 1".to_string(),
6492                ));
6493            }
6494            if val.chars().count() > 35 {
6495                return Err(ValidationError::new(
6496                    1002,
6497                    "srl_nb exceeds the maximum length of 35".to_string(),
6498                ));
6499            }
6500            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6501            if !pattern.is_match(val) {
6502                return Err(ValidationError::new(
6503                    1005,
6504                    "srl_nb does not match the required pattern".to_string(),
6505                ));
6506            }
6507        }
6508        if let Some(ref vec) = self.apprvl_nb {
6509            for item in vec {
6510                if item.chars().count() < 1 {
6511                    return Err(ValidationError::new(
6512                        1001,
6513                        "apprvl_nb is shorter than the minimum length of 1".to_string(),
6514                    ));
6515                }
6516                if item.chars().count() > 70 {
6517                    return Err(ValidationError::new(
6518                        1002,
6519                        "apprvl_nb exceeds the maximum length of 70".to_string(),
6520                    ));
6521                }
6522                let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6523                if !pattern.is_match(&item) {
6524                    return Err(ValidationError::new(
6525                        1005,
6526                        "apprvl_nb does not match the required pattern".to_string(),
6527                    ));
6528                }
6529            }
6530        }
6531        Ok(())
6532    }
6533}
6534
6535// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
6536#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6537pub struct PostalAddress241 {
6538    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
6539    pub adr_tp: Option<AddressType3Choice1>,
6540    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
6541    pub dept: Option<String>,
6542    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
6543    pub sub_dept: Option<String>,
6544    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
6545    pub strt_nm: Option<String>,
6546    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
6547    pub bldg_nb: Option<String>,
6548    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
6549    pub bldg_nm: Option<String>,
6550    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
6551    pub flr: Option<String>,
6552    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
6553    pub pst_bx: Option<String>,
6554    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
6555    pub room: Option<String>,
6556    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
6557    pub pst_cd: Option<String>,
6558    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
6559    pub twn_nm: Option<String>,
6560    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
6561    pub twn_lctn_nm: Option<String>,
6562    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
6563    pub dstrct_nm: Option<String>,
6564    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
6565    pub ctry_sub_dvsn: Option<String>,
6566    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
6567    pub ctry: Option<String>,
6568    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
6569    pub adr_line: Option<Vec<String>>,
6570}
6571
6572impl PostalAddress241 {
6573    pub fn validate(&self) -> Result<(), ValidationError> {
6574        if let Some(ref val) = self.adr_tp {
6575            val.validate()?
6576        }
6577        if let Some(ref val) = self.dept {
6578            if val.chars().count() < 1 {
6579                return Err(ValidationError::new(
6580                    1001,
6581                    "dept is shorter than the minimum length of 1".to_string(),
6582                ));
6583            }
6584            if val.chars().count() > 70 {
6585                return Err(ValidationError::new(
6586                    1002,
6587                    "dept exceeds the maximum length of 70".to_string(),
6588                ));
6589            }
6590            let pattern = Regex::new(
6591                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6592            )
6593            .unwrap();
6594            if !pattern.is_match(val) {
6595                return Err(ValidationError::new(
6596                    1005,
6597                    "dept does not match the required pattern".to_string(),
6598                ));
6599            }
6600        }
6601        if let Some(ref val) = self.sub_dept {
6602            if val.chars().count() < 1 {
6603                return Err(ValidationError::new(
6604                    1001,
6605                    "sub_dept is shorter than the minimum length of 1".to_string(),
6606                ));
6607            }
6608            if val.chars().count() > 70 {
6609                return Err(ValidationError::new(
6610                    1002,
6611                    "sub_dept exceeds the maximum length of 70".to_string(),
6612                ));
6613            }
6614            let pattern = Regex::new(
6615                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6616            )
6617            .unwrap();
6618            if !pattern.is_match(val) {
6619                return Err(ValidationError::new(
6620                    1005,
6621                    "sub_dept does not match the required pattern".to_string(),
6622                ));
6623            }
6624        }
6625        if let Some(ref val) = self.strt_nm {
6626            if val.chars().count() < 1 {
6627                return Err(ValidationError::new(
6628                    1001,
6629                    "strt_nm is shorter than the minimum length of 1".to_string(),
6630                ));
6631            }
6632            if val.chars().count() > 70 {
6633                return Err(ValidationError::new(
6634                    1002,
6635                    "strt_nm exceeds the maximum length of 70".to_string(),
6636                ));
6637            }
6638            let pattern = Regex::new(
6639                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6640            )
6641            .unwrap();
6642            if !pattern.is_match(val) {
6643                return Err(ValidationError::new(
6644                    1005,
6645                    "strt_nm does not match the required pattern".to_string(),
6646                ));
6647            }
6648        }
6649        if let Some(ref val) = self.bldg_nb {
6650            if val.chars().count() < 1 {
6651                return Err(ValidationError::new(
6652                    1001,
6653                    "bldg_nb is shorter than the minimum length of 1".to_string(),
6654                ));
6655            }
6656            if val.chars().count() > 16 {
6657                return Err(ValidationError::new(
6658                    1002,
6659                    "bldg_nb exceeds the maximum length of 16".to_string(),
6660                ));
6661            }
6662            let pattern = Regex::new(
6663                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6664            )
6665            .unwrap();
6666            if !pattern.is_match(val) {
6667                return Err(ValidationError::new(
6668                    1005,
6669                    "bldg_nb does not match the required pattern".to_string(),
6670                ));
6671            }
6672        }
6673        if let Some(ref val) = self.bldg_nm {
6674            if val.chars().count() < 1 {
6675                return Err(ValidationError::new(
6676                    1001,
6677                    "bldg_nm is shorter than the minimum length of 1".to_string(),
6678                ));
6679            }
6680            if val.chars().count() > 35 {
6681                return Err(ValidationError::new(
6682                    1002,
6683                    "bldg_nm exceeds the maximum length of 35".to_string(),
6684                ));
6685            }
6686            let pattern = Regex::new(
6687                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6688            )
6689            .unwrap();
6690            if !pattern.is_match(val) {
6691                return Err(ValidationError::new(
6692                    1005,
6693                    "bldg_nm does not match the required pattern".to_string(),
6694                ));
6695            }
6696        }
6697        if let Some(ref val) = self.flr {
6698            if val.chars().count() < 1 {
6699                return Err(ValidationError::new(
6700                    1001,
6701                    "flr is shorter than the minimum length of 1".to_string(),
6702                ));
6703            }
6704            if val.chars().count() > 70 {
6705                return Err(ValidationError::new(
6706                    1002,
6707                    "flr exceeds the maximum length of 70".to_string(),
6708                ));
6709            }
6710            let pattern = Regex::new(
6711                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6712            )
6713            .unwrap();
6714            if !pattern.is_match(val) {
6715                return Err(ValidationError::new(
6716                    1005,
6717                    "flr does not match the required pattern".to_string(),
6718                ));
6719            }
6720        }
6721        if let Some(ref val) = self.pst_bx {
6722            if val.chars().count() < 1 {
6723                return Err(ValidationError::new(
6724                    1001,
6725                    "pst_bx is shorter than the minimum length of 1".to_string(),
6726                ));
6727            }
6728            if val.chars().count() > 16 {
6729                return Err(ValidationError::new(
6730                    1002,
6731                    "pst_bx exceeds the maximum length of 16".to_string(),
6732                ));
6733            }
6734            let pattern = Regex::new(
6735                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6736            )
6737            .unwrap();
6738            if !pattern.is_match(val) {
6739                return Err(ValidationError::new(
6740                    1005,
6741                    "pst_bx does not match the required pattern".to_string(),
6742                ));
6743            }
6744        }
6745        if let Some(ref val) = self.room {
6746            if val.chars().count() < 1 {
6747                return Err(ValidationError::new(
6748                    1001,
6749                    "room is shorter than the minimum length of 1".to_string(),
6750                ));
6751            }
6752            if val.chars().count() > 70 {
6753                return Err(ValidationError::new(
6754                    1002,
6755                    "room exceeds the maximum length of 70".to_string(),
6756                ));
6757            }
6758            let pattern = Regex::new(
6759                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6760            )
6761            .unwrap();
6762            if !pattern.is_match(val) {
6763                return Err(ValidationError::new(
6764                    1005,
6765                    "room does not match the required pattern".to_string(),
6766                ));
6767            }
6768        }
6769        if let Some(ref val) = self.pst_cd {
6770            if val.chars().count() < 1 {
6771                return Err(ValidationError::new(
6772                    1001,
6773                    "pst_cd is shorter than the minimum length of 1".to_string(),
6774                ));
6775            }
6776            if val.chars().count() > 16 {
6777                return Err(ValidationError::new(
6778                    1002,
6779                    "pst_cd exceeds the maximum length of 16".to_string(),
6780                ));
6781            }
6782            let pattern = Regex::new(
6783                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6784            )
6785            .unwrap();
6786            if !pattern.is_match(val) {
6787                return Err(ValidationError::new(
6788                    1005,
6789                    "pst_cd does not match the required pattern".to_string(),
6790                ));
6791            }
6792        }
6793        if let Some(ref val) = self.twn_nm {
6794            if val.chars().count() < 1 {
6795                return Err(ValidationError::new(
6796                    1001,
6797                    "twn_nm is shorter than the minimum length of 1".to_string(),
6798                ));
6799            }
6800            if val.chars().count() > 35 {
6801                return Err(ValidationError::new(
6802                    1002,
6803                    "twn_nm exceeds the maximum length of 35".to_string(),
6804                ));
6805            }
6806            let pattern = Regex::new(
6807                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6808            )
6809            .unwrap();
6810            if !pattern.is_match(val) {
6811                return Err(ValidationError::new(
6812                    1005,
6813                    "twn_nm does not match the required pattern".to_string(),
6814                ));
6815            }
6816        }
6817        if let Some(ref val) = self.twn_lctn_nm {
6818            if val.chars().count() < 1 {
6819                return Err(ValidationError::new(
6820                    1001,
6821                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
6822                ));
6823            }
6824            if val.chars().count() > 35 {
6825                return Err(ValidationError::new(
6826                    1002,
6827                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
6828                ));
6829            }
6830            let pattern = Regex::new(
6831                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6832            )
6833            .unwrap();
6834            if !pattern.is_match(val) {
6835                return Err(ValidationError::new(
6836                    1005,
6837                    "twn_lctn_nm does not match the required pattern".to_string(),
6838                ));
6839            }
6840        }
6841        if let Some(ref val) = self.dstrct_nm {
6842            if val.chars().count() < 1 {
6843                return Err(ValidationError::new(
6844                    1001,
6845                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
6846                ));
6847            }
6848            if val.chars().count() > 35 {
6849                return Err(ValidationError::new(
6850                    1002,
6851                    "dstrct_nm exceeds the maximum length of 35".to_string(),
6852                ));
6853            }
6854            let pattern = Regex::new(
6855                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6856            )
6857            .unwrap();
6858            if !pattern.is_match(val) {
6859                return Err(ValidationError::new(
6860                    1005,
6861                    "dstrct_nm does not match the required pattern".to_string(),
6862                ));
6863            }
6864        }
6865        if let Some(ref val) = self.ctry_sub_dvsn {
6866            if val.chars().count() < 1 {
6867                return Err(ValidationError::new(
6868                    1001,
6869                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
6870                ));
6871            }
6872            if val.chars().count() > 35 {
6873                return Err(ValidationError::new(
6874                    1002,
6875                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
6876                ));
6877            }
6878            let pattern = Regex::new(
6879                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6880            )
6881            .unwrap();
6882            if !pattern.is_match(val) {
6883                return Err(ValidationError::new(
6884                    1005,
6885                    "ctry_sub_dvsn does not match the required pattern".to_string(),
6886                ));
6887            }
6888        }
6889        if let Some(ref val) = self.ctry {
6890            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
6891            if !pattern.is_match(val) {
6892                return Err(ValidationError::new(
6893                    1005,
6894                    "ctry does not match the required pattern".to_string(),
6895                ));
6896            }
6897        }
6898        if let Some(ref vec) = self.adr_line {
6899            for item in vec {
6900                if item.chars().count() < 1 {
6901                    return Err(ValidationError::new(
6902                        1001,
6903                        "adr_line is shorter than the minimum length of 1".to_string(),
6904                    ));
6905                }
6906                if item.chars().count() > 70 {
6907                    return Err(ValidationError::new(
6908                        1002,
6909                        "adr_line exceeds the maximum length of 70".to_string(),
6910                    ));
6911                }
6912                let pattern = Regex::new(
6913                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6914                )
6915                .unwrap();
6916                if !pattern.is_match(&item) {
6917                    return Err(ValidationError::new(
6918                        1005,
6919                        "adr_line does not match the required pattern".to_string(),
6920                    ));
6921                }
6922            }
6923        }
6924        Ok(())
6925    }
6926}
6927
6928// PostalAddress242: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
6929#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6930pub struct PostalAddress242 {
6931    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
6932    pub adr_tp: Option<AddressType3Choice2>,
6933    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
6934    pub dept: Option<String>,
6935    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
6936    pub sub_dept: Option<String>,
6937    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
6938    pub strt_nm: Option<String>,
6939    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
6940    pub bldg_nb: Option<String>,
6941    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
6942    pub bldg_nm: Option<String>,
6943    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
6944    pub flr: Option<String>,
6945    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
6946    pub pst_bx: Option<String>,
6947    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
6948    pub room: Option<String>,
6949    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
6950    pub pst_cd: Option<String>,
6951    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
6952    pub twn_nm: Option<String>,
6953    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
6954    pub twn_lctn_nm: Option<String>,
6955    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
6956    pub dstrct_nm: Option<String>,
6957    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
6958    pub ctry_sub_dvsn: Option<String>,
6959    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
6960    pub ctry: Option<String>,
6961    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
6962    pub adr_line: Option<Vec<String>>,
6963}
6964
6965impl PostalAddress242 {
6966    pub fn validate(&self) -> Result<(), ValidationError> {
6967        if let Some(ref val) = self.adr_tp {
6968            val.validate()?
6969        }
6970        if let Some(ref val) = self.dept {
6971            if val.chars().count() < 1 {
6972                return Err(ValidationError::new(
6973                    1001,
6974                    "dept is shorter than the minimum length of 1".to_string(),
6975                ));
6976            }
6977            if val.chars().count() > 70 {
6978                return Err(ValidationError::new(
6979                    1002,
6980                    "dept exceeds the maximum length of 70".to_string(),
6981                ));
6982            }
6983            let pattern = Regex::new(
6984                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6985            )
6986            .unwrap();
6987            if !pattern.is_match(val) {
6988                return Err(ValidationError::new(
6989                    1005,
6990                    "dept does not match the required pattern".to_string(),
6991                ));
6992            }
6993        }
6994        if let Some(ref val) = self.sub_dept {
6995            if val.chars().count() < 1 {
6996                return Err(ValidationError::new(
6997                    1001,
6998                    "sub_dept is shorter than the minimum length of 1".to_string(),
6999                ));
7000            }
7001            if val.chars().count() > 70 {
7002                return Err(ValidationError::new(
7003                    1002,
7004                    "sub_dept exceeds the maximum length of 70".to_string(),
7005                ));
7006            }
7007            let pattern = Regex::new(
7008                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7009            )
7010            .unwrap();
7011            if !pattern.is_match(val) {
7012                return Err(ValidationError::new(
7013                    1005,
7014                    "sub_dept does not match the required pattern".to_string(),
7015                ));
7016            }
7017        }
7018        if let Some(ref val) = self.strt_nm {
7019            if val.chars().count() < 1 {
7020                return Err(ValidationError::new(
7021                    1001,
7022                    "strt_nm is shorter than the minimum length of 1".to_string(),
7023                ));
7024            }
7025            if val.chars().count() > 70 {
7026                return Err(ValidationError::new(
7027                    1002,
7028                    "strt_nm exceeds the maximum length of 70".to_string(),
7029                ));
7030            }
7031            let pattern = Regex::new(
7032                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7033            )
7034            .unwrap();
7035            if !pattern.is_match(val) {
7036                return Err(ValidationError::new(
7037                    1005,
7038                    "strt_nm does not match the required pattern".to_string(),
7039                ));
7040            }
7041        }
7042        if let Some(ref val) = self.bldg_nb {
7043            if val.chars().count() < 1 {
7044                return Err(ValidationError::new(
7045                    1001,
7046                    "bldg_nb is shorter than the minimum length of 1".to_string(),
7047                ));
7048            }
7049            if val.chars().count() > 16 {
7050                return Err(ValidationError::new(
7051                    1002,
7052                    "bldg_nb exceeds the maximum length of 16".to_string(),
7053                ));
7054            }
7055            let pattern = Regex::new(
7056                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7057            )
7058            .unwrap();
7059            if !pattern.is_match(val) {
7060                return Err(ValidationError::new(
7061                    1005,
7062                    "bldg_nb does not match the required pattern".to_string(),
7063                ));
7064            }
7065        }
7066        if let Some(ref val) = self.bldg_nm {
7067            if val.chars().count() < 1 {
7068                return Err(ValidationError::new(
7069                    1001,
7070                    "bldg_nm is shorter than the minimum length of 1".to_string(),
7071                ));
7072            }
7073            if val.chars().count() > 35 {
7074                return Err(ValidationError::new(
7075                    1002,
7076                    "bldg_nm exceeds the maximum length of 35".to_string(),
7077                ));
7078            }
7079            let pattern = Regex::new(
7080                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7081            )
7082            .unwrap();
7083            if !pattern.is_match(val) {
7084                return Err(ValidationError::new(
7085                    1005,
7086                    "bldg_nm does not match the required pattern".to_string(),
7087                ));
7088            }
7089        }
7090        if let Some(ref val) = self.flr {
7091            if val.chars().count() < 1 {
7092                return Err(ValidationError::new(
7093                    1001,
7094                    "flr is shorter than the minimum length of 1".to_string(),
7095                ));
7096            }
7097            if val.chars().count() > 70 {
7098                return Err(ValidationError::new(
7099                    1002,
7100                    "flr exceeds the maximum length of 70".to_string(),
7101                ));
7102            }
7103            let pattern = Regex::new(
7104                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7105            )
7106            .unwrap();
7107            if !pattern.is_match(val) {
7108                return Err(ValidationError::new(
7109                    1005,
7110                    "flr does not match the required pattern".to_string(),
7111                ));
7112            }
7113        }
7114        if let Some(ref val) = self.pst_bx {
7115            if val.chars().count() < 1 {
7116                return Err(ValidationError::new(
7117                    1001,
7118                    "pst_bx is shorter than the minimum length of 1".to_string(),
7119                ));
7120            }
7121            if val.chars().count() > 16 {
7122                return Err(ValidationError::new(
7123                    1002,
7124                    "pst_bx exceeds the maximum length of 16".to_string(),
7125                ));
7126            }
7127            let pattern = Regex::new(
7128                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7129            )
7130            .unwrap();
7131            if !pattern.is_match(val) {
7132                return Err(ValidationError::new(
7133                    1005,
7134                    "pst_bx does not match the required pattern".to_string(),
7135                ));
7136            }
7137        }
7138        if let Some(ref val) = self.room {
7139            if val.chars().count() < 1 {
7140                return Err(ValidationError::new(
7141                    1001,
7142                    "room is shorter than the minimum length of 1".to_string(),
7143                ));
7144            }
7145            if val.chars().count() > 70 {
7146                return Err(ValidationError::new(
7147                    1002,
7148                    "room exceeds the maximum length of 70".to_string(),
7149                ));
7150            }
7151            let pattern = Regex::new(
7152                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7153            )
7154            .unwrap();
7155            if !pattern.is_match(val) {
7156                return Err(ValidationError::new(
7157                    1005,
7158                    "room does not match the required pattern".to_string(),
7159                ));
7160            }
7161        }
7162        if let Some(ref val) = self.pst_cd {
7163            if val.chars().count() < 1 {
7164                return Err(ValidationError::new(
7165                    1001,
7166                    "pst_cd is shorter than the minimum length of 1".to_string(),
7167                ));
7168            }
7169            if val.chars().count() > 16 {
7170                return Err(ValidationError::new(
7171                    1002,
7172                    "pst_cd exceeds the maximum length of 16".to_string(),
7173                ));
7174            }
7175            let pattern = Regex::new(
7176                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7177            )
7178            .unwrap();
7179            if !pattern.is_match(val) {
7180                return Err(ValidationError::new(
7181                    1005,
7182                    "pst_cd does not match the required pattern".to_string(),
7183                ));
7184            }
7185        }
7186        if let Some(ref val) = self.twn_nm {
7187            if val.chars().count() < 1 {
7188                return Err(ValidationError::new(
7189                    1001,
7190                    "twn_nm is shorter than the minimum length of 1".to_string(),
7191                ));
7192            }
7193            if val.chars().count() > 35 {
7194                return Err(ValidationError::new(
7195                    1002,
7196                    "twn_nm exceeds the maximum length of 35".to_string(),
7197                ));
7198            }
7199            let pattern = Regex::new(
7200                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7201            )
7202            .unwrap();
7203            if !pattern.is_match(val) {
7204                return Err(ValidationError::new(
7205                    1005,
7206                    "twn_nm does not match the required pattern".to_string(),
7207                ));
7208            }
7209        }
7210        if let Some(ref val) = self.twn_lctn_nm {
7211            if val.chars().count() < 1 {
7212                return Err(ValidationError::new(
7213                    1001,
7214                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
7215                ));
7216            }
7217            if val.chars().count() > 35 {
7218                return Err(ValidationError::new(
7219                    1002,
7220                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
7221                ));
7222            }
7223            let pattern = Regex::new(
7224                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7225            )
7226            .unwrap();
7227            if !pattern.is_match(val) {
7228                return Err(ValidationError::new(
7229                    1005,
7230                    "twn_lctn_nm does not match the required pattern".to_string(),
7231                ));
7232            }
7233        }
7234        if let Some(ref val) = self.dstrct_nm {
7235            if val.chars().count() < 1 {
7236                return Err(ValidationError::new(
7237                    1001,
7238                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
7239                ));
7240            }
7241            if val.chars().count() > 35 {
7242                return Err(ValidationError::new(
7243                    1002,
7244                    "dstrct_nm exceeds the maximum length of 35".to_string(),
7245                ));
7246            }
7247            let pattern = Regex::new(
7248                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7249            )
7250            .unwrap();
7251            if !pattern.is_match(val) {
7252                return Err(ValidationError::new(
7253                    1005,
7254                    "dstrct_nm does not match the required pattern".to_string(),
7255                ));
7256            }
7257        }
7258        if let Some(ref val) = self.ctry_sub_dvsn {
7259            if val.chars().count() < 1 {
7260                return Err(ValidationError::new(
7261                    1001,
7262                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
7263                ));
7264            }
7265            if val.chars().count() > 35 {
7266                return Err(ValidationError::new(
7267                    1002,
7268                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
7269                ));
7270            }
7271            let pattern = Regex::new(
7272                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7273            )
7274            .unwrap();
7275            if !pattern.is_match(val) {
7276                return Err(ValidationError::new(
7277                    1005,
7278                    "ctry_sub_dvsn does not match the required pattern".to_string(),
7279                ));
7280            }
7281        }
7282        if let Some(ref val) = self.ctry {
7283            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
7284            if !pattern.is_match(val) {
7285                return Err(ValidationError::new(
7286                    1005,
7287                    "ctry does not match the required pattern".to_string(),
7288                ));
7289            }
7290        }
7291        if let Some(ref vec) = self.adr_line {
7292            for item in vec {
7293                if item.chars().count() < 1 {
7294                    return Err(ValidationError::new(
7295                        1001,
7296                        "adr_line is shorter than the minimum length of 1".to_string(),
7297                    ));
7298                }
7299                if item.chars().count() > 70 {
7300                    return Err(ValidationError::new(
7301                        1002,
7302                        "adr_line exceeds the maximum length of 70".to_string(),
7303                    ));
7304                }
7305                let pattern = Regex::new(
7306                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7307                )
7308                .unwrap();
7309                if !pattern.is_match(&item) {
7310                    return Err(ValidationError::new(
7311                        1005,
7312                        "adr_line does not match the required pattern".to_string(),
7313                    ));
7314                }
7315            }
7316        }
7317        Ok(())
7318    }
7319}
7320
7321// PreferredContactMethod1Code: Preferred method used to reach the contact is per mobile or cell phone.
7322#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7323pub enum PreferredContactMethod1Code {
7324    #[default]
7325    #[serde(rename = "LETT")]
7326    CodeLETT,
7327    #[serde(rename = "MAIL")]
7328    CodeMAIL,
7329    #[serde(rename = "PHON")]
7330    CodePHON,
7331    #[serde(rename = "FAXX")]
7332    CodeFAXX,
7333    #[serde(rename = "CELL")]
7334    CodeCELL,
7335}
7336
7337impl PreferredContactMethod1Code {
7338    pub fn validate(&self) -> Result<(), ValidationError> {
7339        Ok(())
7340    }
7341}
7342
7343// Price7: Value of the price, for example, as a currency and value.
7344#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7345pub struct Price7 {
7346    #[serde(rename = "Tp")]
7347    pub tp: YieldedOrValueType1Choice,
7348    #[serde(rename = "Val")]
7349    pub val: PriceRateOrAmount3Choice,
7350}
7351
7352impl Price7 {
7353    pub fn validate(&self) -> Result<(), ValidationError> {
7354        self.tp.validate()?;
7355        self.val.validate()?;
7356        Ok(())
7357    }
7358}
7359
7360// PriceRateOrAmount3Choice: Price expressed as a currency and value.
7361#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7362pub struct PriceRateOrAmount3Choice {
7363    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
7364    pub rate: Option<f64>,
7365    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
7366    pub amt: Option<ActiveOrHistoricCurrencyAnd13DecimalAmount>,
7367}
7368
7369impl PriceRateOrAmount3Choice {
7370    pub fn validate(&self) -> Result<(), ValidationError> {
7371        if let Some(ref val) = self.amt {
7372            val.validate()?
7373        }
7374        Ok(())
7375    }
7376}
7377
7378// PriceValueType1Code: Price is the face amount.
7379#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7380pub enum PriceValueType1Code {
7381    #[default]
7382    #[serde(rename = "DISC")]
7383    CodeDISC,
7384    #[serde(rename = "PREM")]
7385    CodePREM,
7386    #[serde(rename = "PARV")]
7387    CodePARV,
7388}
7389
7390impl PriceValueType1Code {
7391    pub fn validate(&self) -> Result<(), ValidationError> {
7392        Ok(())
7393    }
7394}
7395
7396// Product21: Additional information related to the product.
7397#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7398pub struct Product21 {
7399    #[serde(rename = "PdctCd")]
7400    pub pdct_cd: String,
7401    #[serde(rename = "UnitOfMeasr", skip_serializing_if = "Option::is_none")]
7402    pub unit_of_measr: Option<UnitOfMeasure1Code>,
7403    #[serde(rename = "PdctQty", skip_serializing_if = "Option::is_none")]
7404    pub pdct_qty: Option<f64>,
7405    #[serde(rename = "UnitPric", skip_serializing_if = "Option::is_none")]
7406    pub unit_pric: Option<f64>,
7407    #[serde(rename = "PdctAmt", skip_serializing_if = "Option::is_none")]
7408    pub pdct_amt: Option<f64>,
7409    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
7410    pub tax_tp: Option<String>,
7411    #[serde(rename = "AddtlPdctInf", skip_serializing_if = "Option::is_none")]
7412    pub addtl_pdct_inf: Option<String>,
7413}
7414
7415impl Product21 {
7416    pub fn validate(&self) -> Result<(), ValidationError> {
7417        if self.pdct_cd.chars().count() < 1 {
7418            return Err(ValidationError::new(
7419                1001,
7420                "pdct_cd is shorter than the minimum length of 1".to_string(),
7421            ));
7422        }
7423        if self.pdct_cd.chars().count() > 70 {
7424            return Err(ValidationError::new(
7425                1002,
7426                "pdct_cd exceeds the maximum length of 70".to_string(),
7427            ));
7428        }
7429        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7430        if !pattern.is_match(&self.pdct_cd) {
7431            return Err(ValidationError::new(
7432                1005,
7433                "pdct_cd does not match the required pattern".to_string(),
7434            ));
7435        }
7436        if let Some(ref val) = self.unit_of_measr {
7437            val.validate()?
7438        }
7439        if let Some(ref val) = self.tax_tp {
7440            if val.chars().count() < 1 {
7441                return Err(ValidationError::new(
7442                    1001,
7443                    "tax_tp is shorter than the minimum length of 1".to_string(),
7444                ));
7445            }
7446            if val.chars().count() > 35 {
7447                return Err(ValidationError::new(
7448                    1002,
7449                    "tax_tp exceeds the maximum length of 35".to_string(),
7450                ));
7451            }
7452            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7453            if !pattern.is_match(val) {
7454                return Err(ValidationError::new(
7455                    1005,
7456                    "tax_tp does not match the required pattern".to_string(),
7457                ));
7458            }
7459        }
7460        if let Some(ref val) = self.addtl_pdct_inf {
7461            if val.chars().count() < 1 {
7462                return Err(ValidationError::new(
7463                    1001,
7464                    "addtl_pdct_inf is shorter than the minimum length of 1".to_string(),
7465                ));
7466            }
7467            if val.chars().count() > 35 {
7468                return Err(ValidationError::new(
7469                    1002,
7470                    "addtl_pdct_inf exceeds the maximum length of 35".to_string(),
7471                ));
7472            }
7473            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7474            if !pattern.is_match(val) {
7475                return Err(ValidationError::new(
7476                    1005,
7477                    "addtl_pdct_inf does not match the required pattern".to_string(),
7478                ));
7479            }
7480        }
7481        Ok(())
7482    }
7483}
7484
7485// ProprietaryAgent41: Organisation established primarily to provide financial services.
7486#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7487pub struct ProprietaryAgent41 {
7488    #[serde(rename = "Tp")]
7489    pub tp: String,
7490    #[serde(rename = "Agt")]
7491    pub agt: BranchAndFinancialInstitutionIdentification61,
7492}
7493
7494impl ProprietaryAgent41 {
7495    pub fn validate(&self) -> Result<(), ValidationError> {
7496        if self.tp.chars().count() < 1 {
7497            return Err(ValidationError::new(
7498                1001,
7499                "tp is shorter than the minimum length of 1".to_string(),
7500            ));
7501        }
7502        if self.tp.chars().count() > 35 {
7503            return Err(ValidationError::new(
7504                1002,
7505                "tp exceeds the maximum length of 35".to_string(),
7506            ));
7507        }
7508        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7509        if !pattern.is_match(&self.tp) {
7510            return Err(ValidationError::new(
7511                1005,
7512                "tp does not match the required pattern".to_string(),
7513            ));
7514        }
7515        self.agt.validate()?;
7516        Ok(())
7517    }
7518}
7519
7520// ProprietaryBankTransactionCodeStructure11: Identification of the issuer of the proprietary bank transaction code.
7521#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7522pub struct ProprietaryBankTransactionCodeStructure11 {
7523    #[serde(rename = "Cd")]
7524    pub cd: String,
7525    #[serde(rename = "Issr")]
7526    pub issr: String,
7527}
7528
7529impl ProprietaryBankTransactionCodeStructure11 {
7530    pub fn validate(&self) -> Result<(), ValidationError> {
7531        if self.cd.chars().count() < 1 {
7532            return Err(ValidationError::new(
7533                1001,
7534                "cd is shorter than the minimum length of 1".to_string(),
7535            ));
7536        }
7537        if self.cd.chars().count() > 35 {
7538            return Err(ValidationError::new(
7539                1002,
7540                "cd exceeds the maximum length of 35".to_string(),
7541            ));
7542        }
7543        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7544        if !pattern.is_match(&self.cd) {
7545            return Err(ValidationError::new(
7546                1005,
7547                "cd does not match the required pattern".to_string(),
7548            ));
7549        }
7550        if self.issr.chars().count() < 1 {
7551            return Err(ValidationError::new(
7552                1001,
7553                "issr is shorter than the minimum length of 1".to_string(),
7554            ));
7555        }
7556        if self.issr.chars().count() > 35 {
7557            return Err(ValidationError::new(
7558                1002,
7559                "issr exceeds the maximum length of 35".to_string(),
7560            ));
7561        }
7562        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7563        if !pattern.is_match(&self.issr) {
7564            return Err(ValidationError::new(
7565                1005,
7566                "issr does not match the required pattern".to_string(),
7567            ));
7568        }
7569        Ok(())
7570    }
7571}
7572
7573// ProprietaryDate31: Date in ISO format.
7574#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7575pub struct ProprietaryDate31 {
7576    #[serde(rename = "Tp")]
7577    pub tp: String,
7578    #[serde(rename = "Dt")]
7579    pub dt: DateAndDateTime2Choice,
7580}
7581
7582impl ProprietaryDate31 {
7583    pub fn validate(&self) -> Result<(), ValidationError> {
7584        if self.tp.chars().count() < 1 {
7585            return Err(ValidationError::new(
7586                1001,
7587                "tp is shorter than the minimum length of 1".to_string(),
7588            ));
7589        }
7590        if self.tp.chars().count() > 35 {
7591            return Err(ValidationError::new(
7592                1002,
7593                "tp exceeds the maximum length of 35".to_string(),
7594            ));
7595        }
7596        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7597        if !pattern.is_match(&self.tp) {
7598            return Err(ValidationError::new(
7599                1005,
7600                "tp does not match the required pattern".to_string(),
7601            ));
7602        }
7603        self.dt.validate()?;
7604        Ok(())
7605    }
7606}
7607
7608// ProprietaryParty51: Proprietary party.
7609#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7610pub struct ProprietaryParty51 {
7611    #[serde(rename = "Tp")]
7612    pub tp: String,
7613    #[serde(rename = "Pty")]
7614    pub pty: Party40Choice3,
7615}
7616
7617impl ProprietaryParty51 {
7618    pub fn validate(&self) -> Result<(), ValidationError> {
7619        if self.tp.chars().count() < 1 {
7620            return Err(ValidationError::new(
7621                1001,
7622                "tp is shorter than the minimum length of 1".to_string(),
7623            ));
7624        }
7625        if self.tp.chars().count() > 35 {
7626            return Err(ValidationError::new(
7627                1002,
7628                "tp exceeds the maximum length of 35".to_string(),
7629            ));
7630        }
7631        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7632        if !pattern.is_match(&self.tp) {
7633            return Err(ValidationError::new(
7634                1005,
7635                "tp does not match the required pattern".to_string(),
7636            ));
7637        }
7638        self.pty.validate()?;
7639        Ok(())
7640    }
7641}
7642
7643// ProprietaryPrice21: Proprietary price specification related to the underlying transaction.
7644#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7645pub struct ProprietaryPrice21 {
7646    #[serde(rename = "Tp")]
7647    pub tp: String,
7648    #[serde(rename = "Pric")]
7649    pub pric: ActiveOrHistoricCurrencyAndAmount,
7650}
7651
7652impl ProprietaryPrice21 {
7653    pub fn validate(&self) -> Result<(), ValidationError> {
7654        if self.tp.chars().count() < 1 {
7655            return Err(ValidationError::new(
7656                1001,
7657                "tp is shorter than the minimum length of 1".to_string(),
7658            ));
7659        }
7660        if self.tp.chars().count() > 35 {
7661            return Err(ValidationError::new(
7662                1002,
7663                "tp exceeds the maximum length of 35".to_string(),
7664            ));
7665        }
7666        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7667        if !pattern.is_match(&self.tp) {
7668            return Err(ValidationError::new(
7669                1005,
7670                "tp does not match the required pattern".to_string(),
7671            ));
7672        }
7673        self.pric.validate()?;
7674        Ok(())
7675    }
7676}
7677
7678// ProprietaryQuantity11: Provides the proprietary quantity in free format.
7679#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7680pub struct ProprietaryQuantity11 {
7681    #[serde(rename = "Tp")]
7682    pub tp: String,
7683    #[serde(rename = "Qty")]
7684    pub qty: String,
7685}
7686
7687impl ProprietaryQuantity11 {
7688    pub fn validate(&self) -> Result<(), ValidationError> {
7689        if self.tp.chars().count() < 1 {
7690            return Err(ValidationError::new(
7691                1001,
7692                "tp is shorter than the minimum length of 1".to_string(),
7693            ));
7694        }
7695        if self.tp.chars().count() > 35 {
7696            return Err(ValidationError::new(
7697                1002,
7698                "tp exceeds the maximum length of 35".to_string(),
7699            ));
7700        }
7701        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7702        if !pattern.is_match(&self.tp) {
7703            return Err(ValidationError::new(
7704                1005,
7705                "tp does not match the required pattern".to_string(),
7706            ));
7707        }
7708        if self.qty.chars().count() < 1 {
7709            return Err(ValidationError::new(
7710                1001,
7711                "qty is shorter than the minimum length of 1".to_string(),
7712            ));
7713        }
7714        if self.qty.chars().count() > 35 {
7715            return Err(ValidationError::new(
7716                1002,
7717                "qty exceeds the maximum length of 35".to_string(),
7718            ));
7719        }
7720        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7721        if !pattern.is_match(&self.qty) {
7722            return Err(ValidationError::new(
7723                1005,
7724                "qty does not match the required pattern".to_string(),
7725            ));
7726        }
7727        Ok(())
7728    }
7729}
7730
7731// ProprietaryReference11: Proprietary reference specification related to the underlying transaction.
7732#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7733pub struct ProprietaryReference11 {
7734    #[serde(rename = "Tp")]
7735    pub tp: String,
7736    #[serde(rename = "Ref")]
7737    pub ref_attr: String,
7738}
7739
7740impl ProprietaryReference11 {
7741    pub fn validate(&self) -> Result<(), ValidationError> {
7742        if self.tp.chars().count() < 1 {
7743            return Err(ValidationError::new(
7744                1001,
7745                "tp is shorter than the minimum length of 1".to_string(),
7746            ));
7747        }
7748        if self.tp.chars().count() > 35 {
7749            return Err(ValidationError::new(
7750                1002,
7751                "tp exceeds the maximum length of 35".to_string(),
7752            ));
7753        }
7754        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7755        if !pattern.is_match(&self.tp) {
7756            return Err(ValidationError::new(
7757                1005,
7758                "tp does not match the required pattern".to_string(),
7759            ));
7760        }
7761        if self.ref_attr.chars().count() < 1 {
7762            return Err(ValidationError::new(
7763                1001,
7764                "ref_attr is shorter than the minimum length of 1".to_string(),
7765            ));
7766        }
7767        if self.ref_attr.chars().count() > 35 {
7768            return Err(ValidationError::new(
7769                1002,
7770                "ref_attr exceeds the maximum length of 35".to_string(),
7771            ));
7772        }
7773        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7774        if !pattern.is_match(&self.ref_attr) {
7775            return Err(ValidationError::new(
7776                1005,
7777                "ref_attr does not match the required pattern".to_string(),
7778            ));
7779        }
7780        Ok(())
7781    }
7782}
7783
7784// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
7785#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7786pub struct ProxyAccountIdentification11 {
7787    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7788    pub tp: Option<ProxyAccountType1Choice1>,
7789    #[serde(rename = "Id")]
7790    pub id: String,
7791}
7792
7793impl ProxyAccountIdentification11 {
7794    pub fn validate(&self) -> Result<(), ValidationError> {
7795        if let Some(ref val) = self.tp {
7796            val.validate()?
7797        }
7798        if self.id.chars().count() < 1 {
7799            return Err(ValidationError::new(
7800                1001,
7801                "id is shorter than the minimum length of 1".to_string(),
7802            ));
7803        }
7804        if self.id.chars().count() > 320 {
7805            return Err(ValidationError::new(
7806                1002,
7807                "id exceeds the maximum length of 320".to_string(),
7808            ));
7809        }
7810        let pattern =
7811            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
7812                .unwrap();
7813        if !pattern.is_match(&self.id) {
7814            return Err(ValidationError::new(
7815                1005,
7816                "id does not match the required pattern".to_string(),
7817            ));
7818        }
7819        Ok(())
7820    }
7821}
7822
7823// ProxyAccountIdentification12: Identification used to indicate the account identification under another specified name.
7824#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7825pub struct ProxyAccountIdentification12 {
7826    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7827    pub tp: Option<ProxyAccountType1Choice>,
7828    #[serde(rename = "Id")]
7829    pub id: String,
7830}
7831
7832impl ProxyAccountIdentification12 {
7833    pub fn validate(&self) -> Result<(), ValidationError> {
7834        if let Some(ref val) = self.tp {
7835            val.validate()?
7836        }
7837        if self.id.chars().count() < 1 {
7838            return Err(ValidationError::new(
7839                1001,
7840                "id is shorter than the minimum length of 1".to_string(),
7841            ));
7842        }
7843        if self.id.chars().count() > 320 {
7844            return Err(ValidationError::new(
7845                1002,
7846                "id exceeds the maximum length of 320".to_string(),
7847            ));
7848        }
7849        let pattern =
7850            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
7851                .unwrap();
7852        if !pattern.is_match(&self.id) {
7853            return Err(ValidationError::new(
7854                1005,
7855                "id does not match the required pattern".to_string(),
7856            ));
7857        }
7858        Ok(())
7859    }
7860}
7861
7862// ProxyAccountType1Choice: Name of the identification scheme, in a free text form.
7863#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7864pub struct ProxyAccountType1Choice {
7865    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7866    pub cd: Option<String>,
7867    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7868    pub prtry: Option<String>,
7869}
7870
7871impl ProxyAccountType1Choice {
7872    pub fn validate(&self) -> Result<(), ValidationError> {
7873        if let Some(ref val) = self.cd {
7874            if val.chars().count() < 1 {
7875                return Err(ValidationError::new(
7876                    1001,
7877                    "cd is shorter than the minimum length of 1".to_string(),
7878                ));
7879            }
7880            if val.chars().count() > 4 {
7881                return Err(ValidationError::new(
7882                    1002,
7883                    "cd exceeds the maximum length of 4".to_string(),
7884                ));
7885            }
7886        }
7887        if let Some(ref val) = self.prtry {
7888            if val.chars().count() < 1 {
7889                return Err(ValidationError::new(
7890                    1001,
7891                    "prtry is shorter than the minimum length of 1".to_string(),
7892                ));
7893            }
7894            if val.chars().count() > 35 {
7895                return Err(ValidationError::new(
7896                    1002,
7897                    "prtry exceeds the maximum length of 35".to_string(),
7898                ));
7899            }
7900        }
7901        Ok(())
7902    }
7903}
7904
7905// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
7906#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7907pub struct ProxyAccountType1Choice1 {
7908    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7909    pub cd: Option<String>,
7910    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7911    pub prtry: Option<String>,
7912}
7913
7914impl ProxyAccountType1Choice1 {
7915    pub fn validate(&self) -> Result<(), ValidationError> {
7916        if let Some(ref val) = self.cd {
7917            if val.chars().count() < 1 {
7918                return Err(ValidationError::new(
7919                    1001,
7920                    "cd is shorter than the minimum length of 1".to_string(),
7921                ));
7922            }
7923            if val.chars().count() > 4 {
7924                return Err(ValidationError::new(
7925                    1002,
7926                    "cd exceeds the maximum length of 4".to_string(),
7927                ));
7928            }
7929        }
7930        if let Some(ref val) = self.prtry {
7931            if val.chars().count() < 1 {
7932                return Err(ValidationError::new(
7933                    1001,
7934                    "prtry is shorter than the minimum length of 1".to_string(),
7935                ));
7936            }
7937            if val.chars().count() > 35 {
7938                return Err(ValidationError::new(
7939                    1002,
7940                    "prtry exceeds the maximum length of 35".to_string(),
7941                ));
7942            }
7943            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7944            if !pattern.is_match(val) {
7945                return Err(ValidationError::new(
7946                    1005,
7947                    "prtry does not match the required pattern".to_string(),
7948                ));
7949            }
7950        }
7951        Ok(())
7952    }
7953}
7954
7955// Purpose2Choice1: Purpose, in a proprietary form.
7956#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7957pub struct Purpose2Choice1 {
7958    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7959    pub cd: Option<String>,
7960    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7961    pub prtry: Option<String>,
7962}
7963
7964impl Purpose2Choice1 {
7965    pub fn validate(&self) -> Result<(), ValidationError> {
7966        if let Some(ref val) = self.cd {
7967            if val.chars().count() < 1 {
7968                return Err(ValidationError::new(
7969                    1001,
7970                    "cd is shorter than the minimum length of 1".to_string(),
7971                ));
7972            }
7973            if val.chars().count() > 4 {
7974                return Err(ValidationError::new(
7975                    1002,
7976                    "cd exceeds the maximum length of 4".to_string(),
7977                ));
7978            }
7979        }
7980        if let Some(ref val) = self.prtry {
7981            if val.chars().count() < 1 {
7982                return Err(ValidationError::new(
7983                    1001,
7984                    "prtry is shorter than the minimum length of 1".to_string(),
7985                ));
7986            }
7987            if val.chars().count() > 35 {
7988                return Err(ValidationError::new(
7989                    1002,
7990                    "prtry exceeds the maximum length of 35".to_string(),
7991                ));
7992            }
7993            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
7994            if !pattern.is_match(val) {
7995                return Err(ValidationError::new(
7996                    1005,
7997                    "prtry does not match the required pattern".to_string(),
7998                ));
7999            }
8000        }
8001        Ok(())
8002    }
8003}
8004
8005// Rate41: An amount range where the interest rate is applicable.
8006#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8007pub struct Rate41 {
8008    #[serde(rename = "Tp")]
8009    pub tp: RateType4Choice1,
8010    #[serde(rename = "VldtyRg", skip_serializing_if = "Option::is_none")]
8011    pub vldty_rg: Option<ActiveOrHistoricCurrencyAndAmountRange2>,
8012}
8013
8014impl Rate41 {
8015    pub fn validate(&self) -> Result<(), ValidationError> {
8016        self.tp.validate()?;
8017        if let Some(ref val) = self.vldty_rg {
8018            val.validate()?
8019        }
8020        Ok(())
8021    }
8022}
8023
8024// RateType4Choice1: Rate type expressed, in an other form.
8025#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8026pub struct RateType4Choice1 {
8027    #[serde(rename = "Pctg", skip_serializing_if = "Option::is_none")]
8028    pub pctg: Option<f64>,
8029    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
8030    pub othr: Option<String>,
8031}
8032
8033impl RateType4Choice1 {
8034    pub fn validate(&self) -> Result<(), ValidationError> {
8035        if let Some(ref val) = self.othr {
8036            if val.chars().count() < 1 {
8037                return Err(ValidationError::new(
8038                    1001,
8039                    "othr is shorter than the minimum length of 1".to_string(),
8040                ));
8041            }
8042            if val.chars().count() > 35 {
8043                return Err(ValidationError::new(
8044                    1002,
8045                    "othr exceeds the maximum length of 35".to_string(),
8046                ));
8047            }
8048            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8049            if !pattern.is_match(val) {
8050                return Err(ValidationError::new(
8051                    1005,
8052                    "othr does not match the required pattern".to_string(),
8053                ));
8054            }
8055        }
8056        Ok(())
8057    }
8058}
8059
8060// ReferredDocumentInformation71: Set of elements used to provide the content of the referred document line.
8061#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8062pub struct ReferredDocumentInformation71 {
8063    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
8064    pub tp: Option<ReferredDocumentType41>,
8065    #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
8066    pub nb: Option<String>,
8067    #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
8068    pub rltd_dt: Option<String>,
8069    #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
8070    pub line_dtls: Option<Vec<DocumentLineInformation11>>,
8071}
8072
8073impl ReferredDocumentInformation71 {
8074    pub fn validate(&self) -> Result<(), ValidationError> {
8075        if let Some(ref val) = self.tp {
8076            val.validate()?
8077        }
8078        if let Some(ref val) = self.nb {
8079            if val.chars().count() < 1 {
8080                return Err(ValidationError::new(
8081                    1001,
8082                    "nb is shorter than the minimum length of 1".to_string(),
8083                ));
8084            }
8085            if val.chars().count() > 35 {
8086                return Err(ValidationError::new(
8087                    1002,
8088                    "nb exceeds the maximum length of 35".to_string(),
8089                ));
8090            }
8091            let pattern = Regex::new(
8092                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8093            )
8094            .unwrap();
8095            if !pattern.is_match(val) {
8096                return Err(ValidationError::new(
8097                    1005,
8098                    "nb does not match the required pattern".to_string(),
8099                ));
8100            }
8101        }
8102        if let Some(ref vec) = self.line_dtls {
8103            for item in vec {
8104                item.validate()?
8105            }
8106        }
8107        Ok(())
8108    }
8109}
8110
8111// ReferredDocumentType3Choice1: Proprietary identification of the type of the remittance document.
8112#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8113pub struct ReferredDocumentType3Choice1 {
8114    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
8115    pub cd: Option<DocumentType6Code>,
8116    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8117    pub prtry: Option<String>,
8118}
8119
8120impl ReferredDocumentType3Choice1 {
8121    pub fn validate(&self) -> Result<(), ValidationError> {
8122        if let Some(ref val) = self.cd {
8123            val.validate()?
8124        }
8125        if let Some(ref val) = self.prtry {
8126            if val.chars().count() < 1 {
8127                return Err(ValidationError::new(
8128                    1001,
8129                    "prtry is shorter than the minimum length of 1".to_string(),
8130                ));
8131            }
8132            if val.chars().count() > 35 {
8133                return Err(ValidationError::new(
8134                    1002,
8135                    "prtry exceeds the maximum length of 35".to_string(),
8136                ));
8137            }
8138            let pattern = Regex::new(
8139                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8140            )
8141            .unwrap();
8142            if !pattern.is_match(val) {
8143                return Err(ValidationError::new(
8144                    1005,
8145                    "prtry does not match the required pattern".to_string(),
8146                ));
8147            }
8148        }
8149        Ok(())
8150    }
8151}
8152
8153// ReferredDocumentType41: Identification of the issuer of the reference document type.
8154#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8155pub struct ReferredDocumentType41 {
8156    #[serde(rename = "CdOrPrtry")]
8157    pub cd_or_prtry: ReferredDocumentType3Choice1,
8158    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
8159    pub issr: Option<String>,
8160}
8161
8162impl ReferredDocumentType41 {
8163    pub fn validate(&self) -> Result<(), ValidationError> {
8164        self.cd_or_prtry.validate()?;
8165        if let Some(ref val) = self.issr {
8166            if val.chars().count() < 1 {
8167                return Err(ValidationError::new(
8168                    1001,
8169                    "issr is shorter than the minimum length of 1".to_string(),
8170                ));
8171            }
8172            if val.chars().count() > 35 {
8173                return Err(ValidationError::new(
8174                    1002,
8175                    "issr exceeds the maximum length of 35".to_string(),
8176                ));
8177            }
8178            let pattern = Regex::new(
8179                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8180            )
8181            .unwrap();
8182            if !pattern.is_match(val) {
8183                return Err(ValidationError::new(
8184                    1005,
8185                    "issr does not match the required pattern".to_string(),
8186                ));
8187            }
8188        }
8189        Ok(())
8190    }
8191}
8192
8193// RemittanceAmount21: Amount of money remitted for the referred document.
8194#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8195pub struct RemittanceAmount21 {
8196    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
8197    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8198    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
8199    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType11>>,
8200    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
8201    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8202    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
8203    pub tax_amt: Option<Vec<TaxAmountAndType11>>,
8204    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
8205    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment11>>,
8206    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
8207    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8208}
8209
8210impl RemittanceAmount21 {
8211    pub fn validate(&self) -> Result<(), ValidationError> {
8212        if let Some(ref val) = self.due_pybl_amt {
8213            val.validate()?
8214        }
8215        if let Some(ref vec) = self.dscnt_apld_amt {
8216            for item in vec {
8217                item.validate()?
8218            }
8219        }
8220        if let Some(ref val) = self.cdt_note_amt {
8221            val.validate()?
8222        }
8223        if let Some(ref vec) = self.tax_amt {
8224            for item in vec {
8225                item.validate()?
8226            }
8227        }
8228        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
8229            for item in vec {
8230                item.validate()?
8231            }
8232        }
8233        if let Some(ref val) = self.rmtd_amt {
8234            val.validate()?
8235        }
8236        Ok(())
8237    }
8238}
8239
8240// RemittanceAmount31: Amount of money remitted.
8241#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8242pub struct RemittanceAmount31 {
8243    #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
8244    pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8245    #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
8246    pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType11>>,
8247    #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
8248    pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8249    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
8250    pub tax_amt: Option<Vec<TaxAmountAndType11>>,
8251    #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
8252    pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment11>>,
8253    #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
8254    pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
8255}
8256
8257impl RemittanceAmount31 {
8258    pub fn validate(&self) -> Result<(), ValidationError> {
8259        if let Some(ref val) = self.due_pybl_amt {
8260            val.validate()?
8261        }
8262        if let Some(ref vec) = self.dscnt_apld_amt {
8263            for item in vec {
8264                item.validate()?
8265            }
8266        }
8267        if let Some(ref val) = self.cdt_note_amt {
8268            val.validate()?
8269        }
8270        if let Some(ref vec) = self.tax_amt {
8271            for item in vec {
8272                item.validate()?
8273            }
8274        }
8275        if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
8276            for item in vec {
8277                item.validate()?
8278            }
8279        }
8280        if let Some(ref val) = self.rmtd_amt {
8281            val.validate()?
8282        }
8283        Ok(())
8284    }
8285}
8286
8287// 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.
8288#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8289pub struct RemittanceInformation161 {
8290    #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
8291    pub ustrd: Option<String>,
8292    #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
8293    pub strd: Option<Vec<StructuredRemittanceInformation161>>,
8294}
8295
8296impl RemittanceInformation161 {
8297    pub fn validate(&self) -> Result<(), ValidationError> {
8298        if let Some(ref val) = self.ustrd {
8299            if val.chars().count() < 1 {
8300                return Err(ValidationError::new(
8301                    1001,
8302                    "ustrd is shorter than the minimum length of 1".to_string(),
8303                ));
8304            }
8305            if val.chars().count() > 140 {
8306                return Err(ValidationError::new(
8307                    1002,
8308                    "ustrd exceeds the maximum length of 140".to_string(),
8309                ));
8310            }
8311            let pattern = Regex::new(
8312                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8313            )
8314            .unwrap();
8315            if !pattern.is_match(val) {
8316                return Err(ValidationError::new(
8317                    1005,
8318                    "ustrd does not match the required pattern".to_string(),
8319                ));
8320            }
8321        }
8322        if let Some(ref vec) = self.strd {
8323            for item in vec {
8324                item.validate()?
8325            }
8326        }
8327        Ok(())
8328    }
8329}
8330
8331// RemittanceLocation71: Set of elements used to provide information on the location and/or delivery of the remittance information.
8332#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8333pub struct RemittanceLocation71 {
8334    #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
8335    pub rmt_id: Option<String>,
8336    #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
8337    pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData11>>,
8338}
8339
8340impl RemittanceLocation71 {
8341    pub fn validate(&self) -> Result<(), ValidationError> {
8342        if let Some(ref val) = self.rmt_id {
8343            if val.chars().count() < 1 {
8344                return Err(ValidationError::new(
8345                    1001,
8346                    "rmt_id is shorter than the minimum length of 1".to_string(),
8347                ));
8348            }
8349            if val.chars().count() > 35 {
8350                return Err(ValidationError::new(
8351                    1002,
8352                    "rmt_id exceeds the maximum length of 35".to_string(),
8353                ));
8354            }
8355            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8356            if !pattern.is_match(val) {
8357                return Err(ValidationError::new(
8358                    1005,
8359                    "rmt_id does not match the required pattern".to_string(),
8360                ));
8361            }
8362        }
8363        if let Some(ref vec) = self.rmt_lctn_dtls {
8364            for item in vec {
8365                item.validate()?
8366            }
8367        }
8368        Ok(())
8369    }
8370}
8371
8372// RemittanceLocationData11: Postal address to which an agent is to send the remittance information.
8373#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8374pub struct RemittanceLocationData11 {
8375    #[serde(rename = "Mtd")]
8376    pub mtd: RemittanceLocationMethod2Code,
8377    #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
8378    pub elctrnc_adr: Option<String>,
8379    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
8380    pub pstl_adr: Option<NameAndAddress161>,
8381}
8382
8383impl RemittanceLocationData11 {
8384    pub fn validate(&self) -> Result<(), ValidationError> {
8385        self.mtd.validate()?;
8386        if let Some(ref val) = self.elctrnc_adr {
8387            if val.chars().count() < 1 {
8388                return Err(ValidationError::new(
8389                    1001,
8390                    "elctrnc_adr is shorter than the minimum length of 1".to_string(),
8391                ));
8392            }
8393            if val.chars().count() > 2048 {
8394                return Err(ValidationError::new(
8395                    1002,
8396                    "elctrnc_adr exceeds the maximum length of 2048".to_string(),
8397                ));
8398            }
8399            let pattern = Regex::new(
8400                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8401            )
8402            .unwrap();
8403            if !pattern.is_match(val) {
8404                return Err(ValidationError::new(
8405                    1005,
8406                    "elctrnc_adr does not match the required pattern".to_string(),
8407                ));
8408            }
8409        }
8410        if let Some(ref val) = self.pstl_adr {
8411            val.validate()?
8412        }
8413        Ok(())
8414    }
8415}
8416
8417// RemittanceLocationMethod2Code: Remittance advice information must be sent through by phone as a short message service (SMS).
8418#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8419pub enum RemittanceLocationMethod2Code {
8420    #[default]
8421    #[serde(rename = "FAXI")]
8422    CodeFAXI,
8423    #[serde(rename = "EDIC")]
8424    CodeEDIC,
8425    #[serde(rename = "URID")]
8426    CodeURID,
8427    #[serde(rename = "EMAL")]
8428    CodeEMAL,
8429    #[serde(rename = "POST")]
8430    CodePOST,
8431    #[serde(rename = "SMSM")]
8432    CodeSMSM,
8433}
8434
8435impl RemittanceLocationMethod2Code {
8436    pub fn validate(&self) -> Result<(), ValidationError> {
8437        Ok(())
8438    }
8439}
8440
8441// ReportEntry101: Further details of the entry.
8442#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8443pub struct ReportEntry101 {
8444    #[serde(rename = "NtryRef", skip_serializing_if = "Option::is_none")]
8445    pub ntry_ref: Option<String>,
8446    #[serde(rename = "Amt")]
8447    pub amt: ActiveOrHistoricCurrencyAndAmount,
8448    #[serde(rename = "CdtDbtInd")]
8449    pub cdt_dbt_ind: CreditDebitCode,
8450    #[serde(rename = "RvslInd", skip_serializing_if = "Option::is_none")]
8451    pub rvsl_ind: Option<bool>,
8452    #[serde(rename = "Sts")]
8453    pub sts: EntryStatus1Choice1,
8454    #[serde(rename = "BookgDt", skip_serializing_if = "Option::is_none")]
8455    pub bookg_dt: Option<DateAndDateTime2Choice1>,
8456    #[serde(rename = "ValDt")]
8457    pub val_dt: DateAndDateTime2Choice1,
8458    #[serde(rename = "AcctSvcrRef", skip_serializing_if = "Option::is_none")]
8459    pub acct_svcr_ref: Option<String>,
8460    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
8461    pub avlbty: Option<Vec<CashAvailability1>>,
8462    #[serde(rename = "BkTxCd")]
8463    pub bk_tx_cd: BankTransactionCodeStructure41,
8464    #[serde(rename = "ComssnWvrInd", skip_serializing_if = "Option::is_none")]
8465    pub comssn_wvr_ind: Option<bool>,
8466    #[serde(rename = "AddtlInfInd", skip_serializing_if = "Option::is_none")]
8467    pub addtl_inf_ind: Option<MessageIdentification21>,
8468    #[serde(rename = "AmtDtls", skip_serializing_if = "Option::is_none")]
8469    pub amt_dtls: Option<AmountAndCurrencyExchange31>,
8470    #[serde(rename = "Chrgs", skip_serializing_if = "Option::is_none")]
8471    pub chrgs: Option<Charges61>,
8472    #[serde(rename = "TechInptChanl", skip_serializing_if = "Option::is_none")]
8473    pub tech_inpt_chanl: Option<TechnicalInputChannel1Choice1>,
8474    #[serde(rename = "Intrst", skip_serializing_if = "Option::is_none")]
8475    pub intrst: Option<TransactionInterest41>,
8476    #[serde(rename = "CardTx", skip_serializing_if = "Option::is_none")]
8477    pub card_tx: Option<CardEntry41>,
8478    #[serde(rename = "NtryDtls", skip_serializing_if = "Option::is_none")]
8479    pub ntry_dtls: Option<Vec<EntryDetails91>>,
8480    #[serde(rename = "AddtlNtryInf", skip_serializing_if = "Option::is_none")]
8481    pub addtl_ntry_inf: Option<String>,
8482}
8483
8484impl ReportEntry101 {
8485    pub fn validate(&self) -> Result<(), ValidationError> {
8486        if let Some(ref val) = self.ntry_ref {
8487            if val.chars().count() < 1 {
8488                return Err(ValidationError::new(
8489                    1001,
8490                    "ntry_ref is shorter than the minimum length of 1".to_string(),
8491                ));
8492            }
8493            if val.chars().count() > 35 {
8494                return Err(ValidationError::new(
8495                    1002,
8496                    "ntry_ref exceeds the maximum length of 35".to_string(),
8497                ));
8498            }
8499            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8500            if !pattern.is_match(val) {
8501                return Err(ValidationError::new(
8502                    1005,
8503                    "ntry_ref does not match the required pattern".to_string(),
8504                ));
8505            }
8506        }
8507        self.amt.validate()?;
8508        self.cdt_dbt_ind.validate()?;
8509        self.sts.validate()?;
8510        if let Some(ref val) = self.bookg_dt {
8511            val.validate()?
8512        }
8513        self.val_dt.validate()?;
8514        if let Some(ref val) = self.acct_svcr_ref {
8515            if val.chars().count() < 1 {
8516                return Err(ValidationError::new(
8517                    1001,
8518                    "acct_svcr_ref is shorter than the minimum length of 1".to_string(),
8519                ));
8520            }
8521            if val.chars().count() > 35 {
8522                return Err(ValidationError::new(
8523                    1002,
8524                    "acct_svcr_ref exceeds the maximum length of 35".to_string(),
8525                ));
8526            }
8527            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8528            if !pattern.is_match(val) {
8529                return Err(ValidationError::new(
8530                    1005,
8531                    "acct_svcr_ref does not match the required pattern".to_string(),
8532                ));
8533            }
8534        }
8535        if let Some(ref vec) = self.avlbty {
8536            for item in vec {
8537                item.validate()?
8538            }
8539        }
8540        self.bk_tx_cd.validate()?;
8541        if let Some(ref val) = self.addtl_inf_ind {
8542            val.validate()?
8543        }
8544        if let Some(ref val) = self.amt_dtls {
8545            val.validate()?
8546        }
8547        if let Some(ref val) = self.chrgs {
8548            val.validate()?
8549        }
8550        if let Some(ref val) = self.tech_inpt_chanl {
8551            val.validate()?
8552        }
8553        if let Some(ref val) = self.intrst {
8554            val.validate()?
8555        }
8556        if let Some(ref val) = self.card_tx {
8557            val.validate()?
8558        }
8559        if let Some(ref vec) = self.ntry_dtls {
8560            for item in vec {
8561                item.validate()?
8562            }
8563        }
8564        if let Some(ref val) = self.addtl_ntry_inf {
8565            if val.chars().count() < 1 {
8566                return Err(ValidationError::new(
8567                    1001,
8568                    "addtl_ntry_inf is shorter than the minimum length of 1".to_string(),
8569                ));
8570            }
8571            if val.chars().count() > 500 {
8572                return Err(ValidationError::new(
8573                    1002,
8574                    "addtl_ntry_inf exceeds the maximum length of 500".to_string(),
8575                ));
8576            }
8577            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8578            if !pattern.is_match(val) {
8579                return Err(ValidationError::new(
8580                    1005,
8581                    "addtl_ntry_inf does not match the required pattern".to_string(),
8582                ));
8583            }
8584        }
8585        Ok(())
8586    }
8587}
8588
8589// ReportingSource1Choice1: Reporting source, in a proprietary form.
8590#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8591pub struct ReportingSource1Choice1 {
8592    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
8593    pub cd: Option<String>,
8594    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8595    pub prtry: Option<String>,
8596}
8597
8598impl ReportingSource1Choice1 {
8599    pub fn validate(&self) -> Result<(), ValidationError> {
8600        if let Some(ref val) = self.cd {
8601            if val.chars().count() < 1 {
8602                return Err(ValidationError::new(
8603                    1001,
8604                    "cd is shorter than the minimum length of 1".to_string(),
8605                ));
8606            }
8607            if val.chars().count() > 4 {
8608                return Err(ValidationError::new(
8609                    1002,
8610                    "cd exceeds the maximum length of 4".to_string(),
8611                ));
8612            }
8613        }
8614        if let Some(ref val) = self.prtry {
8615            if val.chars().count() < 1 {
8616                return Err(ValidationError::new(
8617                    1001,
8618                    "prtry is shorter than the minimum length of 1".to_string(),
8619                ));
8620            }
8621            if val.chars().count() > 35 {
8622                return Err(ValidationError::new(
8623                    1002,
8624                    "prtry exceeds the maximum length of 35".to_string(),
8625                ));
8626            }
8627            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8628            if !pattern.is_match(val) {
8629                return Err(ValidationError::new(
8630                    1005,
8631                    "prtry does not match the required pattern".to_string(),
8632                ));
8633            }
8634        }
8635        Ok(())
8636    }
8637}
8638
8639// ReturnReason5Choice1: Reason for the return, in a proprietary form.
8640#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8641pub struct ReturnReason5Choice1 {
8642    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
8643    pub cd: Option<String>,
8644    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
8645    pub prtry: Option<String>,
8646}
8647
8648impl ReturnReason5Choice1 {
8649    pub fn validate(&self) -> Result<(), ValidationError> {
8650        if let Some(ref val) = self.cd {
8651            if val.chars().count() < 1 {
8652                return Err(ValidationError::new(
8653                    1001,
8654                    "cd is shorter than the minimum length of 1".to_string(),
8655                ));
8656            }
8657            if val.chars().count() > 4 {
8658                return Err(ValidationError::new(
8659                    1002,
8660                    "cd exceeds the maximum length of 4".to_string(),
8661                ));
8662            }
8663        }
8664        if let Some(ref val) = self.prtry {
8665            if val.chars().count() < 1 {
8666                return Err(ValidationError::new(
8667                    1001,
8668                    "prtry is shorter than the minimum length of 1".to_string(),
8669                ));
8670            }
8671            if val.chars().count() > 35 {
8672                return Err(ValidationError::new(
8673                    1002,
8674                    "prtry exceeds the maximum length of 35".to_string(),
8675                ));
8676            }
8677            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8678            if !pattern.is_match(val) {
8679                return Err(ValidationError::new(
8680                    1005,
8681                    "prtry does not match the required pattern".to_string(),
8682                ));
8683            }
8684        }
8685        Ok(())
8686    }
8687}
8688
8689// SecuritiesAccount191: Description of the account.
8690#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8691pub struct SecuritiesAccount191 {
8692    #[serde(rename = "Id")]
8693    pub id: String,
8694    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
8695    pub tp: Option<GenericIdentification301>,
8696    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
8697    pub nm: Option<String>,
8698}
8699
8700impl SecuritiesAccount191 {
8701    pub fn validate(&self) -> Result<(), ValidationError> {
8702        if self.id.chars().count() < 1 {
8703            return Err(ValidationError::new(
8704                1001,
8705                "id is shorter than the minimum length of 1".to_string(),
8706            ));
8707        }
8708        if self.id.chars().count() > 35 {
8709            return Err(ValidationError::new(
8710                1002,
8711                "id exceeds the maximum length of 35".to_string(),
8712            ));
8713        }
8714        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8715        if !pattern.is_match(&self.id) {
8716            return Err(ValidationError::new(
8717                1005,
8718                "id does not match the required pattern".to_string(),
8719            ));
8720        }
8721        if let Some(ref val) = self.tp {
8722            val.validate()?
8723        }
8724        if let Some(ref val) = self.nm {
8725            if val.chars().count() < 1 {
8726                return Err(ValidationError::new(
8727                    1001,
8728                    "nm is shorter than the minimum length of 1".to_string(),
8729                ));
8730            }
8731            if val.chars().count() > 70 {
8732                return Err(ValidationError::new(
8733                    1002,
8734                    "nm exceeds the maximum length of 70".to_string(),
8735                ));
8736            }
8737            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8738            if !pattern.is_match(val) {
8739                return Err(ValidationError::new(
8740                    1005,
8741                    "nm does not match the required pattern".to_string(),
8742                ));
8743            }
8744        }
8745        Ok(())
8746    }
8747}
8748
8749// SecurityIdentification191: Textual description of a security instrument.
8750#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8751pub struct SecurityIdentification191 {
8752    #[serde(rename = "ISIN", skip_serializing_if = "Option::is_none")]
8753    pub isin: Option<String>,
8754    #[serde(rename = "OthrId", skip_serializing_if = "Option::is_none")]
8755    pub othr_id: Option<Vec<OtherIdentification11>>,
8756    #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
8757    pub desc: Option<String>,
8758}
8759
8760impl SecurityIdentification191 {
8761    pub fn validate(&self) -> Result<(), ValidationError> {
8762        if let Some(ref val) = self.isin {
8763            let pattern = Regex::new("[A-Z]{2,2}[A-Z0-9]{9,9}[0-9]{1,1}").unwrap();
8764            if !pattern.is_match(val) {
8765                return Err(ValidationError::new(
8766                    1005,
8767                    "isin does not match the required pattern".to_string(),
8768                ));
8769            }
8770        }
8771        if let Some(ref vec) = self.othr_id {
8772            for item in vec {
8773                item.validate()?
8774            }
8775        }
8776        if let Some(ref val) = self.desc {
8777            if val.chars().count() < 1 {
8778                return Err(ValidationError::new(
8779                    1001,
8780                    "desc is shorter than the minimum length of 1".to_string(),
8781                ));
8782            }
8783            if val.chars().count() > 140 {
8784                return Err(ValidationError::new(
8785                    1002,
8786                    "desc exceeds the maximum length of 140".to_string(),
8787                ));
8788            }
8789            let pattern = Regex::new(
8790                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
8791            )
8792            .unwrap();
8793            if !pattern.is_match(val) {
8794                return Err(ValidationError::new(
8795                    1005,
8796                    "desc does not match the required pattern".to_string(),
8797                ));
8798            }
8799        }
8800        Ok(())
8801    }
8802}
8803
8804// SequenceRange1Choice1: Specified sequence to be excluded.
8805#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8806pub struct SequenceRange1Choice1 {
8807    #[serde(rename = "FrSeq", skip_serializing_if = "Option::is_none")]
8808    pub fr_seq: Option<String>,
8809    #[serde(rename = "ToSeq", skip_serializing_if = "Option::is_none")]
8810    pub to_seq: Option<String>,
8811    #[serde(rename = "FrToSeq", skip_serializing_if = "Option::is_none")]
8812    pub fr_to_seq: Option<Vec<SequenceRange11>>,
8813    #[serde(rename = "EQSeq", skip_serializing_if = "Option::is_none")]
8814    pub eq_seq: Option<Vec<String>>,
8815    #[serde(rename = "NEQSeq", skip_serializing_if = "Option::is_none")]
8816    pub neq_seq: Option<Vec<String>>,
8817}
8818
8819impl SequenceRange1Choice1 {
8820    pub fn validate(&self) -> Result<(), ValidationError> {
8821        if let Some(ref val) = self.fr_seq {
8822            if val.chars().count() < 1 {
8823                return Err(ValidationError::new(
8824                    1001,
8825                    "fr_seq is shorter than the minimum length of 1".to_string(),
8826                ));
8827            }
8828            if val.chars().count() > 35 {
8829                return Err(ValidationError::new(
8830                    1002,
8831                    "fr_seq exceeds the maximum length of 35".to_string(),
8832                ));
8833            }
8834            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8835            if !pattern.is_match(val) {
8836                return Err(ValidationError::new(
8837                    1005,
8838                    "fr_seq does not match the required pattern".to_string(),
8839                ));
8840            }
8841        }
8842        if let Some(ref val) = self.to_seq {
8843            if val.chars().count() < 1 {
8844                return Err(ValidationError::new(
8845                    1001,
8846                    "to_seq is shorter than the minimum length of 1".to_string(),
8847                ));
8848            }
8849            if val.chars().count() > 35 {
8850                return Err(ValidationError::new(
8851                    1002,
8852                    "to_seq exceeds the maximum length of 35".to_string(),
8853                ));
8854            }
8855            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8856            if !pattern.is_match(val) {
8857                return Err(ValidationError::new(
8858                    1005,
8859                    "to_seq does not match the required pattern".to_string(),
8860                ));
8861            }
8862        }
8863        if let Some(ref vec) = self.fr_to_seq {
8864            for item in vec {
8865                item.validate()?
8866            }
8867        }
8868        if let Some(ref vec) = self.eq_seq {
8869            for item in vec {
8870                if item.chars().count() < 1 {
8871                    return Err(ValidationError::new(
8872                        1001,
8873                        "eq_seq is shorter than the minimum length of 1".to_string(),
8874                    ));
8875                }
8876                if item.chars().count() > 35 {
8877                    return Err(ValidationError::new(
8878                        1002,
8879                        "eq_seq exceeds the maximum length of 35".to_string(),
8880                    ));
8881                }
8882                let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8883                if !pattern.is_match(&item) {
8884                    return Err(ValidationError::new(
8885                        1005,
8886                        "eq_seq does not match the required pattern".to_string(),
8887                    ));
8888                }
8889            }
8890        }
8891        if let Some(ref vec) = self.neq_seq {
8892            for item in vec {
8893                if item.chars().count() < 1 {
8894                    return Err(ValidationError::new(
8895                        1001,
8896                        "neq_seq is shorter than the minimum length of 1".to_string(),
8897                    ));
8898                }
8899                if item.chars().count() > 35 {
8900                    return Err(ValidationError::new(
8901                        1002,
8902                        "neq_seq exceeds the maximum length of 35".to_string(),
8903                    ));
8904                }
8905                let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8906                if !pattern.is_match(&item) {
8907                    return Err(ValidationError::new(
8908                        1005,
8909                        "neq_seq does not match the required pattern".to_string(),
8910                    ));
8911                }
8912            }
8913        }
8914        Ok(())
8915    }
8916}
8917
8918// SequenceRange11: End sequence of the range.
8919#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8920pub struct SequenceRange11 {
8921    #[serde(rename = "FrSeq")]
8922    pub fr_seq: String,
8923    #[serde(rename = "ToSeq")]
8924    pub to_seq: String,
8925}
8926
8927impl SequenceRange11 {
8928    pub fn validate(&self) -> Result<(), ValidationError> {
8929        if self.fr_seq.chars().count() < 1 {
8930            return Err(ValidationError::new(
8931                1001,
8932                "fr_seq is shorter than the minimum length of 1".to_string(),
8933            ));
8934        }
8935        if self.fr_seq.chars().count() > 35 {
8936            return Err(ValidationError::new(
8937                1002,
8938                "fr_seq exceeds the maximum length of 35".to_string(),
8939            ));
8940        }
8941        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8942        if !pattern.is_match(&self.fr_seq) {
8943            return Err(ValidationError::new(
8944                1005,
8945                "fr_seq does not match the required pattern".to_string(),
8946            ));
8947        }
8948        if self.to_seq.chars().count() < 1 {
8949            return Err(ValidationError::new(
8950                1001,
8951                "to_seq is shorter than the minimum length of 1".to_string(),
8952            ));
8953        }
8954        if self.to_seq.chars().count() > 35 {
8955            return Err(ValidationError::new(
8956                1002,
8957                "to_seq exceeds the maximum length of 35".to_string(),
8958            ));
8959        }
8960        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
8961        if !pattern.is_match(&self.to_seq) {
8962            return Err(ValidationError::new(
8963                1005,
8964                "to_seq does not match the required pattern".to_string(),
8965            ));
8966        }
8967        Ok(())
8968    }
8969}
8970
8971// StructuredRemittanceInformation161: Additional information, in free text form, to complement the structured remittance information.
8972#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
8973pub struct StructuredRemittanceInformation161 {
8974    #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
8975    pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation71>>,
8976    #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
8977    pub rfrd_doc_amt: Option<RemittanceAmount21>,
8978    #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
8979    pub cdtr_ref_inf: Option<CreditorReferenceInformation21>,
8980    #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
8981    pub invcr: Option<PartyIdentification1353>,
8982    #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
8983    pub invcee: Option<PartyIdentification1353>,
8984    #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
8985    pub tax_rmt: Option<TaxInformation71>,
8986    #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
8987    pub grnshmt_rmt: Option<Garnishment31>,
8988    #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
8989    pub addtl_rmt_inf: Option<Vec<String>>,
8990}
8991
8992impl StructuredRemittanceInformation161 {
8993    pub fn validate(&self) -> Result<(), ValidationError> {
8994        if let Some(ref vec) = self.rfrd_doc_inf {
8995            for item in vec {
8996                item.validate()?
8997            }
8998        }
8999        if let Some(ref val) = self.rfrd_doc_amt {
9000            val.validate()?
9001        }
9002        if let Some(ref val) = self.cdtr_ref_inf {
9003            val.validate()?
9004        }
9005        if let Some(ref val) = self.invcr {
9006            val.validate()?
9007        }
9008        if let Some(ref val) = self.invcee {
9009            val.validate()?
9010        }
9011        if let Some(ref val) = self.tax_rmt {
9012            val.validate()?
9013        }
9014        if let Some(ref val) = self.grnshmt_rmt {
9015            val.validate()?
9016        }
9017        if let Some(ref vec) = self.addtl_rmt_inf {
9018            for item in vec {
9019                if item.chars().count() < 1 {
9020                    return Err(ValidationError::new(
9021                        1001,
9022                        "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
9023                    ));
9024                }
9025                if item.chars().count() > 140 {
9026                    return Err(ValidationError::new(
9027                        1002,
9028                        "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
9029                    ));
9030                }
9031                let pattern = Regex::new(
9032                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9033                )
9034                .unwrap();
9035                if !pattern.is_match(&item) {
9036                    return Err(ValidationError::new(
9037                        1005,
9038                        "addtl_rmt_inf does not match the required pattern".to_string(),
9039                    ));
9040                }
9041            }
9042        }
9043        Ok(())
9044    }
9045}
9046
9047// TaxAmount2: Set of elements used to provide details on the tax period and amount.
9048#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9049pub struct TaxAmount2 {
9050    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
9051    pub rate: Option<f64>,
9052    #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
9053    pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9054    #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
9055    pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9056    #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
9057    pub dtls: Option<Vec<TaxRecordDetails2>>,
9058}
9059
9060impl TaxAmount2 {
9061    pub fn validate(&self) -> Result<(), ValidationError> {
9062        if let Some(ref val) = self.taxbl_base_amt {
9063            val.validate()?
9064        }
9065        if let Some(ref val) = self.ttl_amt {
9066            val.validate()?
9067        }
9068        if let Some(ref vec) = self.dtls {
9069            for item in vec {
9070                item.validate()?
9071            }
9072        }
9073        Ok(())
9074    }
9075}
9076
9077// TaxAmountAndType11: Amount of money, which has been typed.
9078#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9079pub struct TaxAmountAndType11 {
9080    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
9081    pub tp: Option<TaxAmountType1Choice1>,
9082    #[serde(rename = "Amt")]
9083    pub amt: ActiveOrHistoricCurrencyAndAmount,
9084}
9085
9086impl TaxAmountAndType11 {
9087    pub fn validate(&self) -> Result<(), ValidationError> {
9088        if let Some(ref val) = self.tp {
9089            val.validate()?
9090        }
9091        self.amt.validate()?;
9092        Ok(())
9093    }
9094}
9095
9096// TaxAmountType1Choice1: Specifies the amount type, in a free-text form.
9097#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9098pub struct TaxAmountType1Choice1 {
9099    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
9100    pub cd: Option<String>,
9101    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
9102    pub prtry: Option<String>,
9103}
9104
9105impl TaxAmountType1Choice1 {
9106    pub fn validate(&self) -> Result<(), ValidationError> {
9107        if let Some(ref val) = self.cd {
9108            if val.chars().count() < 1 {
9109                return Err(ValidationError::new(
9110                    1001,
9111                    "cd is shorter than the minimum length of 1".to_string(),
9112                ));
9113            }
9114            if val.chars().count() > 4 {
9115                return Err(ValidationError::new(
9116                    1002,
9117                    "cd exceeds the maximum length of 4".to_string(),
9118                ));
9119            }
9120        }
9121        if let Some(ref val) = self.prtry {
9122            if val.chars().count() < 1 {
9123                return Err(ValidationError::new(
9124                    1001,
9125                    "prtry is shorter than the minimum length of 1".to_string(),
9126                ));
9127            }
9128            if val.chars().count() > 35 {
9129                return Err(ValidationError::new(
9130                    1002,
9131                    "prtry exceeds the maximum length of 35".to_string(),
9132                ));
9133            }
9134            let pattern = Regex::new(
9135                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9136            )
9137            .unwrap();
9138            if !pattern.is_match(val) {
9139                return Err(ValidationError::new(
9140                    1005,
9141                    "prtry does not match the required pattern".to_string(),
9142                ));
9143            }
9144        }
9145        Ok(())
9146    }
9147}
9148
9149// TaxAuthorisation11: Name of the debtor or the debtor's authorised representative.
9150#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9151pub struct TaxAuthorisation11 {
9152    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
9153    pub titl: Option<String>,
9154    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
9155    pub nm: Option<String>,
9156}
9157
9158impl TaxAuthorisation11 {
9159    pub fn validate(&self) -> Result<(), ValidationError> {
9160        if let Some(ref val) = self.titl {
9161            if val.chars().count() < 1 {
9162                return Err(ValidationError::new(
9163                    1001,
9164                    "titl is shorter than the minimum length of 1".to_string(),
9165                ));
9166            }
9167            if val.chars().count() > 35 {
9168                return Err(ValidationError::new(
9169                    1002,
9170                    "titl exceeds the maximum length of 35".to_string(),
9171                ));
9172            }
9173            let pattern = Regex::new(
9174                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9175            )
9176            .unwrap();
9177            if !pattern.is_match(val) {
9178                return Err(ValidationError::new(
9179                    1005,
9180                    "titl does not match the required pattern".to_string(),
9181                ));
9182            }
9183        }
9184        if let Some(ref val) = self.nm {
9185            if val.chars().count() < 1 {
9186                return Err(ValidationError::new(
9187                    1001,
9188                    "nm is shorter than the minimum length of 1".to_string(),
9189                ));
9190            }
9191            if val.chars().count() > 140 {
9192                return Err(ValidationError::new(
9193                    1002,
9194                    "nm exceeds the maximum length of 140".to_string(),
9195                ));
9196            }
9197            let pattern = Regex::new(
9198                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9199            )
9200            .unwrap();
9201            if !pattern.is_match(val) {
9202                return Err(ValidationError::new(
9203                    1005,
9204                    "nm does not match the required pattern".to_string(),
9205                ));
9206            }
9207        }
9208        Ok(())
9209    }
9210}
9211
9212// TaxAuthorisation12: Name of the debtor or the debtor's authorised representative.
9213#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9214pub struct TaxAuthorisation12 {
9215    #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
9216    pub titl: Option<String>,
9217    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
9218    pub nm: Option<String>,
9219}
9220
9221impl TaxAuthorisation12 {
9222    pub fn validate(&self) -> Result<(), ValidationError> {
9223        if let Some(ref val) = self.titl {
9224            if val.chars().count() < 1 {
9225                return Err(ValidationError::new(
9226                    1001,
9227                    "titl is shorter than the minimum length of 1".to_string(),
9228                ));
9229            }
9230            if val.chars().count() > 35 {
9231                return Err(ValidationError::new(
9232                    1002,
9233                    "titl exceeds the maximum length of 35".to_string(),
9234                ));
9235            }
9236            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9237            if !pattern.is_match(val) {
9238                return Err(ValidationError::new(
9239                    1005,
9240                    "titl does not match the required pattern".to_string(),
9241                ));
9242            }
9243        }
9244        if let Some(ref val) = self.nm {
9245            if val.chars().count() < 1 {
9246                return Err(ValidationError::new(
9247                    1001,
9248                    "nm is shorter than the minimum length of 1".to_string(),
9249                ));
9250            }
9251            if val.chars().count() > 140 {
9252                return Err(ValidationError::new(
9253                    1002,
9254                    "nm exceeds the maximum length of 140".to_string(),
9255                ));
9256            }
9257            let pattern = Regex::new(
9258                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9259            )
9260            .unwrap();
9261            if !pattern.is_match(val) {
9262                return Err(ValidationError::new(
9263                    1005,
9264                    "nm does not match the required pattern".to_string(),
9265                ));
9266            }
9267        }
9268        Ok(())
9269    }
9270}
9271
9272// TaxCharges21: Amount of money resulting from the calculation of the tax.
9273#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9274pub struct TaxCharges21 {
9275    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
9276    pub id: Option<String>,
9277    #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
9278    pub rate: Option<f64>,
9279    #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
9280    pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9281}
9282
9283impl TaxCharges21 {
9284    pub fn validate(&self) -> Result<(), ValidationError> {
9285        if let Some(ref val) = self.id {
9286            if val.chars().count() < 1 {
9287                return Err(ValidationError::new(
9288                    1001,
9289                    "id is shorter than the minimum length of 1".to_string(),
9290                ));
9291            }
9292            if val.chars().count() > 35 {
9293                return Err(ValidationError::new(
9294                    1002,
9295                    "id exceeds the maximum length of 35".to_string(),
9296                ));
9297            }
9298            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9299            if !pattern.is_match(val) {
9300                return Err(ValidationError::new(
9301                    1005,
9302                    "id does not match the required pattern".to_string(),
9303                ));
9304            }
9305        }
9306        if let Some(ref val) = self.amt {
9307            val.validate()?
9308        }
9309        Ok(())
9310    }
9311}
9312
9313// TaxInformation71: Record of tax details.
9314#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9315pub struct TaxInformation71 {
9316    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
9317    pub cdtr: Option<TaxParty11>,
9318    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
9319    pub dbtr: Option<TaxParty21>,
9320    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
9321    pub ultmt_dbtr: Option<TaxParty21>,
9322    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
9323    pub admstn_zone: Option<String>,
9324    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
9325    pub ref_nb: Option<String>,
9326    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
9327    pub mtd: Option<String>,
9328    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
9329    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9330    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
9331    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9332    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
9333    pub dt: Option<String>,
9334    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
9335    pub seq_nb: Option<f64>,
9336    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
9337    pub rcrd: Option<Vec<TaxRecord21>>,
9338}
9339
9340impl TaxInformation71 {
9341    pub fn validate(&self) -> Result<(), ValidationError> {
9342        if let Some(ref val) = self.cdtr {
9343            val.validate()?
9344        }
9345        if let Some(ref val) = self.dbtr {
9346            val.validate()?
9347        }
9348        if let Some(ref val) = self.ultmt_dbtr {
9349            val.validate()?
9350        }
9351        if let Some(ref val) = self.admstn_zone {
9352            if val.chars().count() < 1 {
9353                return Err(ValidationError::new(
9354                    1001,
9355                    "admstn_zone is shorter than the minimum length of 1".to_string(),
9356                ));
9357            }
9358            if val.chars().count() > 35 {
9359                return Err(ValidationError::new(
9360                    1002,
9361                    "admstn_zone exceeds the maximum length of 35".to_string(),
9362                ));
9363            }
9364            let pattern = Regex::new(
9365                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9366            )
9367            .unwrap();
9368            if !pattern.is_match(val) {
9369                return Err(ValidationError::new(
9370                    1005,
9371                    "admstn_zone does not match the required pattern".to_string(),
9372                ));
9373            }
9374        }
9375        if let Some(ref val) = self.ref_nb {
9376            if val.chars().count() < 1 {
9377                return Err(ValidationError::new(
9378                    1001,
9379                    "ref_nb is shorter than the minimum length of 1".to_string(),
9380                ));
9381            }
9382            if val.chars().count() > 140 {
9383                return Err(ValidationError::new(
9384                    1002,
9385                    "ref_nb exceeds the maximum length of 140".to_string(),
9386                ));
9387            }
9388            let pattern = Regex::new(
9389                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9390            )
9391            .unwrap();
9392            if !pattern.is_match(val) {
9393                return Err(ValidationError::new(
9394                    1005,
9395                    "ref_nb does not match the required pattern".to_string(),
9396                ));
9397            }
9398        }
9399        if let Some(ref val) = self.mtd {
9400            if val.chars().count() < 1 {
9401                return Err(ValidationError::new(
9402                    1001,
9403                    "mtd is shorter than the minimum length of 1".to_string(),
9404                ));
9405            }
9406            if val.chars().count() > 35 {
9407                return Err(ValidationError::new(
9408                    1002,
9409                    "mtd exceeds the maximum length of 35".to_string(),
9410                ));
9411            }
9412            let pattern = Regex::new(
9413                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9414            )
9415            .unwrap();
9416            if !pattern.is_match(val) {
9417                return Err(ValidationError::new(
9418                    1005,
9419                    "mtd does not match the required pattern".to_string(),
9420                ));
9421            }
9422        }
9423        if let Some(ref val) = self.ttl_taxbl_base_amt {
9424            val.validate()?
9425        }
9426        if let Some(ref val) = self.ttl_tax_amt {
9427            val.validate()?
9428        }
9429        if let Some(ref vec) = self.rcrd {
9430            for item in vec {
9431                item.validate()?
9432            }
9433        }
9434        Ok(())
9435    }
9436}
9437
9438// TaxInformation81: Record of tax details.
9439#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9440pub struct TaxInformation81 {
9441    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
9442    pub cdtr: Option<TaxParty12>,
9443    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
9444    pub dbtr: Option<TaxParty22>,
9445    #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
9446    pub admstn_zone: Option<String>,
9447    #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
9448    pub ref_nb: Option<String>,
9449    #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
9450    pub mtd: Option<String>,
9451    #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
9452    pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9453    #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
9454    pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
9455    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
9456    pub dt: Option<String>,
9457    #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
9458    pub seq_nb: Option<f64>,
9459    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
9460    pub rcrd: Option<Vec<TaxRecord22>>,
9461}
9462
9463impl TaxInformation81 {
9464    pub fn validate(&self) -> Result<(), ValidationError> {
9465        if let Some(ref val) = self.cdtr {
9466            val.validate()?
9467        }
9468        if let Some(ref val) = self.dbtr {
9469            val.validate()?
9470        }
9471        if let Some(ref val) = self.admstn_zone {
9472            if val.chars().count() < 1 {
9473                return Err(ValidationError::new(
9474                    1001,
9475                    "admstn_zone is shorter than the minimum length of 1".to_string(),
9476                ));
9477            }
9478            if val.chars().count() > 35 {
9479                return Err(ValidationError::new(
9480                    1002,
9481                    "admstn_zone exceeds the maximum length of 35".to_string(),
9482                ));
9483            }
9484            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9485            if !pattern.is_match(val) {
9486                return Err(ValidationError::new(
9487                    1005,
9488                    "admstn_zone does not match the required pattern".to_string(),
9489                ));
9490            }
9491        }
9492        if let Some(ref val) = self.ref_nb {
9493            if val.chars().count() < 1 {
9494                return Err(ValidationError::new(
9495                    1001,
9496                    "ref_nb is shorter than the minimum length of 1".to_string(),
9497                ));
9498            }
9499            if val.chars().count() > 140 {
9500                return Err(ValidationError::new(
9501                    1002,
9502                    "ref_nb exceeds the maximum length of 140".to_string(),
9503                ));
9504            }
9505            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.\\n\\r,'\\+ ]{1,140}").unwrap();
9506            if !pattern.is_match(val) {
9507                return Err(ValidationError::new(
9508                    1005,
9509                    "ref_nb does not match the required pattern".to_string(),
9510                ));
9511            }
9512        }
9513        if let Some(ref val) = self.mtd {
9514            if val.chars().count() < 1 {
9515                return Err(ValidationError::new(
9516                    1001,
9517                    "mtd is shorter than the minimum length of 1".to_string(),
9518                ));
9519            }
9520            if val.chars().count() > 35 {
9521                return Err(ValidationError::new(
9522                    1002,
9523                    "mtd exceeds the maximum length of 35".to_string(),
9524                ));
9525            }
9526            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9527            if !pattern.is_match(val) {
9528                return Err(ValidationError::new(
9529                    1005,
9530                    "mtd does not match the required pattern".to_string(),
9531                ));
9532            }
9533        }
9534        if let Some(ref val) = self.ttl_taxbl_base_amt {
9535            val.validate()?
9536        }
9537        if let Some(ref val) = self.ttl_tax_amt {
9538            val.validate()?
9539        }
9540        if let Some(ref vec) = self.rcrd {
9541            for item in vec {
9542                item.validate()?
9543            }
9544        }
9545        Ok(())
9546    }
9547}
9548
9549// TaxParty11: Type of tax payer.
9550#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9551pub struct TaxParty11 {
9552    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
9553    pub tax_id: Option<String>,
9554    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
9555    pub regn_id: Option<String>,
9556    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
9557    pub tax_tp: Option<String>,
9558}
9559
9560impl TaxParty11 {
9561    pub fn validate(&self) -> Result<(), ValidationError> {
9562        if let Some(ref val) = self.tax_id {
9563            if val.chars().count() < 1 {
9564                return Err(ValidationError::new(
9565                    1001,
9566                    "tax_id is shorter than the minimum length of 1".to_string(),
9567                ));
9568            }
9569            if val.chars().count() > 35 {
9570                return Err(ValidationError::new(
9571                    1002,
9572                    "tax_id exceeds the maximum length of 35".to_string(),
9573                ));
9574            }
9575            let pattern = Regex::new(
9576                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9577            )
9578            .unwrap();
9579            if !pattern.is_match(val) {
9580                return Err(ValidationError::new(
9581                    1005,
9582                    "tax_id does not match the required pattern".to_string(),
9583                ));
9584            }
9585        }
9586        if let Some(ref val) = self.regn_id {
9587            if val.chars().count() < 1 {
9588                return Err(ValidationError::new(
9589                    1001,
9590                    "regn_id is shorter than the minimum length of 1".to_string(),
9591                ));
9592            }
9593            if val.chars().count() > 35 {
9594                return Err(ValidationError::new(
9595                    1002,
9596                    "regn_id exceeds the maximum length of 35".to_string(),
9597                ));
9598            }
9599            let pattern = Regex::new(
9600                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9601            )
9602            .unwrap();
9603            if !pattern.is_match(val) {
9604                return Err(ValidationError::new(
9605                    1005,
9606                    "regn_id does not match the required pattern".to_string(),
9607                ));
9608            }
9609        }
9610        if let Some(ref val) = self.tax_tp {
9611            if val.chars().count() < 1 {
9612                return Err(ValidationError::new(
9613                    1001,
9614                    "tax_tp is shorter than the minimum length of 1".to_string(),
9615                ));
9616            }
9617            if val.chars().count() > 35 {
9618                return Err(ValidationError::new(
9619                    1002,
9620                    "tax_tp exceeds the maximum length of 35".to_string(),
9621                ));
9622            }
9623            let pattern = Regex::new(
9624                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9625            )
9626            .unwrap();
9627            if !pattern.is_match(val) {
9628                return Err(ValidationError::new(
9629                    1005,
9630                    "tax_tp does not match the required pattern".to_string(),
9631                ));
9632            }
9633        }
9634        Ok(())
9635    }
9636}
9637
9638// TaxParty12: Type of tax payer.
9639#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9640pub struct TaxParty12 {
9641    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
9642    pub tax_id: Option<String>,
9643    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
9644    pub regn_id: Option<String>,
9645    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
9646    pub tax_tp: Option<String>,
9647}
9648
9649impl TaxParty12 {
9650    pub fn validate(&self) -> Result<(), ValidationError> {
9651        if let Some(ref val) = self.tax_id {
9652            if val.chars().count() < 1 {
9653                return Err(ValidationError::new(
9654                    1001,
9655                    "tax_id is shorter than the minimum length of 1".to_string(),
9656                ));
9657            }
9658            if val.chars().count() > 35 {
9659                return Err(ValidationError::new(
9660                    1002,
9661                    "tax_id exceeds the maximum length of 35".to_string(),
9662                ));
9663            }
9664            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9665            if !pattern.is_match(val) {
9666                return Err(ValidationError::new(
9667                    1005,
9668                    "tax_id does not match the required pattern".to_string(),
9669                ));
9670            }
9671        }
9672        if let Some(ref val) = self.regn_id {
9673            if val.chars().count() < 1 {
9674                return Err(ValidationError::new(
9675                    1001,
9676                    "regn_id is shorter than the minimum length of 1".to_string(),
9677                ));
9678            }
9679            if val.chars().count() > 35 {
9680                return Err(ValidationError::new(
9681                    1002,
9682                    "regn_id exceeds the maximum length of 35".to_string(),
9683                ));
9684            }
9685            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9686            if !pattern.is_match(val) {
9687                return Err(ValidationError::new(
9688                    1005,
9689                    "regn_id does not match the required pattern".to_string(),
9690                ));
9691            }
9692        }
9693        if let Some(ref val) = self.tax_tp {
9694            if val.chars().count() < 1 {
9695                return Err(ValidationError::new(
9696                    1001,
9697                    "tax_tp is shorter than the minimum length of 1".to_string(),
9698                ));
9699            }
9700            if val.chars().count() > 35 {
9701                return Err(ValidationError::new(
9702                    1002,
9703                    "tax_tp exceeds the maximum length of 35".to_string(),
9704                ));
9705            }
9706            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9707            if !pattern.is_match(val) {
9708                return Err(ValidationError::new(
9709                    1005,
9710                    "tax_tp does not match the required pattern".to_string(),
9711                ));
9712            }
9713        }
9714        Ok(())
9715    }
9716}
9717
9718// TaxParty21: Details of the authorised tax paying party.
9719#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9720pub struct TaxParty21 {
9721    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
9722    pub tax_id: Option<String>,
9723    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
9724    pub regn_id: Option<String>,
9725    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
9726    pub tax_tp: Option<String>,
9727    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
9728    pub authstn: Option<TaxAuthorisation11>,
9729}
9730
9731impl TaxParty21 {
9732    pub fn validate(&self) -> Result<(), ValidationError> {
9733        if let Some(ref val) = self.tax_id {
9734            if val.chars().count() < 1 {
9735                return Err(ValidationError::new(
9736                    1001,
9737                    "tax_id is shorter than the minimum length of 1".to_string(),
9738                ));
9739            }
9740            if val.chars().count() > 35 {
9741                return Err(ValidationError::new(
9742                    1002,
9743                    "tax_id exceeds the maximum length of 35".to_string(),
9744                ));
9745            }
9746            let pattern = Regex::new(
9747                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9748            )
9749            .unwrap();
9750            if !pattern.is_match(val) {
9751                return Err(ValidationError::new(
9752                    1005,
9753                    "tax_id does not match the required pattern".to_string(),
9754                ));
9755            }
9756        }
9757        if let Some(ref val) = self.regn_id {
9758            if val.chars().count() < 1 {
9759                return Err(ValidationError::new(
9760                    1001,
9761                    "regn_id is shorter than the minimum length of 1".to_string(),
9762                ));
9763            }
9764            if val.chars().count() > 35 {
9765                return Err(ValidationError::new(
9766                    1002,
9767                    "regn_id exceeds the maximum length of 35".to_string(),
9768                ));
9769            }
9770            let pattern = Regex::new(
9771                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9772            )
9773            .unwrap();
9774            if !pattern.is_match(val) {
9775                return Err(ValidationError::new(
9776                    1005,
9777                    "regn_id does not match the required pattern".to_string(),
9778                ));
9779            }
9780        }
9781        if let Some(ref val) = self.tax_tp {
9782            if val.chars().count() < 1 {
9783                return Err(ValidationError::new(
9784                    1001,
9785                    "tax_tp is shorter than the minimum length of 1".to_string(),
9786                ));
9787            }
9788            if val.chars().count() > 35 {
9789                return Err(ValidationError::new(
9790                    1002,
9791                    "tax_tp exceeds the maximum length of 35".to_string(),
9792                ));
9793            }
9794            let pattern = Regex::new(
9795                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9796            )
9797            .unwrap();
9798            if !pattern.is_match(val) {
9799                return Err(ValidationError::new(
9800                    1005,
9801                    "tax_tp does not match the required pattern".to_string(),
9802                ));
9803            }
9804        }
9805        if let Some(ref val) = self.authstn {
9806            val.validate()?
9807        }
9808        Ok(())
9809    }
9810}
9811
9812// TaxParty22: Details of the authorised tax paying party.
9813#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9814pub struct TaxParty22 {
9815    #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
9816    pub tax_id: Option<String>,
9817    #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
9818    pub regn_id: Option<String>,
9819    #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
9820    pub tax_tp: Option<String>,
9821    #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
9822    pub authstn: Option<TaxAuthorisation12>,
9823}
9824
9825impl TaxParty22 {
9826    pub fn validate(&self) -> Result<(), ValidationError> {
9827        if let Some(ref val) = self.tax_id {
9828            if val.chars().count() < 1 {
9829                return Err(ValidationError::new(
9830                    1001,
9831                    "tax_id is shorter than the minimum length of 1".to_string(),
9832                ));
9833            }
9834            if val.chars().count() > 35 {
9835                return Err(ValidationError::new(
9836                    1002,
9837                    "tax_id exceeds the maximum length of 35".to_string(),
9838                ));
9839            }
9840            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9841            if !pattern.is_match(val) {
9842                return Err(ValidationError::new(
9843                    1005,
9844                    "tax_id does not match the required pattern".to_string(),
9845                ));
9846            }
9847        }
9848        if let Some(ref val) = self.regn_id {
9849            if val.chars().count() < 1 {
9850                return Err(ValidationError::new(
9851                    1001,
9852                    "regn_id is shorter than the minimum length of 1".to_string(),
9853                ));
9854            }
9855            if val.chars().count() > 35 {
9856                return Err(ValidationError::new(
9857                    1002,
9858                    "regn_id exceeds the maximum length of 35".to_string(),
9859                ));
9860            }
9861            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9862            if !pattern.is_match(val) {
9863                return Err(ValidationError::new(
9864                    1005,
9865                    "regn_id does not match the required pattern".to_string(),
9866                ));
9867            }
9868        }
9869        if let Some(ref val) = self.tax_tp {
9870            if val.chars().count() < 1 {
9871                return Err(ValidationError::new(
9872                    1001,
9873                    "tax_tp is shorter than the minimum length of 1".to_string(),
9874                ));
9875            }
9876            if val.chars().count() > 35 {
9877                return Err(ValidationError::new(
9878                    1002,
9879                    "tax_tp exceeds the maximum length of 35".to_string(),
9880                ));
9881            }
9882            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
9883            if !pattern.is_match(val) {
9884                return Err(ValidationError::new(
9885                    1005,
9886                    "tax_tp does not match the required pattern".to_string(),
9887                ));
9888            }
9889        }
9890        if let Some(ref val) = self.authstn {
9891            val.validate()?
9892        }
9893        Ok(())
9894    }
9895}
9896
9897// TaxPeriod2: Range of time between a start date and an end date for which the tax report is provided.
9898#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9899pub struct TaxPeriod2 {
9900    #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
9901    pub yr: Option<String>,
9902    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
9903    pub tp: Option<TaxRecordPeriod1Code>,
9904    #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
9905    pub fr_to_dt: Option<DatePeriod2>,
9906}
9907
9908impl TaxPeriod2 {
9909    pub fn validate(&self) -> Result<(), ValidationError> {
9910        if let Some(ref val) = self.tp {
9911            val.validate()?
9912        }
9913        if let Some(ref val) = self.fr_to_dt {
9914            val.validate()?
9915        }
9916        Ok(())
9917    }
9918}
9919
9920// TaxRecord21: Further details of the tax record.
9921#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
9922pub struct TaxRecord21 {
9923    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
9924    pub tp: Option<String>,
9925    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
9926    pub ctgy: Option<String>,
9927    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
9928    pub ctgy_dtls: Option<String>,
9929    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
9930    pub dbtr_sts: Option<String>,
9931    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
9932    pub cert_id: Option<String>,
9933    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
9934    pub frms_cd: Option<String>,
9935    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
9936    pub prd: Option<TaxPeriod2>,
9937    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
9938    pub tax_amt: Option<TaxAmount2>,
9939    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
9940    pub addtl_inf: Option<String>,
9941}
9942
9943impl TaxRecord21 {
9944    pub fn validate(&self) -> Result<(), ValidationError> {
9945        if let Some(ref val) = self.tp {
9946            if val.chars().count() < 1 {
9947                return Err(ValidationError::new(
9948                    1001,
9949                    "tp is shorter than the minimum length of 1".to_string(),
9950                ));
9951            }
9952            if val.chars().count() > 35 {
9953                return Err(ValidationError::new(
9954                    1002,
9955                    "tp exceeds the maximum length of 35".to_string(),
9956                ));
9957            }
9958            let pattern = Regex::new(
9959                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9960            )
9961            .unwrap();
9962            if !pattern.is_match(val) {
9963                return Err(ValidationError::new(
9964                    1005,
9965                    "tp does not match the required pattern".to_string(),
9966                ));
9967            }
9968        }
9969        if let Some(ref val) = self.ctgy {
9970            if val.chars().count() < 1 {
9971                return Err(ValidationError::new(
9972                    1001,
9973                    "ctgy is shorter than the minimum length of 1".to_string(),
9974                ));
9975            }
9976            if val.chars().count() > 35 {
9977                return Err(ValidationError::new(
9978                    1002,
9979                    "ctgy exceeds the maximum length of 35".to_string(),
9980                ));
9981            }
9982            let pattern = Regex::new(
9983                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
9984            )
9985            .unwrap();
9986            if !pattern.is_match(val) {
9987                return Err(ValidationError::new(
9988                    1005,
9989                    "ctgy does not match the required pattern".to_string(),
9990                ));
9991            }
9992        }
9993        if let Some(ref val) = self.ctgy_dtls {
9994            if val.chars().count() < 1 {
9995                return Err(ValidationError::new(
9996                    1001,
9997                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
9998                ));
9999            }
10000            if val.chars().count() > 35 {
10001                return Err(ValidationError::new(
10002                    1002,
10003                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
10004                ));
10005            }
10006            let pattern = Regex::new(
10007                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
10008            )
10009            .unwrap();
10010            if !pattern.is_match(val) {
10011                return Err(ValidationError::new(
10012                    1005,
10013                    "ctgy_dtls does not match the required pattern".to_string(),
10014                ));
10015            }
10016        }
10017        if let Some(ref val) = self.dbtr_sts {
10018            if val.chars().count() < 1 {
10019                return Err(ValidationError::new(
10020                    1001,
10021                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
10022                ));
10023            }
10024            if val.chars().count() > 35 {
10025                return Err(ValidationError::new(
10026                    1002,
10027                    "dbtr_sts exceeds the maximum length of 35".to_string(),
10028                ));
10029            }
10030            let pattern = Regex::new(
10031                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
10032            )
10033            .unwrap();
10034            if !pattern.is_match(val) {
10035                return Err(ValidationError::new(
10036                    1005,
10037                    "dbtr_sts does not match the required pattern".to_string(),
10038                ));
10039            }
10040        }
10041        if let Some(ref val) = self.cert_id {
10042            if val.chars().count() < 1 {
10043                return Err(ValidationError::new(
10044                    1001,
10045                    "cert_id is shorter than the minimum length of 1".to_string(),
10046                ));
10047            }
10048            if val.chars().count() > 35 {
10049                return Err(ValidationError::new(
10050                    1002,
10051                    "cert_id exceeds the maximum length of 35".to_string(),
10052                ));
10053            }
10054            let pattern = Regex::new(
10055                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
10056            )
10057            .unwrap();
10058            if !pattern.is_match(val) {
10059                return Err(ValidationError::new(
10060                    1005,
10061                    "cert_id does not match the required pattern".to_string(),
10062                ));
10063            }
10064        }
10065        if let Some(ref val) = self.frms_cd {
10066            if val.chars().count() < 1 {
10067                return Err(ValidationError::new(
10068                    1001,
10069                    "frms_cd is shorter than the minimum length of 1".to_string(),
10070                ));
10071            }
10072            if val.chars().count() > 35 {
10073                return Err(ValidationError::new(
10074                    1002,
10075                    "frms_cd exceeds the maximum length of 35".to_string(),
10076                ));
10077            }
10078            let pattern = Regex::new(
10079                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
10080            )
10081            .unwrap();
10082            if !pattern.is_match(val) {
10083                return Err(ValidationError::new(
10084                    1005,
10085                    "frms_cd does not match the required pattern".to_string(),
10086                ));
10087            }
10088        }
10089        if let Some(ref val) = self.prd {
10090            val.validate()?
10091        }
10092        if let Some(ref val) = self.tax_amt {
10093            val.validate()?
10094        }
10095        if let Some(ref val) = self.addtl_inf {
10096            if val.chars().count() < 1 {
10097                return Err(ValidationError::new(
10098                    1001,
10099                    "addtl_inf is shorter than the minimum length of 1".to_string(),
10100                ));
10101            }
10102            if val.chars().count() > 140 {
10103                return Err(ValidationError::new(
10104                    1002,
10105                    "addtl_inf exceeds the maximum length of 140".to_string(),
10106                ));
10107            }
10108            let pattern = Regex::new(
10109                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
10110            )
10111            .unwrap();
10112            if !pattern.is_match(val) {
10113                return Err(ValidationError::new(
10114                    1005,
10115                    "addtl_inf does not match the required pattern".to_string(),
10116                ));
10117            }
10118        }
10119        Ok(())
10120    }
10121}
10122
10123// TaxRecord22: Further details of the tax record.
10124#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10125pub struct TaxRecord22 {
10126    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
10127    pub tp: Option<String>,
10128    #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
10129    pub ctgy: Option<String>,
10130    #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
10131    pub ctgy_dtls: Option<String>,
10132    #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
10133    pub dbtr_sts: Option<String>,
10134    #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
10135    pub cert_id: Option<String>,
10136    #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
10137    pub frms_cd: Option<String>,
10138    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
10139    pub prd: Option<TaxPeriod2>,
10140    #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
10141    pub tax_amt: Option<TaxAmount2>,
10142    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
10143    pub addtl_inf: Option<String>,
10144}
10145
10146impl TaxRecord22 {
10147    pub fn validate(&self) -> Result<(), ValidationError> {
10148        if let Some(ref val) = self.tp {
10149            if val.chars().count() < 1 {
10150                return Err(ValidationError::new(
10151                    1001,
10152                    "tp is shorter than the minimum length of 1".to_string(),
10153                ));
10154            }
10155            if val.chars().count() > 35 {
10156                return Err(ValidationError::new(
10157                    1002,
10158                    "tp exceeds the maximum length of 35".to_string(),
10159                ));
10160            }
10161            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10162            if !pattern.is_match(val) {
10163                return Err(ValidationError::new(
10164                    1005,
10165                    "tp does not match the required pattern".to_string(),
10166                ));
10167            }
10168        }
10169        if let Some(ref val) = self.ctgy {
10170            if val.chars().count() < 1 {
10171                return Err(ValidationError::new(
10172                    1001,
10173                    "ctgy is shorter than the minimum length of 1".to_string(),
10174                ));
10175            }
10176            if val.chars().count() > 35 {
10177                return Err(ValidationError::new(
10178                    1002,
10179                    "ctgy exceeds the maximum length of 35".to_string(),
10180                ));
10181            }
10182            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10183            if !pattern.is_match(val) {
10184                return Err(ValidationError::new(
10185                    1005,
10186                    "ctgy does not match the required pattern".to_string(),
10187                ));
10188            }
10189        }
10190        if let Some(ref val) = self.ctgy_dtls {
10191            if val.chars().count() < 1 {
10192                return Err(ValidationError::new(
10193                    1001,
10194                    "ctgy_dtls is shorter than the minimum length of 1".to_string(),
10195                ));
10196            }
10197            if val.chars().count() > 35 {
10198                return Err(ValidationError::new(
10199                    1002,
10200                    "ctgy_dtls exceeds the maximum length of 35".to_string(),
10201                ));
10202            }
10203            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10204            if !pattern.is_match(val) {
10205                return Err(ValidationError::new(
10206                    1005,
10207                    "ctgy_dtls does not match the required pattern".to_string(),
10208                ));
10209            }
10210        }
10211        if let Some(ref val) = self.dbtr_sts {
10212            if val.chars().count() < 1 {
10213                return Err(ValidationError::new(
10214                    1001,
10215                    "dbtr_sts is shorter than the minimum length of 1".to_string(),
10216                ));
10217            }
10218            if val.chars().count() > 35 {
10219                return Err(ValidationError::new(
10220                    1002,
10221                    "dbtr_sts exceeds the maximum length of 35".to_string(),
10222                ));
10223            }
10224            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10225            if !pattern.is_match(val) {
10226                return Err(ValidationError::new(
10227                    1005,
10228                    "dbtr_sts does not match the required pattern".to_string(),
10229                ));
10230            }
10231        }
10232        if let Some(ref val) = self.cert_id {
10233            if val.chars().count() < 1 {
10234                return Err(ValidationError::new(
10235                    1001,
10236                    "cert_id is shorter than the minimum length of 1".to_string(),
10237                ));
10238            }
10239            if val.chars().count() > 35 {
10240                return Err(ValidationError::new(
10241                    1002,
10242                    "cert_id exceeds the maximum length of 35".to_string(),
10243                ));
10244            }
10245            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10246            if !pattern.is_match(val) {
10247                return Err(ValidationError::new(
10248                    1005,
10249                    "cert_id does not match the required pattern".to_string(),
10250                ));
10251            }
10252        }
10253        if let Some(ref val) = self.frms_cd {
10254            if val.chars().count() < 1 {
10255                return Err(ValidationError::new(
10256                    1001,
10257                    "frms_cd is shorter than the minimum length of 1".to_string(),
10258                ));
10259            }
10260            if val.chars().count() > 35 {
10261                return Err(ValidationError::new(
10262                    1002,
10263                    "frms_cd exceeds the maximum length of 35".to_string(),
10264                ));
10265            }
10266            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10267            if !pattern.is_match(val) {
10268                return Err(ValidationError::new(
10269                    1005,
10270                    "frms_cd does not match the required pattern".to_string(),
10271                ));
10272            }
10273        }
10274        if let Some(ref val) = self.prd {
10275            val.validate()?
10276        }
10277        if let Some(ref val) = self.tax_amt {
10278            val.validate()?
10279        }
10280        if let Some(ref val) = self.addtl_inf {
10281            if val.chars().count() < 1 {
10282                return Err(ValidationError::new(
10283                    1001,
10284                    "addtl_inf is shorter than the minimum length of 1".to_string(),
10285                ));
10286            }
10287            if val.chars().count() > 140 {
10288                return Err(ValidationError::new(
10289                    1002,
10290                    "addtl_inf exceeds the maximum length of 140".to_string(),
10291                ));
10292            }
10293            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.\\n\\r,'\\+ ]{1,140}").unwrap();
10294            if !pattern.is_match(val) {
10295                return Err(ValidationError::new(
10296                    1005,
10297                    "addtl_inf does not match the required pattern".to_string(),
10298                ));
10299            }
10300        }
10301        Ok(())
10302    }
10303}
10304
10305// TaxRecordDetails2: Underlying tax amount related to the specified period.
10306#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10307pub struct TaxRecordDetails2 {
10308    #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
10309    pub prd: Option<TaxPeriod2>,
10310    #[serde(rename = "Amt")]
10311    pub amt: ActiveOrHistoricCurrencyAndAmount,
10312}
10313
10314impl TaxRecordDetails2 {
10315    pub fn validate(&self) -> Result<(), ValidationError> {
10316        if let Some(ref val) = self.prd {
10317            val.validate()?
10318        }
10319        self.amt.validate()?;
10320        Ok(())
10321    }
10322}
10323
10324// TaxRecordPeriod1Code: Tax is related to the second half of the period.
10325#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10326pub enum TaxRecordPeriod1Code {
10327    #[default]
10328    #[serde(rename = "MM01")]
10329    CodeMM01,
10330    #[serde(rename = "MM02")]
10331    CodeMM02,
10332    #[serde(rename = "MM03")]
10333    CodeMM03,
10334    #[serde(rename = "MM04")]
10335    CodeMM04,
10336    #[serde(rename = "MM05")]
10337    CodeMM05,
10338    #[serde(rename = "MM06")]
10339    CodeMM06,
10340    #[serde(rename = "MM07")]
10341    CodeMM07,
10342    #[serde(rename = "MM08")]
10343    CodeMM08,
10344    #[serde(rename = "MM09")]
10345    CodeMM09,
10346    #[serde(rename = "MM10")]
10347    CodeMM10,
10348    #[serde(rename = "MM11")]
10349    CodeMM11,
10350    #[serde(rename = "MM12")]
10351    CodeMM12,
10352    #[serde(rename = "QTR1")]
10353    CodeQTR1,
10354    #[serde(rename = "QTR2")]
10355    CodeQTR2,
10356    #[serde(rename = "QTR3")]
10357    CodeQTR3,
10358    #[serde(rename = "QTR4")]
10359    CodeQTR4,
10360    #[serde(rename = "HLF1")]
10361    CodeHLF1,
10362    #[serde(rename = "HLF2")]
10363    CodeHLF2,
10364}
10365
10366impl TaxRecordPeriod1Code {
10367    pub fn validate(&self) -> Result<(), ValidationError> {
10368        Ok(())
10369    }
10370}
10371
10372// TechnicalInputChannel1Choice1: Technical channel used to input the instruction, in a proprietary form.
10373#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10374pub struct TechnicalInputChannel1Choice1 {
10375    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
10376    pub cd: Option<String>,
10377    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10378    pub prtry: Option<String>,
10379}
10380
10381impl TechnicalInputChannel1Choice1 {
10382    pub fn validate(&self) -> Result<(), ValidationError> {
10383        if let Some(ref val) = self.cd {
10384            if val.chars().count() < 1 {
10385                return Err(ValidationError::new(
10386                    1001,
10387                    "cd is shorter than the minimum length of 1".to_string(),
10388                ));
10389            }
10390            if val.chars().count() > 4 {
10391                return Err(ValidationError::new(
10392                    1002,
10393                    "cd exceeds the maximum length of 4".to_string(),
10394                ));
10395            }
10396        }
10397        if let Some(ref val) = self.prtry {
10398            if val.chars().count() < 1 {
10399                return Err(ValidationError::new(
10400                    1001,
10401                    "prtry is shorter than the minimum length of 1".to_string(),
10402                ));
10403            }
10404            if val.chars().count() > 35 {
10405                return Err(ValidationError::new(
10406                    1002,
10407                    "prtry exceeds the maximum length of 35".to_string(),
10408                ));
10409            }
10410            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10411            if !pattern.is_match(val) {
10412                return Err(ValidationError::new(
10413                    1005,
10414                    "prtry does not match the required pattern".to_string(),
10415                ));
10416            }
10417        }
10418        Ok(())
10419    }
10420}
10421
10422// TotalTransactions61: Specifies the total number and sum of entries per bank transaction code.
10423#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10424pub struct TotalTransactions61 {
10425    #[serde(rename = "TtlNtries", skip_serializing_if = "Option::is_none")]
10426    pub ttl_ntries: Option<NumberAndSumOfTransactions4>,
10427    #[serde(rename = "TtlCdtNtries", skip_serializing_if = "Option::is_none")]
10428    pub ttl_cdt_ntries: Option<NumberAndSumOfTransactions1>,
10429    #[serde(rename = "TtlDbtNtries", skip_serializing_if = "Option::is_none")]
10430    pub ttl_dbt_ntries: Option<NumberAndSumOfTransactions1>,
10431    #[serde(rename = "TtlNtriesPerBkTxCd", skip_serializing_if = "Option::is_none")]
10432    pub ttl_ntries_per_bk_tx_cd: Option<Vec<TotalsPerBankTransactionCode51>>,
10433}
10434
10435impl TotalTransactions61 {
10436    pub fn validate(&self) -> Result<(), ValidationError> {
10437        if let Some(ref val) = self.ttl_ntries {
10438            val.validate()?
10439        }
10440        if let Some(ref val) = self.ttl_cdt_ntries {
10441            val.validate()?
10442        }
10443        if let Some(ref val) = self.ttl_dbt_ntries {
10444            val.validate()?
10445        }
10446        if let Some(ref vec) = self.ttl_ntries_per_bk_tx_cd {
10447            for item in vec {
10448                item.validate()?
10449            }
10450        }
10451        Ok(())
10452    }
10453}
10454
10455// TotalsPerBankTransactionCode51: Indicates the date (and time) of the transaction summary.
10456#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10457pub struct TotalsPerBankTransactionCode51 {
10458    #[serde(rename = "NbOfNtries", skip_serializing_if = "Option::is_none")]
10459    pub nb_of_ntries: Option<String>,
10460    #[serde(rename = "Sum", skip_serializing_if = "Option::is_none")]
10461    pub sum: Option<f64>,
10462    #[serde(rename = "TtlNetNtry", skip_serializing_if = "Option::is_none")]
10463    pub ttl_net_ntry: Option<AmountAndDirection35>,
10464    #[serde(rename = "CdtNtries", skip_serializing_if = "Option::is_none")]
10465    pub cdt_ntries: Option<NumberAndSumOfTransactions1>,
10466    #[serde(rename = "DbtNtries", skip_serializing_if = "Option::is_none")]
10467    pub dbt_ntries: Option<NumberAndSumOfTransactions1>,
10468    #[serde(rename = "FcstInd", skip_serializing_if = "Option::is_none")]
10469    pub fcst_ind: Option<bool>,
10470    #[serde(rename = "BkTxCd")]
10471    pub bk_tx_cd: BankTransactionCodeStructure41,
10472    #[serde(rename = "Avlbty", skip_serializing_if = "Option::is_none")]
10473    pub avlbty: Option<Vec<CashAvailability1>>,
10474    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
10475    pub dt: Option<DateAndDateTime2Choice1>,
10476}
10477
10478impl TotalsPerBankTransactionCode51 {
10479    pub fn validate(&self) -> Result<(), ValidationError> {
10480        if let Some(ref val) = self.nb_of_ntries {
10481            let pattern = Regex::new("[0-9]{1,15}").unwrap();
10482            if !pattern.is_match(val) {
10483                return Err(ValidationError::new(
10484                    1005,
10485                    "nb_of_ntries does not match the required pattern".to_string(),
10486                ));
10487            }
10488        }
10489        if let Some(ref val) = self.ttl_net_ntry {
10490            val.validate()?
10491        }
10492        if let Some(ref val) = self.cdt_ntries {
10493            val.validate()?
10494        }
10495        if let Some(ref val) = self.dbt_ntries {
10496            val.validate()?
10497        }
10498        self.bk_tx_cd.validate()?;
10499        if let Some(ref vec) = self.avlbty {
10500            for item in vec {
10501                item.validate()?
10502            }
10503        }
10504        if let Some(ref val) = self.dt {
10505            val.validate()?
10506        }
10507        Ok(())
10508    }
10509}
10510
10511// TrackData11: Card track content or equivalent.
10512#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10513pub struct TrackData11 {
10514    #[serde(rename = "TrckNb", skip_serializing_if = "Option::is_none")]
10515    pub trck_nb: Option<String>,
10516    #[serde(rename = "TrckVal")]
10517    pub trck_val: String,
10518}
10519
10520impl TrackData11 {
10521    pub fn validate(&self) -> Result<(), ValidationError> {
10522        if let Some(ref val) = self.trck_nb {
10523            let pattern = Regex::new("[0-9]").unwrap();
10524            if !pattern.is_match(val) {
10525                return Err(ValidationError::new(
10526                    1005,
10527                    "trck_nb does not match the required pattern".to_string(),
10528                ));
10529            }
10530        }
10531        if self.trck_val.chars().count() < 1 {
10532            return Err(ValidationError::new(
10533                1001,
10534                "trck_val is shorter than the minimum length of 1".to_string(),
10535            ));
10536        }
10537        if self.trck_val.chars().count() > 140 {
10538            return Err(ValidationError::new(
10539                1002,
10540                "trck_val exceeds the maximum length of 140".to_string(),
10541            ));
10542        }
10543        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10544        if !pattern.is_match(&self.trck_val) {
10545            return Err(ValidationError::new(
10546                1005,
10547                "trck_val does not match the required pattern".to_string(),
10548            ));
10549        }
10550        Ok(())
10551    }
10552}
10553
10554// TransactionAgents51: Proprietary agent related to the underlying transaction.
10555#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10556pub struct TransactionAgents51 {
10557    #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
10558    pub instg_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10559    #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
10560    pub instd_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10561    #[serde(rename = "DbtrAgt", skip_serializing_if = "Option::is_none")]
10562    pub dbtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10563    #[serde(rename = "CdtrAgt", skip_serializing_if = "Option::is_none")]
10564    pub cdtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10565    #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
10566    pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification61>,
10567    #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
10568    pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
10569    #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
10570    pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
10571    #[serde(rename = "RcvgAgt", skip_serializing_if = "Option::is_none")]
10572    pub rcvg_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10573    #[serde(rename = "DlvrgAgt", skip_serializing_if = "Option::is_none")]
10574    pub dlvrg_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10575    #[serde(rename = "IssgAgt", skip_serializing_if = "Option::is_none")]
10576    pub issg_agt: Option<BranchAndFinancialInstitutionIdentification61>,
10577    #[serde(rename = "SttlmPlc", skip_serializing_if = "Option::is_none")]
10578    pub sttlm_plc: Option<BranchAndFinancialInstitutionIdentification61>,
10579    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10580    pub prtry: Option<Vec<ProprietaryAgent41>>,
10581}
10582
10583impl TransactionAgents51 {
10584    pub fn validate(&self) -> Result<(), ValidationError> {
10585        if let Some(ref val) = self.instg_agt {
10586            val.validate()?
10587        }
10588        if let Some(ref val) = self.instd_agt {
10589            val.validate()?
10590        }
10591        if let Some(ref val) = self.dbtr_agt {
10592            val.validate()?
10593        }
10594        if let Some(ref val) = self.cdtr_agt {
10595            val.validate()?
10596        }
10597        if let Some(ref val) = self.intrmy_agt1 {
10598            val.validate()?
10599        }
10600        if let Some(ref val) = self.intrmy_agt2 {
10601            val.validate()?
10602        }
10603        if let Some(ref val) = self.intrmy_agt3 {
10604            val.validate()?
10605        }
10606        if let Some(ref val) = self.rcvg_agt {
10607            val.validate()?
10608        }
10609        if let Some(ref val) = self.dlvrg_agt {
10610            val.validate()?
10611        }
10612        if let Some(ref val) = self.issg_agt {
10613            val.validate()?
10614        }
10615        if let Some(ref val) = self.sttlm_plc {
10616            val.validate()?
10617        }
10618        if let Some(ref vec) = self.prtry {
10619            for item in vec {
10620                item.validate()?
10621            }
10622        }
10623        Ok(())
10624    }
10625}
10626
10627// TransactionChannel1Code: Payment on television.
10628#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10629pub enum TransactionChannel1Code {
10630    #[default]
10631    #[serde(rename = "MAIL")]
10632    CodeMAIL,
10633    #[serde(rename = "TLPH")]
10634    CodeTLPH,
10635    #[serde(rename = "ECOM")]
10636    CodeECOM,
10637    #[serde(rename = "TVPY")]
10638    CodeTVPY,
10639}
10640
10641impl TransactionChannel1Code {
10642    pub fn validate(&self) -> Result<(), ValidationError> {
10643        Ok(())
10644    }
10645}
10646
10647// TransactionDates31: Proprietary date related to the underlying transaction.
10648#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10649pub struct TransactionDates31 {
10650    #[serde(rename = "AccptncDtTm", skip_serializing_if = "Option::is_none")]
10651    pub accptnc_dt_tm: Option<String>,
10652    #[serde(
10653        rename = "TradActvtyCtrctlSttlmDt",
10654        skip_serializing_if = "Option::is_none"
10655    )]
10656    pub trad_actvty_ctrctl_sttlm_dt: Option<String>,
10657    #[serde(rename = "TradDt", skip_serializing_if = "Option::is_none")]
10658    pub trad_dt: Option<String>,
10659    #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
10660    pub intr_bk_sttlm_dt: Option<String>,
10661    #[serde(rename = "StartDt", skip_serializing_if = "Option::is_none")]
10662    pub start_dt: Option<String>,
10663    #[serde(rename = "EndDt", skip_serializing_if = "Option::is_none")]
10664    pub end_dt: Option<String>,
10665    #[serde(rename = "TxDtTm", skip_serializing_if = "Option::is_none")]
10666    pub tx_dt_tm: Option<String>,
10667    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10668    pub prtry: Option<Vec<ProprietaryDate31>>,
10669}
10670
10671impl TransactionDates31 {
10672    pub fn validate(&self) -> Result<(), ValidationError> {
10673        if let Some(ref val) = self.accptnc_dt_tm {
10674            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
10675            if !pattern.is_match(val) {
10676                return Err(ValidationError::new(
10677                    1005,
10678                    "accptnc_dt_tm does not match the required pattern".to_string(),
10679                ));
10680            }
10681        }
10682        if let Some(ref val) = self.tx_dt_tm {
10683            let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
10684            if !pattern.is_match(val) {
10685                return Err(ValidationError::new(
10686                    1005,
10687                    "tx_dt_tm does not match the required pattern".to_string(),
10688                ));
10689            }
10690        }
10691        if let Some(ref vec) = self.prtry {
10692            for item in vec {
10693                item.validate()?
10694            }
10695        }
10696        Ok(())
10697    }
10698}
10699
10700// TransactionEnvironment1Code: Public environment.
10701#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10702pub enum TransactionEnvironment1Code {
10703    #[default]
10704    #[serde(rename = "MERC")]
10705    CodeMERC,
10706    #[serde(rename = "PRIV")]
10707    CodePRIV,
10708    #[serde(rename = "PUBL")]
10709    CodePUBL,
10710}
10711
10712impl TransactionEnvironment1Code {
10713    pub fn validate(&self) -> Result<(), ValidationError> {
10714        Ok(())
10715    }
10716}
10717
10718// TransactionIdentifier11: Identification of the transaction that has to be unique for a time period.
10719#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10720pub struct TransactionIdentifier11 {
10721    #[serde(rename = "TxDtTm")]
10722    pub tx_dt_tm: String,
10723    #[serde(rename = "TxRef")]
10724    pub tx_ref: String,
10725}
10726
10727impl TransactionIdentifier11 {
10728    pub fn validate(&self) -> Result<(), ValidationError> {
10729        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
10730        if !pattern.is_match(&self.tx_dt_tm) {
10731            return Err(ValidationError::new(
10732                1005,
10733                "tx_dt_tm does not match the required pattern".to_string(),
10734            ));
10735        }
10736        if self.tx_ref.chars().count() < 1 {
10737            return Err(ValidationError::new(
10738                1001,
10739                "tx_ref is shorter than the minimum length of 1".to_string(),
10740            ));
10741        }
10742        if self.tx_ref.chars().count() > 35 {
10743            return Err(ValidationError::new(
10744                1002,
10745                "tx_ref exceeds the maximum length of 35".to_string(),
10746            ));
10747        }
10748        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10749        if !pattern.is_match(&self.tx_ref) {
10750            return Err(ValidationError::new(
10751                1005,
10752                "tx_ref does not match the required pattern".to_string(),
10753            ));
10754        }
10755        Ok(())
10756    }
10757}
10758
10759// TransactionInterest41: Individual interest record.
10760#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10761pub struct TransactionInterest41 {
10762    #[serde(rename = "TtlIntrstAndTaxAmt", skip_serializing_if = "Option::is_none")]
10763    pub ttl_intrst_and_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
10764    #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
10765    pub rcrd: Option<Vec<InterestRecord21>>,
10766}
10767
10768impl TransactionInterest41 {
10769    pub fn validate(&self) -> Result<(), ValidationError> {
10770        if let Some(ref val) = self.ttl_intrst_and_tax_amt {
10771            val.validate()?
10772        }
10773        if let Some(ref vec) = self.rcrd {
10774            for item in vec {
10775                item.validate()?
10776            }
10777        }
10778        Ok(())
10779    }
10780}
10781
10782// TransactionParties61: Proprietary party related to the underlying transaction.
10783#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10784pub struct TransactionParties61 {
10785    #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
10786    pub initg_pty: Option<Party40Choice1>,
10787    #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
10788    pub dbtr: Option<Party40Choice2>,
10789    #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
10790    pub dbtr_acct: Option<CashAccount383>,
10791    #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
10792    pub ultmt_dbtr: Option<Party40Choice3>,
10793    #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
10794    pub cdtr: Option<Party40Choice3>,
10795    #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
10796    pub cdtr_acct: Option<CashAccount383>,
10797    #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
10798    pub ultmt_cdtr: Option<Party40Choice3>,
10799    #[serde(rename = "TradgPty", skip_serializing_if = "Option::is_none")]
10800    pub tradg_pty: Option<Party40Choice3>,
10801    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10802    pub prtry: Option<Vec<ProprietaryParty51>>,
10803}
10804
10805impl TransactionParties61 {
10806    pub fn validate(&self) -> Result<(), ValidationError> {
10807        if let Some(ref val) = self.initg_pty {
10808            val.validate()?
10809        }
10810        if let Some(ref val) = self.dbtr {
10811            val.validate()?
10812        }
10813        if let Some(ref val) = self.dbtr_acct {
10814            val.validate()?
10815        }
10816        if let Some(ref val) = self.ultmt_dbtr {
10817            val.validate()?
10818        }
10819        if let Some(ref val) = self.cdtr {
10820            val.validate()?
10821        }
10822        if let Some(ref val) = self.cdtr_acct {
10823            val.validate()?
10824        }
10825        if let Some(ref val) = self.ultmt_cdtr {
10826            val.validate()?
10827        }
10828        if let Some(ref val) = self.tradg_pty {
10829            val.validate()?
10830        }
10831        if let Some(ref vec) = self.prtry {
10832            for item in vec {
10833                item.validate()?
10834            }
10835        }
10836        Ok(())
10837    }
10838}
10839
10840// TransactionPrice4Choice1: Proprietary price specification related to the underlying transaction.
10841#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10842pub struct TransactionPrice4Choice1 {
10843    #[serde(rename = "DealPric", skip_serializing_if = "Option::is_none")]
10844    pub deal_pric: Option<Price7>,
10845    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10846    pub prtry: Option<Vec<ProprietaryPrice21>>,
10847}
10848
10849impl TransactionPrice4Choice1 {
10850    pub fn validate(&self) -> Result<(), ValidationError> {
10851        if let Some(ref val) = self.deal_pric {
10852            val.validate()?
10853        }
10854        if let Some(ref vec) = self.prtry {
10855            for item in vec {
10856                item.validate()?
10857            }
10858        }
10859        Ok(())
10860    }
10861}
10862
10863// TransactionQuantities3Choice1: Proprietary quantities specification defined in the underlying transaction.
10864#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10865pub struct TransactionQuantities3Choice1 {
10866    #[serde(rename = "Qty", skip_serializing_if = "Option::is_none")]
10867    pub qty: Option<FinancialInstrumentQuantity1Choice>,
10868    #[serde(rename = "OrgnlAndCurFaceAmt", skip_serializing_if = "Option::is_none")]
10869    pub orgnl_and_cur_face_amt: Option<OriginalAndCurrentQuantities1>,
10870    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10871    pub prtry: Option<ProprietaryQuantity11>,
10872}
10873
10874impl TransactionQuantities3Choice1 {
10875    pub fn validate(&self) -> Result<(), ValidationError> {
10876        if let Some(ref val) = self.qty {
10877            val.validate()?
10878        }
10879        if let Some(ref val) = self.orgnl_and_cur_face_amt {
10880            val.validate()?
10881        }
10882        if let Some(ref val) = self.prtry {
10883            val.validate()?
10884        }
10885        Ok(())
10886    }
10887}
10888
10889// TransactionReferences61: Proprietary reference related to the underlying transaction.
10890#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
10891pub struct TransactionReferences61 {
10892    #[serde(rename = "MsgId", skip_serializing_if = "Option::is_none")]
10893    pub msg_id: Option<String>,
10894    #[serde(rename = "AcctSvcrRef", skip_serializing_if = "Option::is_none")]
10895    pub acct_svcr_ref: Option<String>,
10896    #[serde(rename = "PmtInfId", skip_serializing_if = "Option::is_none")]
10897    pub pmt_inf_id: Option<String>,
10898    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
10899    pub instr_id: Option<String>,
10900    #[serde(rename = "EndToEndId", skip_serializing_if = "Option::is_none")]
10901    pub end_to_end_id: Option<String>,
10902    #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
10903    pub uetr: Option<String>,
10904    #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
10905    pub tx_id: Option<String>,
10906    #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
10907    pub mndt_id: Option<String>,
10908    #[serde(rename = "ChqNb", skip_serializing_if = "Option::is_none")]
10909    pub chq_nb: Option<String>,
10910    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
10911    pub clr_sys_ref: Option<String>,
10912    #[serde(rename = "AcctOwnrTxId", skip_serializing_if = "Option::is_none")]
10913    pub acct_ownr_tx_id: Option<String>,
10914    #[serde(rename = "AcctSvcrTxId", skip_serializing_if = "Option::is_none")]
10915    pub acct_svcr_tx_id: Option<String>,
10916    #[serde(rename = "MktInfrstrctrTxId", skip_serializing_if = "Option::is_none")]
10917    pub mkt_infrstrctr_tx_id: Option<String>,
10918    #[serde(rename = "PrcgId", skip_serializing_if = "Option::is_none")]
10919    pub prcg_id: Option<String>,
10920    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
10921    pub prtry: Option<Vec<ProprietaryReference11>>,
10922}
10923
10924impl TransactionReferences61 {
10925    pub fn validate(&self) -> Result<(), ValidationError> {
10926        if let Some(ref val) = self.msg_id {
10927            if val.chars().count() < 1 {
10928                return Err(ValidationError::new(
10929                    1001,
10930                    "msg_id is shorter than the minimum length of 1".to_string(),
10931                ));
10932            }
10933            if val.chars().count() > 35 {
10934                return Err(ValidationError::new(
10935                    1002,
10936                    "msg_id exceeds the maximum length of 35".to_string(),
10937                ));
10938            }
10939            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10940            if !pattern.is_match(val) {
10941                return Err(ValidationError::new(
10942                    1005,
10943                    "msg_id does not match the required pattern".to_string(),
10944                ));
10945            }
10946        }
10947        if let Some(ref val) = self.acct_svcr_ref {
10948            if val.chars().count() < 1 {
10949                return Err(ValidationError::new(
10950                    1001,
10951                    "acct_svcr_ref is shorter than the minimum length of 1".to_string(),
10952                ));
10953            }
10954            if val.chars().count() > 35 {
10955                return Err(ValidationError::new(
10956                    1002,
10957                    "acct_svcr_ref exceeds the maximum length of 35".to_string(),
10958                ));
10959            }
10960            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10961            if !pattern.is_match(val) {
10962                return Err(ValidationError::new(
10963                    1005,
10964                    "acct_svcr_ref does not match the required pattern".to_string(),
10965                ));
10966            }
10967        }
10968        if let Some(ref val) = self.pmt_inf_id {
10969            if val.chars().count() < 1 {
10970                return Err(ValidationError::new(
10971                    1001,
10972                    "pmt_inf_id is shorter than the minimum length of 1".to_string(),
10973                ));
10974            }
10975            if val.chars().count() > 35 {
10976                return Err(ValidationError::new(
10977                    1002,
10978                    "pmt_inf_id exceeds the maximum length of 35".to_string(),
10979                ));
10980            }
10981            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
10982            if !pattern.is_match(val) {
10983                return Err(ValidationError::new(
10984                    1005,
10985                    "pmt_inf_id does not match the required pattern".to_string(),
10986                ));
10987            }
10988        }
10989        if let Some(ref val) = self.instr_id {
10990            if val.chars().count() < 1 {
10991                return Err(ValidationError::new(
10992                    1001,
10993                    "instr_id is shorter than the minimum length of 1".to_string(),
10994                ));
10995            }
10996            if val.chars().count() > 35 {
10997                return Err(ValidationError::new(
10998                    1002,
10999                    "instr_id exceeds the maximum length of 35".to_string(),
11000                ));
11001            }
11002            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11003            if !pattern.is_match(val) {
11004                return Err(ValidationError::new(
11005                    1005,
11006                    "instr_id does not match the required pattern".to_string(),
11007                ));
11008            }
11009        }
11010        if let Some(ref val) = self.end_to_end_id {
11011            if val.chars().count() < 1 {
11012                return Err(ValidationError::new(
11013                    1001,
11014                    "end_to_end_id is shorter than the minimum length of 1".to_string(),
11015                ));
11016            }
11017            if val.chars().count() > 35 {
11018                return Err(ValidationError::new(
11019                    1002,
11020                    "end_to_end_id exceeds the maximum length of 35".to_string(),
11021                ));
11022            }
11023            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11024            if !pattern.is_match(val) {
11025                return Err(ValidationError::new(
11026                    1005,
11027                    "end_to_end_id does not match the required pattern".to_string(),
11028                ));
11029            }
11030        }
11031        if let Some(ref val) = self.uetr {
11032            let pattern =
11033                Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
11034                    .unwrap();
11035            if !pattern.is_match(val) {
11036                return Err(ValidationError::new(
11037                    1005,
11038                    "uetr does not match the required pattern".to_string(),
11039                ));
11040            }
11041        }
11042        if let Some(ref val) = self.tx_id {
11043            if val.chars().count() < 1 {
11044                return Err(ValidationError::new(
11045                    1001,
11046                    "tx_id is shorter than the minimum length of 1".to_string(),
11047                ));
11048            }
11049            if val.chars().count() > 35 {
11050                return Err(ValidationError::new(
11051                    1002,
11052                    "tx_id exceeds the maximum length of 35".to_string(),
11053                ));
11054            }
11055            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11056            if !pattern.is_match(val) {
11057                return Err(ValidationError::new(
11058                    1005,
11059                    "tx_id does not match the required pattern".to_string(),
11060                ));
11061            }
11062        }
11063        if let Some(ref val) = self.mndt_id {
11064            if val.chars().count() < 1 {
11065                return Err(ValidationError::new(
11066                    1001,
11067                    "mndt_id is shorter than the minimum length of 1".to_string(),
11068                ));
11069            }
11070            if val.chars().count() > 35 {
11071                return Err(ValidationError::new(
11072                    1002,
11073                    "mndt_id exceeds the maximum length of 35".to_string(),
11074                ));
11075            }
11076            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11077            if !pattern.is_match(val) {
11078                return Err(ValidationError::new(
11079                    1005,
11080                    "mndt_id does not match the required pattern".to_string(),
11081                ));
11082            }
11083        }
11084        if let Some(ref val) = self.chq_nb {
11085            if val.chars().count() < 1 {
11086                return Err(ValidationError::new(
11087                    1001,
11088                    "chq_nb is shorter than the minimum length of 1".to_string(),
11089                ));
11090            }
11091            if val.chars().count() > 35 {
11092                return Err(ValidationError::new(
11093                    1002,
11094                    "chq_nb exceeds the maximum length of 35".to_string(),
11095                ));
11096            }
11097            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11098            if !pattern.is_match(val) {
11099                return Err(ValidationError::new(
11100                    1005,
11101                    "chq_nb does not match the required pattern".to_string(),
11102                ));
11103            }
11104        }
11105        if let Some(ref val) = self.clr_sys_ref {
11106            if val.chars().count() < 1 {
11107                return Err(ValidationError::new(
11108                    1001,
11109                    "clr_sys_ref is shorter than the minimum length of 1".to_string(),
11110                ));
11111            }
11112            if val.chars().count() > 35 {
11113                return Err(ValidationError::new(
11114                    1002,
11115                    "clr_sys_ref exceeds the maximum length of 35".to_string(),
11116                ));
11117            }
11118            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11119            if !pattern.is_match(val) {
11120                return Err(ValidationError::new(
11121                    1005,
11122                    "clr_sys_ref does not match the required pattern".to_string(),
11123                ));
11124            }
11125        }
11126        if let Some(ref val) = self.acct_ownr_tx_id {
11127            if val.chars().count() < 1 {
11128                return Err(ValidationError::new(
11129                    1001,
11130                    "acct_ownr_tx_id is shorter than the minimum length of 1".to_string(),
11131                ));
11132            }
11133            if val.chars().count() > 35 {
11134                return Err(ValidationError::new(
11135                    1002,
11136                    "acct_ownr_tx_id exceeds the maximum length of 35".to_string(),
11137                ));
11138            }
11139            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11140            if !pattern.is_match(val) {
11141                return Err(ValidationError::new(
11142                    1005,
11143                    "acct_ownr_tx_id does not match the required pattern".to_string(),
11144                ));
11145            }
11146        }
11147        if let Some(ref val) = self.acct_svcr_tx_id {
11148            if val.chars().count() < 1 {
11149                return Err(ValidationError::new(
11150                    1001,
11151                    "acct_svcr_tx_id is shorter than the minimum length of 1".to_string(),
11152                ));
11153            }
11154            if val.chars().count() > 35 {
11155                return Err(ValidationError::new(
11156                    1002,
11157                    "acct_svcr_tx_id exceeds the maximum length of 35".to_string(),
11158                ));
11159            }
11160            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11161            if !pattern.is_match(val) {
11162                return Err(ValidationError::new(
11163                    1005,
11164                    "acct_svcr_tx_id does not match the required pattern".to_string(),
11165                ));
11166            }
11167        }
11168        if let Some(ref val) = self.mkt_infrstrctr_tx_id {
11169            if val.chars().count() < 1 {
11170                return Err(ValidationError::new(
11171                    1001,
11172                    "mkt_infrstrctr_tx_id is shorter than the minimum length of 1".to_string(),
11173                ));
11174            }
11175            if val.chars().count() > 35 {
11176                return Err(ValidationError::new(
11177                    1002,
11178                    "mkt_infrstrctr_tx_id exceeds the maximum length of 35".to_string(),
11179                ));
11180            }
11181            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11182            if !pattern.is_match(val) {
11183                return Err(ValidationError::new(
11184                    1005,
11185                    "mkt_infrstrctr_tx_id does not match the required pattern".to_string(),
11186                ));
11187            }
11188        }
11189        if let Some(ref val) = self.prcg_id {
11190            if val.chars().count() < 1 {
11191                return Err(ValidationError::new(
11192                    1001,
11193                    "prcg_id is shorter than the minimum length of 1".to_string(),
11194                ));
11195            }
11196            if val.chars().count() > 35 {
11197                return Err(ValidationError::new(
11198                    1002,
11199                    "prcg_id exceeds the maximum length of 35".to_string(),
11200                ));
11201            }
11202            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
11203            if !pattern.is_match(val) {
11204                return Err(ValidationError::new(
11205                    1005,
11206                    "prcg_id does not match the required pattern".to_string(),
11207                ));
11208            }
11209        }
11210        if let Some(ref vec) = self.prtry {
11211            for item in vec {
11212                item.validate()?
11213            }
11214        }
11215        Ok(())
11216    }
11217}
11218
11219// UnitOfMeasure1Code: Unit of measure equal to 4, 840 square yards.
11220#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
11221pub enum UnitOfMeasure1Code {
11222    #[default]
11223    #[serde(rename = "PIEC")]
11224    CodePIEC,
11225    #[serde(rename = "TONS")]
11226    CodeTONS,
11227    #[serde(rename = "FOOT")]
11228    CodeFOOT,
11229    #[serde(rename = "GBGA")]
11230    CodeGBGA,
11231    #[serde(rename = "USGA")]
11232    CodeUSGA,
11233    #[serde(rename = "GRAM")]
11234    CodeGRAM,
11235    #[serde(rename = "INCH")]
11236    CodeINCH,
11237    #[serde(rename = "KILO")]
11238    CodeKILO,
11239    #[serde(rename = "PUND")]
11240    CodePUND,
11241    #[serde(rename = "METR")]
11242    CodeMETR,
11243    #[serde(rename = "CMET")]
11244    CodeCMET,
11245    #[serde(rename = "MMET")]
11246    CodeMMET,
11247    #[serde(rename = "LITR")]
11248    CodeLITR,
11249    #[serde(rename = "CELI")]
11250    CodeCELI,
11251    #[serde(rename = "MILI")]
11252    CodeMILI,
11253    #[serde(rename = "GBOU")]
11254    CodeGBOU,
11255    #[serde(rename = "USOU")]
11256    CodeUSOU,
11257    #[serde(rename = "GBQA")]
11258    CodeGBQA,
11259    #[serde(rename = "USQA")]
11260    CodeUSQA,
11261    #[serde(rename = "GBPI")]
11262    CodeGBPI,
11263    #[serde(rename = "USPI")]
11264    CodeUSPI,
11265    #[serde(rename = "MILE")]
11266    CodeMILE,
11267    #[serde(rename = "KMET")]
11268    CodeKMET,
11269    #[serde(rename = "YARD")]
11270    CodeYARD,
11271    #[serde(rename = "SQKI")]
11272    CodeSQKI,
11273    #[serde(rename = "HECT")]
11274    CodeHECT,
11275    #[serde(rename = "ARES")]
11276    CodeARES,
11277    #[serde(rename = "SMET")]
11278    CodeSMET,
11279    #[serde(rename = "SCMT")]
11280    CodeSCMT,
11281    #[serde(rename = "SMIL")]
11282    CodeSMIL,
11283    #[serde(rename = "SQMI")]
11284    CodeSQMI,
11285    #[serde(rename = "SQYA")]
11286    CodeSQYA,
11287    #[serde(rename = "SQFO")]
11288    CodeSQFO,
11289    #[serde(rename = "SQIN")]
11290    CodeSQIN,
11291    #[serde(rename = "ACRE")]
11292    CodeACRE,
11293}
11294
11295impl UnitOfMeasure1Code {
11296    pub fn validate(&self) -> Result<(), ValidationError> {
11297        Ok(())
11298    }
11299}
11300
11301// UserInterface2Code: Cardholder display or interface.
11302#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
11303pub enum UserInterface2Code {
11304    #[default]
11305    #[serde(rename = "MDSP")]
11306    CodeMDSP,
11307    #[serde(rename = "CDSP")]
11308    CodeCDSP,
11309}
11310
11311impl UserInterface2Code {
11312    pub fn validate(&self) -> Result<(), ValidationError> {
11313        Ok(())
11314    }
11315}
11316
11317// YieldedOrValueType1Choice: Type of value in which the price is expressed.
11318#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
11319pub struct YieldedOrValueType1Choice {
11320    #[serde(rename = "Yldd", skip_serializing_if = "Option::is_none")]
11321    pub yldd: Option<bool>,
11322    #[serde(rename = "ValTp", skip_serializing_if = "Option::is_none")]
11323    pub val_tp: Option<PriceValueType1Code>,
11324}
11325
11326impl YieldedOrValueType1Choice {
11327    pub fn validate(&self) -> Result<(), ValidationError> {
11328        if let Some(ref val) = self.val_tp {
11329            val.validate()?
11330        }
11331        Ok(())
11332    }
11333}