mx_message/document/
camt_060_001_05.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
19use crate::parse_result::{ErrorCollector, ParserConfig};
20use crate::validation::{Validate, helpers};
21use serde::{Deserialize, Serialize};
22
23// AccountIdentification4Choice1: Unique identification of an account, as assigned by the account servicer, using an identification scheme.
24#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
25pub struct AccountIdentification4Choice1 {
26    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
27    pub iban: Option<String>,
28    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
29    pub othr: Option<GenericAccountIdentification11>,
30}
31
32impl Validate for AccountIdentification4Choice1 {
33    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
34        if let Some(ref val) = self.iban {
35            helpers::validate_pattern(
36                val,
37                "IBAN",
38                "[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}",
39                &helpers::child_path(path, "IBAN"),
40                config,
41                collector,
42            );
43        }
44        if let Some(ref val) = self.othr
45            && config.validate_optional_fields
46        {
47            val.validate(&helpers::child_path(path, "Othr"), config, collector);
48        }
49    }
50}
51
52// AccountReportingRequestV05: Set of elements used to provide further details on the reporting request.
53#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
54pub struct AccountReportingRequestV05 {
55    #[serde(rename = "GrpHdr")]
56    pub grp_hdr: GroupHeader771,
57    #[serde(rename = "RptgReq")]
58    pub rptg_req: Vec<ReportingRequest51>,
59}
60
61impl Validate for AccountReportingRequestV05 {
62    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
63        self.grp_hdr
64            .validate(&helpers::child_path(path, "GrpHdr"), config, collector);
65        for item in &self.rptg_req {
66            item.validate(&helpers::child_path(path, "RptgReq"), config, collector);
67        }
68    }
69}
70
71// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
72#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
73pub struct AccountSchemeName1Choice1 {
74    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
75    pub cd: Option<String>,
76    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
77    pub prtry: Option<String>,
78}
79
80impl Validate for AccountSchemeName1Choice1 {
81    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
82        if let Some(ref val) = self.cd {
83            helpers::validate_length(
84                val,
85                "Cd",
86                Some(1),
87                Some(4),
88                &helpers::child_path(path, "Cd"),
89                config,
90                collector,
91            );
92        }
93        if let Some(ref val) = self.prtry {
94            helpers::validate_length(
95                val,
96                "Prtry",
97                Some(1),
98                Some(35),
99                &helpers::child_path(path, "Prtry"),
100                config,
101                collector,
102            );
103        }
104        if let Some(ref val) = self.prtry {
105            helpers::validate_pattern(
106                val,
107                "Prtry",
108                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
109                &helpers::child_path(path, "Prtry"),
110                config,
111                collector,
112            );
113        }
114    }
115}
116
117// 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.
118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
119pub struct ActiveOrHistoricCurrencyAndAmount {
120    #[serde(rename = "@Ccy")]
121    pub ccy: String,
122    #[serde(rename = "$value")]
123    pub value: f64,
124}
125
126impl Validate for ActiveOrHistoricCurrencyAndAmount {
127    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {}
128}
129
130// AddressType2Code: Address is the address to which delivery is to take place.
131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
132pub enum AddressType2Code {
133    #[default]
134    #[serde(rename = "ADDR")]
135    CodeADDR,
136    #[serde(rename = "PBOX")]
137    CodePBOX,
138    #[serde(rename = "HOME")]
139    CodeHOME,
140    #[serde(rename = "BIZZ")]
141    CodeBIZZ,
142    #[serde(rename = "MLTO")]
143    CodeMLTO,
144    #[serde(rename = "DLVY")]
145    CodeDLVY,
146}
147
148impl Validate for AddressType2Code {
149    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
150        // Enum validation is typically empty
151    }
152}
153
154// AddressType3Choice1: Type of address expressed as a proprietary code.
155#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
156pub struct AddressType3Choice1 {
157    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
158    pub cd: Option<AddressType2Code>,
159    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
160    pub prtry: Option<GenericIdentification301>,
161}
162
163impl Validate for AddressType3Choice1 {
164    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
165        if let Some(ref val) = self.cd
166            && config.validate_optional_fields
167        {
168            val.validate(&helpers::child_path(path, "Cd"), config, collector);
169        }
170        if let Some(ref val) = self.prtry
171            && config.validate_optional_fields
172        {
173            val.validate(&helpers::child_path(path, "Prtry"), config, collector);
174        }
175    }
176}
177
178// BalanceSubType1Choice1: Specifies a proprietary code for the balance type.
179#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
180pub struct BalanceSubType1Choice1 {
181    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
182    pub cd: Option<String>,
183    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
184    pub prtry: Option<String>,
185}
186
187impl Validate for BalanceSubType1Choice1 {
188    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
189        if let Some(ref val) = self.cd {
190            helpers::validate_length(
191                val,
192                "Cd",
193                Some(1),
194                Some(4),
195                &helpers::child_path(path, "Cd"),
196                config,
197                collector,
198            );
199        }
200        if let Some(ref val) = self.prtry {
201            helpers::validate_length(
202                val,
203                "Prtry",
204                Some(1),
205                Some(35),
206                &helpers::child_path(path, "Prtry"),
207                config,
208                collector,
209            );
210        }
211        if let Some(ref val) = self.prtry {
212            helpers::validate_pattern(
213                val,
214                "Prtry",
215                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
216                &helpers::child_path(path, "Prtry"),
217                config,
218                collector,
219            );
220        }
221    }
222}
223
224// BalanceType10Choice1: Balance type, in a proprietary format.
225#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
226pub struct BalanceType10Choice1 {
227    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
228    pub cd: Option<String>,
229    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
230    pub prtry: Option<String>,
231}
232
233impl Validate for BalanceType10Choice1 {
234    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
235        if let Some(ref val) = self.cd {
236            helpers::validate_length(
237                val,
238                "Cd",
239                Some(1),
240                Some(4),
241                &helpers::child_path(path, "Cd"),
242                config,
243                collector,
244            );
245        }
246        if let Some(ref val) = self.prtry {
247            helpers::validate_length(
248                val,
249                "Prtry",
250                Some(1),
251                Some(35),
252                &helpers::child_path(path, "Prtry"),
253                config,
254                collector,
255            );
256        }
257        if let Some(ref val) = self.prtry {
258            helpers::validate_pattern(
259                val,
260                "Prtry",
261                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
262                &helpers::child_path(path, "Prtry"),
263                config,
264                collector,
265            );
266        }
267    }
268}
269
270// BalanceType131: Specifies the balance sub-type.
271#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
272pub struct BalanceType131 {
273    #[serde(rename = "CdOrPrtry")]
274    pub cd_or_prtry: BalanceType10Choice1,
275    #[serde(rename = "SubTp", skip_serializing_if = "Option::is_none")]
276    pub sub_tp: Option<BalanceSubType1Choice1>,
277}
278
279impl Validate for BalanceType131 {
280    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
281        self.cd_or_prtry
282            .validate(&helpers::child_path(path, "CdOrPrtry"), config, collector);
283        if let Some(ref val) = self.sub_tp
284            && config.validate_optional_fields
285        {
286            val.validate(&helpers::child_path(path, "SubTp"), config, collector);
287        }
288    }
289}
290
291// BranchAndFinancialInstitutionIdentification61: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
292#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
293pub struct BranchAndFinancialInstitutionIdentification61 {
294    #[serde(rename = "FinInstnId")]
295    pub fin_instn_id: FinancialInstitutionIdentification181,
296}
297
298impl Validate for BranchAndFinancialInstitutionIdentification61 {
299    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
300        self.fin_instn_id
301            .validate(&helpers::child_path(path, "FinInstnId"), config, collector);
302    }
303}
304
305// CashAccount381: Specifies an alternate assumed name for the identification of the account.
306#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
307pub struct CashAccount381 {
308    #[serde(rename = "Id")]
309    pub id: AccountIdentification4Choice1,
310    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
311    pub tp: Option<CashAccountType2Choice1>,
312    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
313    pub ccy: Option<String>,
314    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
315    pub nm: Option<String>,
316    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
317    pub prxy: Option<ProxyAccountIdentification11>,
318}
319
320impl Validate for CashAccount381 {
321    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
322        self.id
323            .validate(&helpers::child_path(path, "Id"), config, collector);
324        if let Some(ref val) = self.tp
325            && config.validate_optional_fields
326        {
327            val.validate(&helpers::child_path(path, "Tp"), config, collector);
328        }
329        if let Some(ref val) = self.ccy {
330            helpers::validate_pattern(
331                val,
332                "Ccy",
333                "[A-Z]{3,3}",
334                &helpers::child_path(path, "Ccy"),
335                config,
336                collector,
337            );
338        }
339        if let Some(ref val) = self.nm {
340            helpers::validate_length(
341                val,
342                "Nm",
343                Some(1),
344                Some(70),
345                &helpers::child_path(path, "Nm"),
346                config,
347                collector,
348            );
349        }
350        if let Some(ref val) = self.nm {
351            helpers::validate_pattern(
352                val,
353                "Nm",
354                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
355                &helpers::child_path(path, "Nm"),
356                config,
357                collector,
358            );
359        }
360        if let Some(ref val) = self.prxy
361            && config.validate_optional_fields
362        {
363            val.validate(&helpers::child_path(path, "Prxy"), config, collector);
364        }
365    }
366}
367
368// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
369#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
370pub struct CashAccountType2Choice1 {
371    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
372    pub cd: Option<String>,
373    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
374    pub prtry: Option<String>,
375}
376
377impl Validate for CashAccountType2Choice1 {
378    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
379        if let Some(ref val) = self.cd {
380            helpers::validate_length(
381                val,
382                "Cd",
383                Some(1),
384                Some(4),
385                &helpers::child_path(path, "Cd"),
386                config,
387                collector,
388            );
389        }
390        if let Some(ref val) = self.prtry {
391            helpers::validate_length(
392                val,
393                "Prtry",
394                Some(1),
395                Some(35),
396                &helpers::child_path(path, "Prtry"),
397                config,
398                collector,
399            );
400        }
401        if let Some(ref val) = self.prtry {
402            helpers::validate_pattern(
403                val,
404                "Prtry",
405                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
406                &helpers::child_path(path, "Prtry"),
407                config,
408                collector,
409            );
410        }
411    }
412}
413
414// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
415#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
416pub struct ClearingSystemIdentification2Choice1 {
417    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
418    pub cd: Option<String>,
419}
420
421impl Validate for ClearingSystemIdentification2Choice1 {
422    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
423        if let Some(ref val) = self.cd {
424            helpers::validate_length(
425                val,
426                "Cd",
427                Some(1),
428                Some(5),
429                &helpers::child_path(path, "Cd"),
430                config,
431                collector,
432            );
433        }
434    }
435}
436
437// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
438#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
439pub struct ClearingSystemMemberIdentification21 {
440    #[serde(rename = "ClrSysId")]
441    pub clr_sys_id: ClearingSystemIdentification2Choice1,
442    #[serde(rename = "MmbId")]
443    pub mmb_id: String,
444}
445
446impl Validate for ClearingSystemMemberIdentification21 {
447    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
448        self.clr_sys_id
449            .validate(&helpers::child_path(path, "ClrSysId"), config, collector);
450        helpers::validate_length(
451            &self.mmb_id,
452            "MmbId",
453            Some(1),
454            Some(28),
455            &helpers::child_path(path, "MmbId"),
456            config,
457            collector,
458        );
459        helpers::validate_pattern(
460            &self.mmb_id,
461            "MmbId",
462            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
463            &helpers::child_path(path, "MmbId"),
464            config,
465            collector,
466        );
467    }
468}
469
470// CreditDebitCode: Operation is a decrease.
471#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
472pub enum CreditDebitCode {
473    #[default]
474    #[serde(rename = "CRDT")]
475    CodeCRDT,
476    #[serde(rename = "DBIT")]
477    CodeDBIT,
478}
479
480impl Validate for CreditDebitCode {
481    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
482        // Enum validation is typically empty
483    }
484}
485
486// DateAndPlaceOfBirth11: Country where a person was born.
487#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
488pub struct DateAndPlaceOfBirth11 {
489    #[serde(rename = "BirthDt")]
490    pub birth_dt: String,
491    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
492    pub prvc_of_birth: Option<String>,
493    #[serde(rename = "CityOfBirth")]
494    pub city_of_birth: String,
495    #[serde(rename = "CtryOfBirth")]
496    pub ctry_of_birth: String,
497}
498
499impl Validate for DateAndPlaceOfBirth11 {
500    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
501        if let Some(ref val) = self.prvc_of_birth {
502            helpers::validate_length(
503                val,
504                "PrvcOfBirth",
505                Some(1),
506                Some(35),
507                &helpers::child_path(path, "PrvcOfBirth"),
508                config,
509                collector,
510            );
511        }
512        if let Some(ref val) = self.prvc_of_birth {
513            helpers::validate_pattern(
514                val,
515                "PrvcOfBirth",
516                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
517                &helpers::child_path(path, "PrvcOfBirth"),
518                config,
519                collector,
520            );
521        }
522        helpers::validate_length(
523            &self.city_of_birth,
524            "CityOfBirth",
525            Some(1),
526            Some(35),
527            &helpers::child_path(path, "CityOfBirth"),
528            config,
529            collector,
530        );
531        helpers::validate_pattern(
532            &self.city_of_birth,
533            "CityOfBirth",
534            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
535            &helpers::child_path(path, "CityOfBirth"),
536            config,
537            collector,
538        );
539        helpers::validate_pattern(
540            &self.ctry_of_birth,
541            "CtryOfBirth",
542            "[A-Z]{2,2}",
543            &helpers::child_path(path, "CtryOfBirth"),
544            config,
545            collector,
546        );
547    }
548}
549
550// DatePeriodDetails1: End date of the range.
551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
552pub struct DatePeriodDetails1 {
553    #[serde(rename = "FrDt")]
554    pub fr_dt: String,
555    #[serde(rename = "ToDt", skip_serializing_if = "Option::is_none")]
556    pub to_dt: Option<String>,
557}
558
559impl Validate for DatePeriodDetails1 {
560    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {}
561}
562
563// EntryStatus1Choice1: Entry status, in a proprietary form.
564#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
565pub struct EntryStatus1Choice1 {
566    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
567    pub cd: Option<String>,
568    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
569    pub prtry: Option<String>,
570}
571
572impl Validate for EntryStatus1Choice1 {
573    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
574        if let Some(ref val) = self.cd {
575            helpers::validate_length(
576                val,
577                "Cd",
578                Some(1),
579                Some(4),
580                &helpers::child_path(path, "Cd"),
581                config,
582                collector,
583            );
584        }
585        if let Some(ref val) = self.prtry {
586            helpers::validate_length(
587                val,
588                "Prtry",
589                Some(1),
590                Some(35),
591                &helpers::child_path(path, "Prtry"),
592                config,
593                collector,
594            );
595        }
596        if let Some(ref val) = self.prtry {
597            helpers::validate_pattern(
598                val,
599                "Prtry",
600                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
601                &helpers::child_path(path, "Prtry"),
602                config,
603                collector,
604            );
605        }
606    }
607}
608
609// FinancialInstitutionIdentification181: Information that locates and identifies a specific address, as defined by postal services.
610#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
611pub struct FinancialInstitutionIdentification181 {
612    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
613    pub bicfi: Option<String>,
614    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
615    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
616    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
617    pub lei: Option<String>,
618    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
619    pub nm: Option<String>,
620    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
621    pub pstl_adr: Option<PostalAddress242>,
622}
623
624impl Validate for FinancialInstitutionIdentification181 {
625    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
626        if let Some(ref val) = self.bicfi {
627            helpers::validate_pattern(
628                val,
629                "BICFI",
630                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
631                &helpers::child_path(path, "BICFI"),
632                config,
633                collector,
634            );
635        }
636        if let Some(ref val) = self.clr_sys_mmb_id
637            && config.validate_optional_fields
638        {
639            val.validate(&helpers::child_path(path, "ClrSysMmbId"), config, collector);
640        }
641        if let Some(ref val) = self.lei {
642            helpers::validate_pattern(
643                val,
644                "LEI",
645                "[A-Z0-9]{18,18}[0-9]{2,2}",
646                &helpers::child_path(path, "LEI"),
647                config,
648                collector,
649            );
650        }
651        if let Some(ref val) = self.nm {
652            helpers::validate_length(
653                val,
654                "Nm",
655                Some(1),
656                Some(140),
657                &helpers::child_path(path, "Nm"),
658                config,
659                collector,
660            );
661        }
662        if let Some(ref val) = self.nm {
663            helpers::validate_pattern(
664                val,
665                "Nm",
666                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
667                &helpers::child_path(path, "Nm"),
668                config,
669                collector,
670            );
671        }
672        if let Some(ref val) = self.pstl_adr
673            && config.validate_optional_fields
674        {
675            val.validate(&helpers::child_path(path, "PstlAdr"), config, collector);
676        }
677    }
678}
679
680// FloorLimitType1Code: Floor limit applies to both credit and debit entries.
681#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
682pub enum FloorLimitType1Code {
683    #[default]
684    #[serde(rename = "CRED")]
685    CodeCRED,
686    #[serde(rename = "DEBT")]
687    CodeDEBT,
688    #[serde(rename = "BOTH")]
689    CodeBOTH,
690}
691
692impl Validate for FloorLimitType1Code {
693    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
694        // Enum validation is typically empty
695    }
696}
697
698// GenericAccountIdentification11: Entity that assigns the identification.
699#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
700pub struct GenericAccountIdentification11 {
701    #[serde(rename = "Id")]
702    pub id: String,
703    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
704    pub schme_nm: Option<AccountSchemeName1Choice1>,
705    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
706    pub issr: Option<String>,
707}
708
709impl Validate for GenericAccountIdentification11 {
710    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
711        helpers::validate_length(
712            &self.id,
713            "Id",
714            Some(1),
715            Some(34),
716            &helpers::child_path(path, "Id"),
717            config,
718            collector,
719        );
720        helpers::validate_pattern(
721            &self.id,
722            "Id",
723            "([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)",
724            &helpers::child_path(path, "Id"),
725            config,
726            collector,
727        );
728        if let Some(ref val) = self.schme_nm
729            && config.validate_optional_fields
730        {
731            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
732        }
733        if let Some(ref val) = self.issr {
734            helpers::validate_length(
735                val,
736                "Issr",
737                Some(1),
738                Some(35),
739                &helpers::child_path(path, "Issr"),
740                config,
741                collector,
742            );
743        }
744        if let Some(ref val) = self.issr {
745            helpers::validate_pattern(
746                val,
747                "Issr",
748                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
749                &helpers::child_path(path, "Issr"),
750                config,
751                collector,
752            );
753        }
754    }
755}
756
757// GenericIdentification301: Short textual description of the scheme.
758#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
759pub struct GenericIdentification301 {
760    #[serde(rename = "Id")]
761    pub id: String,
762    #[serde(rename = "Issr")]
763    pub issr: String,
764    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
765    pub schme_nm: Option<String>,
766}
767
768impl Validate for GenericIdentification301 {
769    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
770        helpers::validate_pattern(
771            &self.id,
772            "Id",
773            "[a-zA-Z0-9]{4}",
774            &helpers::child_path(path, "Id"),
775            config,
776            collector,
777        );
778        helpers::validate_length(
779            &self.issr,
780            "Issr",
781            Some(1),
782            Some(35),
783            &helpers::child_path(path, "Issr"),
784            config,
785            collector,
786        );
787        helpers::validate_pattern(
788            &self.issr,
789            "Issr",
790            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
791            &helpers::child_path(path, "Issr"),
792            config,
793            collector,
794        );
795        if let Some(ref val) = self.schme_nm {
796            helpers::validate_length(
797                val,
798                "SchmeNm",
799                Some(1),
800                Some(35),
801                &helpers::child_path(path, "SchmeNm"),
802                config,
803                collector,
804            );
805        }
806        if let Some(ref val) = self.schme_nm {
807            helpers::validate_pattern(
808                val,
809                "SchmeNm",
810                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
811                &helpers::child_path(path, "SchmeNm"),
812                config,
813                collector,
814            );
815        }
816    }
817}
818
819// GenericOrganisationIdentification11: Entity that assigns the identification.
820#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
821pub struct GenericOrganisationIdentification11 {
822    #[serde(rename = "Id")]
823    pub id: String,
824    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
825    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
826    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
827    pub issr: Option<String>,
828}
829
830impl Validate for GenericOrganisationIdentification11 {
831    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
832        helpers::validate_length(
833            &self.id,
834            "Id",
835            Some(1),
836            Some(35),
837            &helpers::child_path(path, "Id"),
838            config,
839            collector,
840        );
841        helpers::validate_pattern(
842            &self.id,
843            "Id",
844            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
845            &helpers::child_path(path, "Id"),
846            config,
847            collector,
848        );
849        if let Some(ref val) = self.schme_nm
850            && config.validate_optional_fields
851        {
852            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
853        }
854        if let Some(ref val) = self.issr {
855            helpers::validate_length(
856                val,
857                "Issr",
858                Some(1),
859                Some(35),
860                &helpers::child_path(path, "Issr"),
861                config,
862                collector,
863            );
864        }
865        if let Some(ref val) = self.issr {
866            helpers::validate_pattern(
867                val,
868                "Issr",
869                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
870                &helpers::child_path(path, "Issr"),
871                config,
872                collector,
873            );
874        }
875    }
876}
877
878// GenericPersonIdentification11: Entity that assigns the identification.
879#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
880pub struct GenericPersonIdentification11 {
881    #[serde(rename = "Id")]
882    pub id: String,
883    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
884    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
885    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
886    pub issr: Option<String>,
887}
888
889impl Validate for GenericPersonIdentification11 {
890    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
891        helpers::validate_length(
892            &self.id,
893            "Id",
894            Some(1),
895            Some(35),
896            &helpers::child_path(path, "Id"),
897            config,
898            collector,
899        );
900        helpers::validate_pattern(
901            &self.id,
902            "Id",
903            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
904            &helpers::child_path(path, "Id"),
905            config,
906            collector,
907        );
908        if let Some(ref val) = self.schme_nm
909            && config.validate_optional_fields
910        {
911            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
912        }
913        if let Some(ref val) = self.issr {
914            helpers::validate_length(
915                val,
916                "Issr",
917                Some(1),
918                Some(35),
919                &helpers::child_path(path, "Issr"),
920                config,
921                collector,
922            );
923        }
924        if let Some(ref val) = self.issr {
925            helpers::validate_pattern(
926                val,
927                "Issr",
928                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
929                &helpers::child_path(path, "Issr"),
930                config,
931                collector,
932            );
933        }
934    }
935}
936
937// GroupHeader771: Identification of the party that is sending the message, when different from the account owner.
938#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
939pub struct GroupHeader771 {
940    #[serde(rename = "MsgId")]
941    pub msg_id: String,
942    #[serde(rename = "CreDtTm")]
943    pub cre_dt_tm: String,
944    #[serde(rename = "MsgSndr", skip_serializing_if = "Option::is_none")]
945    pub msg_sndr: Option<Party40Choice1>,
946}
947
948impl Validate for GroupHeader771 {
949    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
950        helpers::validate_length(
951            &self.msg_id,
952            "MsgId",
953            Some(1),
954            Some(35),
955            &helpers::child_path(path, "MsgId"),
956            config,
957            collector,
958        );
959        helpers::validate_pattern(
960            &self.msg_id,
961            "MsgId",
962            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
963            &helpers::child_path(path, "MsgId"),
964            config,
965            collector,
966        );
967        helpers::validate_pattern(
968            &self.cre_dt_tm,
969            "CreDtTm",
970            ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
971            &helpers::child_path(path, "CreDtTm"),
972            config,
973            collector,
974        );
975        if let Some(ref val) = self.msg_sndr
976            && config.validate_optional_fields
977        {
978            val.validate(&helpers::child_path(path, "MsgSndr"), config, collector);
979        }
980    }
981}
982
983// Limit2: Indicates whether the floor limit applies to credit, to debit or to both credit and debit entries.
984#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
985pub struct Limit2 {
986    #[serde(rename = "Amt")]
987    pub amt: ActiveOrHistoricCurrencyAndAmount,
988    #[serde(rename = "CdtDbtInd")]
989    pub cdt_dbt_ind: FloorLimitType1Code,
990}
991
992impl Validate for Limit2 {
993    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
994        self.amt
995            .validate(&helpers::child_path(path, "Amt"), config, collector);
996        self.cdt_dbt_ind
997            .validate(&helpers::child_path(path, "CdtDbtInd"), config, collector);
998    }
999}
1000
1001// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
1002#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1003pub struct OrganisationIdentification291 {
1004    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
1005    pub any_bic: Option<String>,
1006    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1007    pub lei: Option<String>,
1008    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1009    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
1010}
1011
1012impl Validate for OrganisationIdentification291 {
1013    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1014        if let Some(ref val) = self.any_bic {
1015            helpers::validate_pattern(
1016                val,
1017                "AnyBIC",
1018                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
1019                &helpers::child_path(path, "AnyBIC"),
1020                config,
1021                collector,
1022            );
1023        }
1024        if let Some(ref val) = self.lei {
1025            helpers::validate_pattern(
1026                val,
1027                "LEI",
1028                "[A-Z0-9]{18,18}[0-9]{2,2}",
1029                &helpers::child_path(path, "LEI"),
1030                config,
1031                collector,
1032            );
1033        }
1034        if let Some(ref vec) = self.othr
1035            && config.validate_optional_fields
1036        {
1037            for item in vec {
1038                item.validate(&helpers::child_path(path, "Othr"), config, collector);
1039            }
1040        }
1041    }
1042}
1043
1044// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
1045#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1046pub struct OrganisationIdentificationSchemeName1Choice1 {
1047    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1048    pub cd: Option<String>,
1049    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1050    pub prtry: Option<String>,
1051}
1052
1053impl Validate for OrganisationIdentificationSchemeName1Choice1 {
1054    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1055        if let Some(ref val) = self.cd {
1056            helpers::validate_length(
1057                val,
1058                "Cd",
1059                Some(1),
1060                Some(4),
1061                &helpers::child_path(path, "Cd"),
1062                config,
1063                collector,
1064            );
1065        }
1066        if let Some(ref val) = self.prtry {
1067            helpers::validate_length(
1068                val,
1069                "Prtry",
1070                Some(1),
1071                Some(35),
1072                &helpers::child_path(path, "Prtry"),
1073                config,
1074                collector,
1075            );
1076        }
1077        if let Some(ref val) = self.prtry {
1078            helpers::validate_pattern(
1079                val,
1080                "Prtry",
1081                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1082                &helpers::child_path(path, "Prtry"),
1083                config,
1084                collector,
1085            );
1086        }
1087    }
1088}
1089
1090// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
1091#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1092pub struct Party38Choice1 {
1093    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
1094    pub org_id: Option<OrganisationIdentification291>,
1095    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
1096    pub prvt_id: Option<PersonIdentification131>,
1097}
1098
1099impl Validate for Party38Choice1 {
1100    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1101        if let Some(ref val) = self.org_id
1102            && config.validate_optional_fields
1103        {
1104            val.validate(&helpers::child_path(path, "OrgId"), config, collector);
1105        }
1106        if let Some(ref val) = self.prvt_id
1107            && config.validate_optional_fields
1108        {
1109            val.validate(&helpers::child_path(path, "PrvtId"), config, collector);
1110        }
1111    }
1112}
1113
1114// Party40Choice1: Identification of a financial institution.
1115#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1116pub struct Party40Choice1 {
1117    #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
1118    pub pty: Option<PartyIdentification1351>,
1119    #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
1120    pub agt: Option<BranchAndFinancialInstitutionIdentification61>,
1121}
1122
1123impl Validate for Party40Choice1 {
1124    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1125        if let Some(ref val) = self.pty
1126            && config.validate_optional_fields
1127        {
1128            val.validate(&helpers::child_path(path, "Pty"), config, collector);
1129        }
1130        if let Some(ref val) = self.agt
1131            && config.validate_optional_fields
1132        {
1133            val.validate(&helpers::child_path(path, "Agt"), config, collector);
1134        }
1135    }
1136}
1137
1138// PartyIdentification1351: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
1139#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1140pub struct PartyIdentification1351 {
1141    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1142    pub nm: Option<String>,
1143    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1144    pub pstl_adr: Option<PostalAddress241>,
1145    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1146    pub id: Option<Party38Choice1>,
1147    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
1148    pub ctry_of_res: Option<String>,
1149}
1150
1151impl Validate for PartyIdentification1351 {
1152    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1153        if let Some(ref val) = self.nm {
1154            helpers::validate_length(
1155                val,
1156                "Nm",
1157                Some(1),
1158                Some(140),
1159                &helpers::child_path(path, "Nm"),
1160                config,
1161                collector,
1162            );
1163        }
1164        if let Some(ref val) = self.nm {
1165            helpers::validate_pattern(
1166                val,
1167                "Nm",
1168                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1169                &helpers::child_path(path, "Nm"),
1170                config,
1171                collector,
1172            );
1173        }
1174        if let Some(ref val) = self.pstl_adr
1175            && config.validate_optional_fields
1176        {
1177            val.validate(&helpers::child_path(path, "PstlAdr"), config, collector);
1178        }
1179        if let Some(ref val) = self.id
1180            && config.validate_optional_fields
1181        {
1182            val.validate(&helpers::child_path(path, "Id"), config, collector);
1183        }
1184        if let Some(ref val) = self.ctry_of_res {
1185            helpers::validate_pattern(
1186                val,
1187                "CtryOfRes",
1188                "[A-Z]{2,2}",
1189                &helpers::child_path(path, "CtryOfRes"),
1190                config,
1191                collector,
1192            );
1193        }
1194    }
1195}
1196
1197// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
1198#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1199pub struct PersonIdentification131 {
1200    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
1201    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
1202    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1203    pub othr: Option<Vec<GenericPersonIdentification11>>,
1204}
1205
1206impl Validate for PersonIdentification131 {
1207    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1208        if let Some(ref val) = self.dt_and_plc_of_birth
1209            && config.validate_optional_fields
1210        {
1211            val.validate(
1212                &helpers::child_path(path, "DtAndPlcOfBirth"),
1213                config,
1214                collector,
1215            );
1216        }
1217        if let Some(ref vec) = self.othr
1218            && config.validate_optional_fields
1219        {
1220            for item in vec {
1221                item.validate(&helpers::child_path(path, "Othr"), config, collector);
1222            }
1223        }
1224    }
1225}
1226
1227// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
1228#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1229pub struct PersonIdentificationSchemeName1Choice1 {
1230    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1231    pub cd: Option<String>,
1232    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1233    pub prtry: Option<String>,
1234}
1235
1236impl Validate for PersonIdentificationSchemeName1Choice1 {
1237    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1238        if let Some(ref val) = self.cd {
1239            helpers::validate_length(
1240                val,
1241                "Cd",
1242                Some(1),
1243                Some(4),
1244                &helpers::child_path(path, "Cd"),
1245                config,
1246                collector,
1247            );
1248        }
1249        if let Some(ref val) = self.prtry {
1250            helpers::validate_length(
1251                val,
1252                "Prtry",
1253                Some(1),
1254                Some(35),
1255                &helpers::child_path(path, "Prtry"),
1256                config,
1257                collector,
1258            );
1259        }
1260        if let Some(ref val) = self.prtry {
1261            helpers::validate_pattern(
1262                val,
1263                "Prtry",
1264                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1265                &helpers::child_path(path, "Prtry"),
1266                config,
1267                collector,
1268            );
1269        }
1270    }
1271}
1272
1273// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
1274#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1275pub struct PostalAddress241 {
1276    #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
1277    pub adr_tp: Option<AddressType3Choice1>,
1278    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1279    pub dept: Option<String>,
1280    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1281    pub sub_dept: Option<String>,
1282    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1283    pub strt_nm: Option<String>,
1284    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1285    pub bldg_nb: Option<String>,
1286    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1287    pub bldg_nm: Option<String>,
1288    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1289    pub flr: Option<String>,
1290    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1291    pub pst_bx: Option<String>,
1292    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1293    pub room: Option<String>,
1294    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1295    pub pst_cd: Option<String>,
1296    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1297    pub twn_nm: Option<String>,
1298    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1299    pub twn_lctn_nm: Option<String>,
1300    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1301    pub dstrct_nm: Option<String>,
1302    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1303    pub ctry_sub_dvsn: Option<String>,
1304    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1305    pub ctry: Option<String>,
1306    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1307    pub adr_line: Option<Vec<String>>,
1308}
1309
1310impl Validate for PostalAddress241 {
1311    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1312        if let Some(ref val) = self.adr_tp
1313            && config.validate_optional_fields
1314        {
1315            val.validate(&helpers::child_path(path, "AdrTp"), config, collector);
1316        }
1317        if let Some(ref val) = self.dept {
1318            helpers::validate_length(
1319                val,
1320                "Dept",
1321                Some(1),
1322                Some(70),
1323                &helpers::child_path(path, "Dept"),
1324                config,
1325                collector,
1326            );
1327        }
1328        if let Some(ref val) = self.dept {
1329            helpers::validate_pattern(
1330                val,
1331                "Dept",
1332                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1333                &helpers::child_path(path, "Dept"),
1334                config,
1335                collector,
1336            );
1337        }
1338        if let Some(ref val) = self.sub_dept {
1339            helpers::validate_length(
1340                val,
1341                "SubDept",
1342                Some(1),
1343                Some(70),
1344                &helpers::child_path(path, "SubDept"),
1345                config,
1346                collector,
1347            );
1348        }
1349        if let Some(ref val) = self.sub_dept {
1350            helpers::validate_pattern(
1351                val,
1352                "SubDept",
1353                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1354                &helpers::child_path(path, "SubDept"),
1355                config,
1356                collector,
1357            );
1358        }
1359        if let Some(ref val) = self.strt_nm {
1360            helpers::validate_length(
1361                val,
1362                "StrtNm",
1363                Some(1),
1364                Some(70),
1365                &helpers::child_path(path, "StrtNm"),
1366                config,
1367                collector,
1368            );
1369        }
1370        if let Some(ref val) = self.strt_nm {
1371            helpers::validate_pattern(
1372                val,
1373                "StrtNm",
1374                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1375                &helpers::child_path(path, "StrtNm"),
1376                config,
1377                collector,
1378            );
1379        }
1380        if let Some(ref val) = self.bldg_nb {
1381            helpers::validate_length(
1382                val,
1383                "BldgNb",
1384                Some(1),
1385                Some(16),
1386                &helpers::child_path(path, "BldgNb"),
1387                config,
1388                collector,
1389            );
1390        }
1391        if let Some(ref val) = self.bldg_nb {
1392            helpers::validate_pattern(
1393                val,
1394                "BldgNb",
1395                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1396                &helpers::child_path(path, "BldgNb"),
1397                config,
1398                collector,
1399            );
1400        }
1401        if let Some(ref val) = self.bldg_nm {
1402            helpers::validate_length(
1403                val,
1404                "BldgNm",
1405                Some(1),
1406                Some(35),
1407                &helpers::child_path(path, "BldgNm"),
1408                config,
1409                collector,
1410            );
1411        }
1412        if let Some(ref val) = self.bldg_nm {
1413            helpers::validate_pattern(
1414                val,
1415                "BldgNm",
1416                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1417                &helpers::child_path(path, "BldgNm"),
1418                config,
1419                collector,
1420            );
1421        }
1422        if let Some(ref val) = self.flr {
1423            helpers::validate_length(
1424                val,
1425                "Flr",
1426                Some(1),
1427                Some(70),
1428                &helpers::child_path(path, "Flr"),
1429                config,
1430                collector,
1431            );
1432        }
1433        if let Some(ref val) = self.flr {
1434            helpers::validate_pattern(
1435                val,
1436                "Flr",
1437                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1438                &helpers::child_path(path, "Flr"),
1439                config,
1440                collector,
1441            );
1442        }
1443        if let Some(ref val) = self.pst_bx {
1444            helpers::validate_length(
1445                val,
1446                "PstBx",
1447                Some(1),
1448                Some(16),
1449                &helpers::child_path(path, "PstBx"),
1450                config,
1451                collector,
1452            );
1453        }
1454        if let Some(ref val) = self.pst_bx {
1455            helpers::validate_pattern(
1456                val,
1457                "PstBx",
1458                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1459                &helpers::child_path(path, "PstBx"),
1460                config,
1461                collector,
1462            );
1463        }
1464        if let Some(ref val) = self.room {
1465            helpers::validate_length(
1466                val,
1467                "Room",
1468                Some(1),
1469                Some(70),
1470                &helpers::child_path(path, "Room"),
1471                config,
1472                collector,
1473            );
1474        }
1475        if let Some(ref val) = self.room {
1476            helpers::validate_pattern(
1477                val,
1478                "Room",
1479                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1480                &helpers::child_path(path, "Room"),
1481                config,
1482                collector,
1483            );
1484        }
1485        if let Some(ref val) = self.pst_cd {
1486            helpers::validate_length(
1487                val,
1488                "PstCd",
1489                Some(1),
1490                Some(16),
1491                &helpers::child_path(path, "PstCd"),
1492                config,
1493                collector,
1494            );
1495        }
1496        if let Some(ref val) = self.pst_cd {
1497            helpers::validate_pattern(
1498                val,
1499                "PstCd",
1500                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1501                &helpers::child_path(path, "PstCd"),
1502                config,
1503                collector,
1504            );
1505        }
1506        if let Some(ref val) = self.twn_nm {
1507            helpers::validate_length(
1508                val,
1509                "TwnNm",
1510                Some(1),
1511                Some(35),
1512                &helpers::child_path(path, "TwnNm"),
1513                config,
1514                collector,
1515            );
1516        }
1517        if let Some(ref val) = self.twn_nm {
1518            helpers::validate_pattern(
1519                val,
1520                "TwnNm",
1521                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1522                &helpers::child_path(path, "TwnNm"),
1523                config,
1524                collector,
1525            );
1526        }
1527        if let Some(ref val) = self.twn_lctn_nm {
1528            helpers::validate_length(
1529                val,
1530                "TwnLctnNm",
1531                Some(1),
1532                Some(35),
1533                &helpers::child_path(path, "TwnLctnNm"),
1534                config,
1535                collector,
1536            );
1537        }
1538        if let Some(ref val) = self.twn_lctn_nm {
1539            helpers::validate_pattern(
1540                val,
1541                "TwnLctnNm",
1542                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1543                &helpers::child_path(path, "TwnLctnNm"),
1544                config,
1545                collector,
1546            );
1547        }
1548        if let Some(ref val) = self.dstrct_nm {
1549            helpers::validate_length(
1550                val,
1551                "DstrctNm",
1552                Some(1),
1553                Some(35),
1554                &helpers::child_path(path, "DstrctNm"),
1555                config,
1556                collector,
1557            );
1558        }
1559        if let Some(ref val) = self.dstrct_nm {
1560            helpers::validate_pattern(
1561                val,
1562                "DstrctNm",
1563                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1564                &helpers::child_path(path, "DstrctNm"),
1565                config,
1566                collector,
1567            );
1568        }
1569        if let Some(ref val) = self.ctry_sub_dvsn {
1570            helpers::validate_length(
1571                val,
1572                "CtrySubDvsn",
1573                Some(1),
1574                Some(35),
1575                &helpers::child_path(path, "CtrySubDvsn"),
1576                config,
1577                collector,
1578            );
1579        }
1580        if let Some(ref val) = self.ctry_sub_dvsn {
1581            helpers::validate_pattern(
1582                val,
1583                "CtrySubDvsn",
1584                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1585                &helpers::child_path(path, "CtrySubDvsn"),
1586                config,
1587                collector,
1588            );
1589        }
1590        if let Some(ref val) = self.ctry {
1591            helpers::validate_pattern(
1592                val,
1593                "Ctry",
1594                "[A-Z]{2,2}",
1595                &helpers::child_path(path, "Ctry"),
1596                config,
1597                collector,
1598            );
1599        }
1600        if let Some(ref vec) = self.adr_line {
1601            for item in vec {
1602                helpers::validate_length(
1603                    item,
1604                    "AdrLine",
1605                    Some(1),
1606                    Some(70),
1607                    &helpers::child_path(path, "AdrLine"),
1608                    config,
1609                    collector,
1610                );
1611            }
1612        }
1613        if let Some(ref vec) = self.adr_line {
1614            for item in vec {
1615                helpers::validate_pattern(
1616                    item,
1617                    "AdrLine",
1618                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1619                    &helpers::child_path(path, "AdrLine"),
1620                    config,
1621                    collector,
1622                );
1623            }
1624        }
1625    }
1626}
1627
1628// PostalAddress242: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
1629#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1630pub struct PostalAddress242 {
1631    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1632    pub dept: Option<String>,
1633    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1634    pub sub_dept: Option<String>,
1635    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1636    pub strt_nm: Option<String>,
1637    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1638    pub bldg_nb: Option<String>,
1639    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1640    pub bldg_nm: Option<String>,
1641    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1642    pub flr: Option<String>,
1643    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1644    pub pst_bx: Option<String>,
1645    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1646    pub room: Option<String>,
1647    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1648    pub pst_cd: Option<String>,
1649    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1650    pub twn_nm: Option<String>,
1651    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1652    pub twn_lctn_nm: Option<String>,
1653    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1654    pub dstrct_nm: Option<String>,
1655    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1656    pub ctry_sub_dvsn: Option<String>,
1657    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1658    pub ctry: Option<String>,
1659    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1660    pub adr_line: Option<Vec<String>>,
1661}
1662
1663impl Validate for PostalAddress242 {
1664    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1665        if let Some(ref val) = self.dept {
1666            helpers::validate_length(
1667                val,
1668                "Dept",
1669                Some(1),
1670                Some(70),
1671                &helpers::child_path(path, "Dept"),
1672                config,
1673                collector,
1674            );
1675        }
1676        if let Some(ref val) = self.dept {
1677            helpers::validate_pattern(
1678                val,
1679                "Dept",
1680                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1681                &helpers::child_path(path, "Dept"),
1682                config,
1683                collector,
1684            );
1685        }
1686        if let Some(ref val) = self.sub_dept {
1687            helpers::validate_length(
1688                val,
1689                "SubDept",
1690                Some(1),
1691                Some(70),
1692                &helpers::child_path(path, "SubDept"),
1693                config,
1694                collector,
1695            );
1696        }
1697        if let Some(ref val) = self.sub_dept {
1698            helpers::validate_pattern(
1699                val,
1700                "SubDept",
1701                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1702                &helpers::child_path(path, "SubDept"),
1703                config,
1704                collector,
1705            );
1706        }
1707        if let Some(ref val) = self.strt_nm {
1708            helpers::validate_length(
1709                val,
1710                "StrtNm",
1711                Some(1),
1712                Some(70),
1713                &helpers::child_path(path, "StrtNm"),
1714                config,
1715                collector,
1716            );
1717        }
1718        if let Some(ref val) = self.strt_nm {
1719            helpers::validate_pattern(
1720                val,
1721                "StrtNm",
1722                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1723                &helpers::child_path(path, "StrtNm"),
1724                config,
1725                collector,
1726            );
1727        }
1728        if let Some(ref val) = self.bldg_nb {
1729            helpers::validate_length(
1730                val,
1731                "BldgNb",
1732                Some(1),
1733                Some(16),
1734                &helpers::child_path(path, "BldgNb"),
1735                config,
1736                collector,
1737            );
1738        }
1739        if let Some(ref val) = self.bldg_nb {
1740            helpers::validate_pattern(
1741                val,
1742                "BldgNb",
1743                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1744                &helpers::child_path(path, "BldgNb"),
1745                config,
1746                collector,
1747            );
1748        }
1749        if let Some(ref val) = self.bldg_nm {
1750            helpers::validate_length(
1751                val,
1752                "BldgNm",
1753                Some(1),
1754                Some(35),
1755                &helpers::child_path(path, "BldgNm"),
1756                config,
1757                collector,
1758            );
1759        }
1760        if let Some(ref val) = self.bldg_nm {
1761            helpers::validate_pattern(
1762                val,
1763                "BldgNm",
1764                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1765                &helpers::child_path(path, "BldgNm"),
1766                config,
1767                collector,
1768            );
1769        }
1770        if let Some(ref val) = self.flr {
1771            helpers::validate_length(
1772                val,
1773                "Flr",
1774                Some(1),
1775                Some(70),
1776                &helpers::child_path(path, "Flr"),
1777                config,
1778                collector,
1779            );
1780        }
1781        if let Some(ref val) = self.flr {
1782            helpers::validate_pattern(
1783                val,
1784                "Flr",
1785                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1786                &helpers::child_path(path, "Flr"),
1787                config,
1788                collector,
1789            );
1790        }
1791        if let Some(ref val) = self.pst_bx {
1792            helpers::validate_length(
1793                val,
1794                "PstBx",
1795                Some(1),
1796                Some(16),
1797                &helpers::child_path(path, "PstBx"),
1798                config,
1799                collector,
1800            );
1801        }
1802        if let Some(ref val) = self.pst_bx {
1803            helpers::validate_pattern(
1804                val,
1805                "PstBx",
1806                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1807                &helpers::child_path(path, "PstBx"),
1808                config,
1809                collector,
1810            );
1811        }
1812        if let Some(ref val) = self.room {
1813            helpers::validate_length(
1814                val,
1815                "Room",
1816                Some(1),
1817                Some(70),
1818                &helpers::child_path(path, "Room"),
1819                config,
1820                collector,
1821            );
1822        }
1823        if let Some(ref val) = self.room {
1824            helpers::validate_pattern(
1825                val,
1826                "Room",
1827                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1828                &helpers::child_path(path, "Room"),
1829                config,
1830                collector,
1831            );
1832        }
1833        if let Some(ref val) = self.pst_cd {
1834            helpers::validate_length(
1835                val,
1836                "PstCd",
1837                Some(1),
1838                Some(16),
1839                &helpers::child_path(path, "PstCd"),
1840                config,
1841                collector,
1842            );
1843        }
1844        if let Some(ref val) = self.pst_cd {
1845            helpers::validate_pattern(
1846                val,
1847                "PstCd",
1848                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1849                &helpers::child_path(path, "PstCd"),
1850                config,
1851                collector,
1852            );
1853        }
1854        if let Some(ref val) = self.twn_nm {
1855            helpers::validate_length(
1856                val,
1857                "TwnNm",
1858                Some(1),
1859                Some(35),
1860                &helpers::child_path(path, "TwnNm"),
1861                config,
1862                collector,
1863            );
1864        }
1865        if let Some(ref val) = self.twn_nm {
1866            helpers::validate_pattern(
1867                val,
1868                "TwnNm",
1869                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1870                &helpers::child_path(path, "TwnNm"),
1871                config,
1872                collector,
1873            );
1874        }
1875        if let Some(ref val) = self.twn_lctn_nm {
1876            helpers::validate_length(
1877                val,
1878                "TwnLctnNm",
1879                Some(1),
1880                Some(35),
1881                &helpers::child_path(path, "TwnLctnNm"),
1882                config,
1883                collector,
1884            );
1885        }
1886        if let Some(ref val) = self.twn_lctn_nm {
1887            helpers::validate_pattern(
1888                val,
1889                "TwnLctnNm",
1890                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1891                &helpers::child_path(path, "TwnLctnNm"),
1892                config,
1893                collector,
1894            );
1895        }
1896        if let Some(ref val) = self.dstrct_nm {
1897            helpers::validate_length(
1898                val,
1899                "DstrctNm",
1900                Some(1),
1901                Some(35),
1902                &helpers::child_path(path, "DstrctNm"),
1903                config,
1904                collector,
1905            );
1906        }
1907        if let Some(ref val) = self.dstrct_nm {
1908            helpers::validate_pattern(
1909                val,
1910                "DstrctNm",
1911                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1912                &helpers::child_path(path, "DstrctNm"),
1913                config,
1914                collector,
1915            );
1916        }
1917        if let Some(ref val) = self.ctry_sub_dvsn {
1918            helpers::validate_length(
1919                val,
1920                "CtrySubDvsn",
1921                Some(1),
1922                Some(35),
1923                &helpers::child_path(path, "CtrySubDvsn"),
1924                config,
1925                collector,
1926            );
1927        }
1928        if let Some(ref val) = self.ctry_sub_dvsn {
1929            helpers::validate_pattern(
1930                val,
1931                "CtrySubDvsn",
1932                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1933                &helpers::child_path(path, "CtrySubDvsn"),
1934                config,
1935                collector,
1936            );
1937        }
1938        if let Some(ref val) = self.ctry {
1939            helpers::validate_pattern(
1940                val,
1941                "Ctry",
1942                "[A-Z]{2,2}",
1943                &helpers::child_path(path, "Ctry"),
1944                config,
1945                collector,
1946            );
1947        }
1948        if let Some(ref vec) = self.adr_line {
1949            for item in vec {
1950                helpers::validate_length(
1951                    item,
1952                    "AdrLine",
1953                    Some(1),
1954                    Some(70),
1955                    &helpers::child_path(path, "AdrLine"),
1956                    config,
1957                    collector,
1958                );
1959            }
1960        }
1961        if let Some(ref vec) = self.adr_line {
1962            for item in vec {
1963                helpers::validate_pattern(
1964                    item,
1965                    "AdrLine",
1966                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1967                    &helpers::child_path(path, "AdrLine"),
1968                    config,
1969                    collector,
1970                );
1971            }
1972        }
1973    }
1974}
1975
1976// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
1977#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1978pub struct ProxyAccountIdentification11 {
1979    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1980    pub tp: Option<ProxyAccountType1Choice1>,
1981    #[serde(rename = "Id")]
1982    pub id: String,
1983}
1984
1985impl Validate for ProxyAccountIdentification11 {
1986    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1987        if let Some(ref val) = self.tp
1988            && config.validate_optional_fields
1989        {
1990            val.validate(&helpers::child_path(path, "Tp"), config, collector);
1991        }
1992        helpers::validate_length(
1993            &self.id,
1994            "Id",
1995            Some(1),
1996            Some(320),
1997            &helpers::child_path(path, "Id"),
1998            config,
1999            collector,
2000        );
2001        helpers::validate_pattern(
2002            &self.id,
2003            "Id",
2004            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2005            &helpers::child_path(path, "Id"),
2006            config,
2007            collector,
2008        );
2009    }
2010}
2011
2012// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
2013#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2014pub struct ProxyAccountType1Choice1 {
2015    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2016    pub cd: Option<String>,
2017    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2018    pub prtry: Option<String>,
2019}
2020
2021impl Validate for ProxyAccountType1Choice1 {
2022    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2023        if let Some(ref val) = self.cd {
2024            helpers::validate_length(
2025                val,
2026                "Cd",
2027                Some(1),
2028                Some(4),
2029                &helpers::child_path(path, "Cd"),
2030                config,
2031                collector,
2032            );
2033        }
2034        if let Some(ref val) = self.prtry {
2035            helpers::validate_length(
2036                val,
2037                "Prtry",
2038                Some(1),
2039                Some(35),
2040                &helpers::child_path(path, "Prtry"),
2041                config,
2042                collector,
2043            );
2044        }
2045        if let Some(ref val) = self.prtry {
2046            helpers::validate_pattern(
2047                val,
2048                "Prtry",
2049                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2050                &helpers::child_path(path, "Prtry"),
2051                config,
2052                collector,
2053            );
2054        }
2055    }
2056}
2057
2058// QueryType3Code: Specifies that the query requests that only items that have changed since the last query be returned.
2059#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2060pub enum QueryType3Code {
2061    #[default]
2062    #[serde(rename = "ALLL")]
2063    CodeALLL,
2064    #[serde(rename = "CHNG")]
2065    CodeCHNG,
2066    #[serde(rename = "MODF")]
2067    CodeMODF,
2068}
2069
2070impl Validate for QueryType3Code {
2071    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
2072        // Enum validation is typically empty
2073    }
2074}
2075
2076// ReportingPeriod21: Specifies whether all matching items need to be reported or only those items that are new or have changed since the last similar request was made.
2077#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2078pub struct ReportingPeriod21 {
2079    #[serde(rename = "FrToDt")]
2080    pub fr_to_dt: DatePeriodDetails1,
2081    #[serde(rename = "FrToTm", skip_serializing_if = "Option::is_none")]
2082    pub fr_to_tm: Option<TimePeriodDetails11>,
2083    #[serde(rename = "Tp")]
2084    pub tp: QueryType3Code,
2085}
2086
2087impl Validate for ReportingPeriod21 {
2088    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2089        self.fr_to_dt
2090            .validate(&helpers::child_path(path, "FrToDt"), config, collector);
2091        if let Some(ref val) = self.fr_to_tm
2092            && config.validate_optional_fields
2093        {
2094            val.validate(&helpers::child_path(path, "FrToTm"), config, collector);
2095        }
2096        self.tp
2097            .validate(&helpers::child_path(path, "Tp"), config, collector);
2098    }
2099}
2100
2101// ReportingRequest51: Provides details on the requested balance reporting.
2102#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2103pub struct ReportingRequest51 {
2104    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2105    pub id: Option<String>,
2106    #[serde(rename = "ReqdMsgNmId")]
2107    pub reqd_msg_nm_id: String,
2108    #[serde(rename = "Acct", skip_serializing_if = "Option::is_none")]
2109    pub acct: Option<CashAccount381>,
2110    #[serde(rename = "AcctOwnr")]
2111    pub acct_ownr: Party40Choice1,
2112    #[serde(rename = "AcctSvcr", skip_serializing_if = "Option::is_none")]
2113    pub acct_svcr: Option<BranchAndFinancialInstitutionIdentification61>,
2114    #[serde(rename = "RptgPrd", skip_serializing_if = "Option::is_none")]
2115    pub rptg_prd: Option<ReportingPeriod21>,
2116    #[serde(rename = "RptgSeq", skip_serializing_if = "Option::is_none")]
2117    pub rptg_seq: Option<SequenceRange1Choice1>,
2118    #[serde(rename = "ReqdTxTp", skip_serializing_if = "Option::is_none")]
2119    pub reqd_tx_tp: Option<TransactionType21>,
2120    #[serde(rename = "ReqdBalTp", skip_serializing_if = "Option::is_none")]
2121    pub reqd_bal_tp: Option<Vec<BalanceType131>>,
2122}
2123
2124impl Validate for ReportingRequest51 {
2125    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2126        if let Some(ref val) = self.id {
2127            helpers::validate_length(
2128                val,
2129                "Id",
2130                Some(1),
2131                Some(35),
2132                &helpers::child_path(path, "Id"),
2133                config,
2134                collector,
2135            );
2136        }
2137        if let Some(ref val) = self.id {
2138            helpers::validate_pattern(
2139                val,
2140                "Id",
2141                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2142                &helpers::child_path(path, "Id"),
2143                config,
2144                collector,
2145            );
2146        }
2147        helpers::validate_length(
2148            &self.reqd_msg_nm_id,
2149            "ReqdMsgNmId",
2150            Some(1),
2151            Some(35),
2152            &helpers::child_path(path, "ReqdMsgNmId"),
2153            config,
2154            collector,
2155        );
2156        helpers::validate_pattern(
2157            &self.reqd_msg_nm_id,
2158            "ReqdMsgNmId",
2159            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2160            &helpers::child_path(path, "ReqdMsgNmId"),
2161            config,
2162            collector,
2163        );
2164        if let Some(ref val) = self.acct
2165            && config.validate_optional_fields
2166        {
2167            val.validate(&helpers::child_path(path, "Acct"), config, collector);
2168        }
2169        self.acct_ownr
2170            .validate(&helpers::child_path(path, "AcctOwnr"), config, collector);
2171        if let Some(ref val) = self.acct_svcr
2172            && config.validate_optional_fields
2173        {
2174            val.validate(&helpers::child_path(path, "AcctSvcr"), config, collector);
2175        }
2176        if let Some(ref val) = self.rptg_prd
2177            && config.validate_optional_fields
2178        {
2179            val.validate(&helpers::child_path(path, "RptgPrd"), config, collector);
2180        }
2181        if let Some(ref val) = self.rptg_seq
2182            && config.validate_optional_fields
2183        {
2184            val.validate(&helpers::child_path(path, "RptgSeq"), config, collector);
2185        }
2186        if let Some(ref val) = self.reqd_tx_tp
2187            && config.validate_optional_fields
2188        {
2189            val.validate(&helpers::child_path(path, "ReqdTxTp"), config, collector);
2190        }
2191        if let Some(ref vec) = self.reqd_bal_tp
2192            && config.validate_optional_fields
2193        {
2194            for item in vec {
2195                item.validate(&helpers::child_path(path, "ReqdBalTp"), config, collector);
2196            }
2197        }
2198    }
2199}
2200
2201// SequenceRange1Choice1: Specified sequence to be excluded.
2202#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2203pub struct SequenceRange1Choice1 {
2204    #[serde(rename = "FrSeq", skip_serializing_if = "Option::is_none")]
2205    pub fr_seq: Option<String>,
2206    #[serde(rename = "ToSeq", skip_serializing_if = "Option::is_none")]
2207    pub to_seq: Option<String>,
2208    #[serde(rename = "FrToSeq", skip_serializing_if = "Option::is_none")]
2209    pub fr_to_seq: Option<Vec<SequenceRange11>>,
2210    #[serde(rename = "EQSeq", skip_serializing_if = "Option::is_none")]
2211    pub eq_seq: Option<Vec<String>>,
2212    #[serde(rename = "NEQSeq", skip_serializing_if = "Option::is_none")]
2213    pub neq_seq: Option<Vec<String>>,
2214}
2215
2216impl Validate for SequenceRange1Choice1 {
2217    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2218        if let Some(ref val) = self.fr_seq {
2219            helpers::validate_length(
2220                val,
2221                "FrSeq",
2222                Some(1),
2223                Some(35),
2224                &helpers::child_path(path, "FrSeq"),
2225                config,
2226                collector,
2227            );
2228        }
2229        if let Some(ref val) = self.fr_seq {
2230            helpers::validate_pattern(
2231                val,
2232                "FrSeq",
2233                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2234                &helpers::child_path(path, "FrSeq"),
2235                config,
2236                collector,
2237            );
2238        }
2239        if let Some(ref val) = self.to_seq {
2240            helpers::validate_length(
2241                val,
2242                "ToSeq",
2243                Some(1),
2244                Some(35),
2245                &helpers::child_path(path, "ToSeq"),
2246                config,
2247                collector,
2248            );
2249        }
2250        if let Some(ref val) = self.to_seq {
2251            helpers::validate_pattern(
2252                val,
2253                "ToSeq",
2254                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2255                &helpers::child_path(path, "ToSeq"),
2256                config,
2257                collector,
2258            );
2259        }
2260        if let Some(ref vec) = self.fr_to_seq
2261            && config.validate_optional_fields
2262        {
2263            for item in vec {
2264                item.validate(&helpers::child_path(path, "FrToSeq"), config, collector);
2265            }
2266        }
2267        if let Some(ref vec) = self.eq_seq {
2268            for item in vec {
2269                helpers::validate_length(
2270                    item,
2271                    "EQSeq",
2272                    Some(1),
2273                    Some(35),
2274                    &helpers::child_path(path, "EQSeq"),
2275                    config,
2276                    collector,
2277                );
2278            }
2279        }
2280        if let Some(ref vec) = self.eq_seq {
2281            for item in vec {
2282                helpers::validate_pattern(
2283                    item,
2284                    "EQSeq",
2285                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2286                    &helpers::child_path(path, "EQSeq"),
2287                    config,
2288                    collector,
2289                );
2290            }
2291        }
2292        if let Some(ref vec) = self.neq_seq {
2293            for item in vec {
2294                helpers::validate_length(
2295                    item,
2296                    "NEQSeq",
2297                    Some(1),
2298                    Some(35),
2299                    &helpers::child_path(path, "NEQSeq"),
2300                    config,
2301                    collector,
2302                );
2303            }
2304        }
2305        if let Some(ref vec) = self.neq_seq {
2306            for item in vec {
2307                helpers::validate_pattern(
2308                    item,
2309                    "NEQSeq",
2310                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2311                    &helpers::child_path(path, "NEQSeq"),
2312                    config,
2313                    collector,
2314                );
2315            }
2316        }
2317    }
2318}
2319
2320// SequenceRange11: End sequence of the range.
2321#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2322pub struct SequenceRange11 {
2323    #[serde(rename = "FrSeq")]
2324    pub fr_seq: String,
2325    #[serde(rename = "ToSeq")]
2326    pub to_seq: String,
2327}
2328
2329impl Validate for SequenceRange11 {
2330    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2331        helpers::validate_length(
2332            &self.fr_seq,
2333            "FrSeq",
2334            Some(1),
2335            Some(35),
2336            &helpers::child_path(path, "FrSeq"),
2337            config,
2338            collector,
2339        );
2340        helpers::validate_pattern(
2341            &self.fr_seq,
2342            "FrSeq",
2343            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2344            &helpers::child_path(path, "FrSeq"),
2345            config,
2346            collector,
2347        );
2348        helpers::validate_length(
2349            &self.to_seq,
2350            "ToSeq",
2351            Some(1),
2352            Some(35),
2353            &helpers::child_path(path, "ToSeq"),
2354            config,
2355            collector,
2356        );
2357        helpers::validate_pattern(
2358            &self.to_seq,
2359            "ToSeq",
2360            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
2361            &helpers::child_path(path, "ToSeq"),
2362            config,
2363            collector,
2364        );
2365    }
2366}
2367
2368// TimePeriodDetails11: Time at which the time span ends.
2369#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2370pub struct TimePeriodDetails11 {
2371    #[serde(rename = "FrTm")]
2372    pub fr_tm: String,
2373    #[serde(rename = "ToTm", skip_serializing_if = "Option::is_none")]
2374    pub to_tm: Option<String>,
2375}
2376
2377impl Validate for TimePeriodDetails11 {
2378    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2379        helpers::validate_pattern(
2380            &self.fr_tm,
2381            "FrTm",
2382            ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
2383            &helpers::child_path(path, "FrTm"),
2384            config,
2385            collector,
2386        );
2387        if let Some(ref val) = self.to_tm {
2388            helpers::validate_pattern(
2389                val,
2390                "ToTm",
2391                ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
2392                &helpers::child_path(path, "ToTm"),
2393                config,
2394                collector,
2395            );
2396        }
2397    }
2398}
2399
2400// TransactionType21: Specifies the minimum value of entries to be reported in the requested message.
2401#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2402pub struct TransactionType21 {
2403    #[serde(rename = "Sts")]
2404    pub sts: EntryStatus1Choice1,
2405    #[serde(rename = "CdtDbtInd")]
2406    pub cdt_dbt_ind: CreditDebitCode,
2407    #[serde(rename = "FlrLmt", skip_serializing_if = "Option::is_none")]
2408    pub flr_lmt: Option<Vec<Limit2>>,
2409}
2410
2411impl Validate for TransactionType21 {
2412    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
2413        self.sts
2414            .validate(&helpers::child_path(path, "Sts"), config, collector);
2415        self.cdt_dbt_ind
2416            .validate(&helpers::child_path(path, "CdtDbtInd"), config, collector);
2417        if let Some(ref vec) = self.flr_lmt
2418            && config.validate_optional_fields
2419        {
2420            for item in vec {
2421                item.validate(&helpers::child_path(path, "FlrLmt"), config, collector);
2422            }
2423        }
2424    }
2425}