mx_message/document/
camt_108_001_01.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// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
53#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
54pub struct AccountSchemeName1Choice1 {
55    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
56    pub cd: Option<String>,
57    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
58    pub prtry: Option<String>,
59}
60
61impl Validate for AccountSchemeName1Choice1 {
62    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
63        if let Some(ref val) = self.cd {
64            helpers::validate_length(
65                val,
66                "Cd",
67                Some(1),
68                Some(4),
69                &helpers::child_path(path, "Cd"),
70                config,
71                collector,
72            );
73        }
74        if let Some(ref val) = self.prtry {
75            helpers::validate_length(
76                val,
77                "Prtry",
78                Some(1),
79                Some(35),
80                &helpers::child_path(path, "Prtry"),
81                config,
82                collector,
83            );
84        }
85        if let Some(ref val) = self.prtry {
86            helpers::validate_pattern(
87                val,
88                "Prtry",
89                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
90                &helpers::child_path(path, "Prtry"),
91                config,
92                collector,
93            );
94        }
95    }
96}
97
98// BranchAndFinancialInstitutionIdentification61: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
99#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
100pub struct BranchAndFinancialInstitutionIdentification61 {
101    #[serde(rename = "FinInstnId")]
102    pub fin_instn_id: FinancialInstitutionIdentification181,
103}
104
105impl Validate for BranchAndFinancialInstitutionIdentification61 {
106    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
107        self.fin_instn_id
108            .validate(&helpers::child_path(path, "FinInstnId"), config, collector);
109    }
110}
111
112// CBPRAmount: CBPR_Amount
113#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
114pub struct CBPRAmount {
115    #[serde(rename = "@Ccy")]
116    pub ccy: String,
117    #[serde(rename = "$value")]
118    pub value: f64,
119}
120
121impl Validate for CBPRAmount {
122    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {}
123}
124
125// CBPR_ChequeCancellationReasonCode: Reason is provided as narrative information in the additional reason information.
126#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
127pub enum CBPRChequeCancellationReasonCode {
128    #[default]
129    #[serde(rename = "DUPL")]
130    CodeDUPL,
131    #[serde(rename = "CUST")]
132    CodeCUST,
133    #[serde(rename = "FRAD")]
134    CodeFRAD,
135    #[serde(rename = "LOST")]
136    CodeLOST,
137    #[serde(rename = "NARR")]
138    CodeNARR,
139}
140
141impl Validate for CBPRChequeCancellationReasonCode {
142    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
143        // Enum validation is typically empty
144    }
145}
146
147// CashAccount401: Specifies an alternate assumed name for the identification of the account.
148#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
149pub struct CashAccount401 {
150    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
151    pub id: Option<AccountIdentification4Choice1>,
152    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
153    pub tp: Option<CashAccountType2Choice1>,
154    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
155    pub ccy: Option<String>,
156    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
157    pub nm: Option<String>,
158    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
159    pub prxy: Option<ProxyAccountIdentification11>,
160}
161
162impl Validate for CashAccount401 {
163    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
164        if let Some(ref val) = self.id
165            && config.validate_optional_fields
166        {
167            val.validate(&helpers::child_path(path, "Id"), config, collector);
168        }
169        if let Some(ref val) = self.tp
170            && config.validate_optional_fields
171        {
172            val.validate(&helpers::child_path(path, "Tp"), config, collector);
173        }
174        if let Some(ref val) = self.ccy {
175            helpers::validate_pattern(
176                val,
177                "Ccy",
178                "[A-Z]{3,3}",
179                &helpers::child_path(path, "Ccy"),
180                config,
181                collector,
182            );
183        }
184        if let Some(ref val) = self.nm {
185            helpers::validate_length(
186                val,
187                "Nm",
188                Some(1),
189                Some(70),
190                &helpers::child_path(path, "Nm"),
191                config,
192                collector,
193            );
194        }
195        if let Some(ref val) = self.nm {
196            helpers::validate_pattern(
197                val,
198                "Nm",
199                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
200                &helpers::child_path(path, "Nm"),
201                config,
202                collector,
203            );
204        }
205        if let Some(ref val) = self.prxy
206            && config.validate_optional_fields
207        {
208            val.validate(&helpers::child_path(path, "Prxy"), config, collector);
209        }
210    }
211}
212
213// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
214#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
215pub struct CashAccountType2Choice1 {
216    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
217    pub cd: Option<String>,
218    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
219    pub prtry: Option<String>,
220}
221
222impl Validate for CashAccountType2Choice1 {
223    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
224        if let Some(ref val) = self.cd {
225            helpers::validate_length(
226                val,
227                "Cd",
228                Some(1),
229                Some(4),
230                &helpers::child_path(path, "Cd"),
231                config,
232                collector,
233            );
234        }
235        if let Some(ref val) = self.prtry {
236            helpers::validate_length(
237                val,
238                "Prtry",
239                Some(1),
240                Some(35),
241                &helpers::child_path(path, "Prtry"),
242                config,
243                collector,
244            );
245        }
246        if let Some(ref val) = self.prtry {
247            helpers::validate_pattern(
248                val,
249                "Prtry",
250                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
251                &helpers::child_path(path, "Prtry"),
252                config,
253                collector,
254            );
255        }
256    }
257}
258
259// Cheque151: Specifies the reason for stopping the payment of the cheque or a request for reimbursement authorisation.
260#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
261pub struct Cheque151 {
262    #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
263    pub instr_id: Option<String>,
264    #[serde(rename = "OrgnlInstrId")]
265    pub orgnl_instr_id: String,
266    #[serde(rename = "ChqNb")]
267    pub chq_nb: String,
268    #[serde(rename = "IsseDt")]
269    pub isse_dt: String,
270    #[serde(rename = "StlDt", skip_serializing_if = "Option::is_none")]
271    pub stl_dt: Option<String>,
272    #[serde(rename = "Amt")]
273    pub amt: CBPRAmount,
274    #[serde(rename = "FctvDt", skip_serializing_if = "Option::is_none")]
275    pub fctv_dt: Option<DateAndDateTime2Choice1>,
276    #[serde(rename = "DrwrAgt", skip_serializing_if = "Option::is_none")]
277    pub drwr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
278    #[serde(rename = "DrwrAgtAcct", skip_serializing_if = "Option::is_none")]
279    pub drwr_agt_acct: Option<CashAccount401>,
280    #[serde(rename = "Pyee", skip_serializing_if = "Option::is_none")]
281    pub pyee: Option<PartyIdentification1351>,
282    #[serde(rename = "ChqCxlOrStopRsn")]
283    pub chq_cxl_or_stop_rsn: ChequeCancellationReason11,
284}
285
286impl Validate for Cheque151 {
287    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
288        if let Some(ref val) = self.instr_id {
289            helpers::validate_length(
290                val,
291                "InstrId",
292                Some(1),
293                Some(35),
294                &helpers::child_path(path, "InstrId"),
295                config,
296                collector,
297            );
298        }
299        if let Some(ref val) = self.instr_id {
300            helpers::validate_pattern(
301                val,
302                "InstrId",
303                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
304                &helpers::child_path(path, "InstrId"),
305                config,
306                collector,
307            );
308        }
309        helpers::validate_length(
310            &self.orgnl_instr_id,
311            "OrgnlInstrId",
312            Some(1),
313            Some(35),
314            &helpers::child_path(path, "OrgnlInstrId"),
315            config,
316            collector,
317        );
318        helpers::validate_pattern(
319            &self.orgnl_instr_id,
320            "OrgnlInstrId",
321            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
322            &helpers::child_path(path, "OrgnlInstrId"),
323            config,
324            collector,
325        );
326        helpers::validate_length(
327            &self.chq_nb,
328            "ChqNb",
329            Some(1),
330            Some(16),
331            &helpers::child_path(path, "ChqNb"),
332            config,
333            collector,
334        );
335        helpers::validate_pattern(
336            &self.chq_nb,
337            "ChqNb",
338            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
339            &helpers::child_path(path, "ChqNb"),
340            config,
341            collector,
342        );
343        self.amt
344            .validate(&helpers::child_path(path, "Amt"), config, collector);
345        if let Some(ref val) = self.fctv_dt
346            && config.validate_optional_fields
347        {
348            val.validate(&helpers::child_path(path, "FctvDt"), config, collector);
349        }
350        if let Some(ref val) = self.drwr_agt
351            && config.validate_optional_fields
352        {
353            val.validate(&helpers::child_path(path, "DrwrAgt"), config, collector);
354        }
355        if let Some(ref val) = self.drwr_agt_acct
356            && config.validate_optional_fields
357        {
358            val.validate(&helpers::child_path(path, "DrwrAgtAcct"), config, collector);
359        }
360        if let Some(ref val) = self.pyee
361            && config.validate_optional_fields
362        {
363            val.validate(&helpers::child_path(path, "Pyee"), config, collector);
364        }
365        self.chq_cxl_or_stop_rsn.validate(
366            &helpers::child_path(path, "ChqCxlOrStopRsn"),
367            config,
368            collector,
369        );
370    }
371}
372
373// ChequeCancellationOrStopRequestV01: Specifies the details of the cheque.
374#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
375pub struct ChequeCancellationOrStopRequestV01 {
376    #[serde(rename = "GrpHdr")]
377    pub grp_hdr: GroupHeader1031,
378    #[serde(rename = "Chq")]
379    pub chq: Cheque151,
380}
381
382impl Validate for ChequeCancellationOrStopRequestV01 {
383    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
384        self.grp_hdr
385            .validate(&helpers::child_path(path, "GrpHdr"), config, collector);
386        self.chq
387            .validate(&helpers::child_path(path, "Chq"), config, collector);
388    }
389}
390
391// ChequeCancellationReason1Choice1: Reason, as published in an external code set.
392#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
393pub struct ChequeCancellationReason1Choice1 {
394    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
395    pub cd: Option<CBPRChequeCancellationReasonCode>,
396}
397
398impl Validate for ChequeCancellationReason1Choice1 {
399    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
400        if let Some(ref val) = self.cd
401            && config.validate_optional_fields
402        {
403            val.validate(&helpers::child_path(path, "Cd"), config, collector);
404        }
405    }
406}
407
408// ChequeCancellationReason11: Further details on the cancellation request reason.
409#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
410pub struct ChequeCancellationReason11 {
411    #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
412    pub orgtr: Option<ChequePartyRole1Code>,
413    #[serde(rename = "Rsn")]
414    pub rsn: ChequeCancellationReason1Choice1,
415    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
416    pub addtl_inf: Option<String>,
417}
418
419impl Validate for ChequeCancellationReason11 {
420    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
421        if let Some(ref val) = self.orgtr
422            && config.validate_optional_fields
423        {
424            val.validate(&helpers::child_path(path, "Orgtr"), config, collector);
425        }
426        self.rsn
427            .validate(&helpers::child_path(path, "Rsn"), config, collector);
428        if let Some(ref val) = self.addtl_inf {
429            helpers::validate_length(
430                val,
431                "AddtlInf",
432                Some(1),
433                Some(140),
434                &helpers::child_path(path, "AddtlInf"),
435                config,
436                collector,
437            );
438        }
439        if let Some(ref val) = self.addtl_inf {
440            helpers::validate_pattern(
441                val,
442                "AddtlInf",
443                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
444                &helpers::child_path(path, "AddtlInf"),
445                config,
446                collector,
447            );
448        }
449    }
450}
451
452// ChequePartyRole1Code: Party that issues a cheque ordering the drawee agent to pay a specific amount, upon demand, to the payee.
453#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
454pub enum ChequePartyRole1Code {
455    #[default]
456    #[serde(rename = "DWEA")]
457    CodeDWEA,
458    #[serde(rename = "DWRA")]
459    CodeDWRA,
460    #[serde(rename = "PAYE")]
461    CodePAYE,
462    #[serde(rename = "PAYR")]
463    CodePAYR,
464}
465
466impl Validate for ChequePartyRole1Code {
467    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
468        // Enum validation is typically empty
469    }
470}
471
472// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
473#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
474pub struct ClearingSystemIdentification2Choice1 {
475    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
476    pub cd: Option<String>,
477}
478
479impl Validate for ClearingSystemIdentification2Choice1 {
480    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
481        if let Some(ref val) = self.cd {
482            helpers::validate_length(
483                val,
484                "Cd",
485                Some(1),
486                Some(5),
487                &helpers::child_path(path, "Cd"),
488                config,
489                collector,
490            );
491        }
492    }
493}
494
495// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
496#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
497pub struct ClearingSystemMemberIdentification21 {
498    #[serde(rename = "ClrSysId")]
499    pub clr_sys_id: ClearingSystemIdentification2Choice1,
500    #[serde(rename = "MmbId")]
501    pub mmb_id: String,
502}
503
504impl Validate for ClearingSystemMemberIdentification21 {
505    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
506        self.clr_sys_id
507            .validate(&helpers::child_path(path, "ClrSysId"), config, collector);
508        helpers::validate_length(
509            &self.mmb_id,
510            "MmbId",
511            Some(1),
512            Some(28),
513            &helpers::child_path(path, "MmbId"),
514            config,
515            collector,
516        );
517        helpers::validate_pattern(
518            &self.mmb_id,
519            "MmbId",
520            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
521            &helpers::child_path(path, "MmbId"),
522            config,
523            collector,
524        );
525    }
526}
527
528// DateAndDateTime2Choice1: Specified date.
529#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
530pub struct DateAndDateTime2Choice1 {
531    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
532    pub dt: Option<String>,
533}
534
535impl Validate for DateAndDateTime2Choice1 {
536    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {}
537}
538
539// DateAndPlaceOfBirth11: Country where a person was born.
540#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
541pub struct DateAndPlaceOfBirth11 {
542    #[serde(rename = "BirthDt")]
543    pub birth_dt: String,
544    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
545    pub prvc_of_birth: Option<String>,
546    #[serde(rename = "CityOfBirth")]
547    pub city_of_birth: String,
548    #[serde(rename = "CtryOfBirth")]
549    pub ctry_of_birth: String,
550}
551
552impl Validate for DateAndPlaceOfBirth11 {
553    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
554        if let Some(ref val) = self.prvc_of_birth {
555            helpers::validate_length(
556                val,
557                "PrvcOfBirth",
558                Some(1),
559                Some(35),
560                &helpers::child_path(path, "PrvcOfBirth"),
561                config,
562                collector,
563            );
564        }
565        if let Some(ref val) = self.prvc_of_birth {
566            helpers::validate_pattern(
567                val,
568                "PrvcOfBirth",
569                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
570                &helpers::child_path(path, "PrvcOfBirth"),
571                config,
572                collector,
573            );
574        }
575        helpers::validate_length(
576            &self.city_of_birth,
577            "CityOfBirth",
578            Some(1),
579            Some(35),
580            &helpers::child_path(path, "CityOfBirth"),
581            config,
582            collector,
583        );
584        helpers::validate_pattern(
585            &self.city_of_birth,
586            "CityOfBirth",
587            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
588            &helpers::child_path(path, "CityOfBirth"),
589            config,
590            collector,
591        );
592        helpers::validate_pattern(
593            &self.ctry_of_birth,
594            "CtryOfBirth",
595            "[A-Z]{2,2}",
596            &helpers::child_path(path, "CtryOfBirth"),
597            config,
598            collector,
599        );
600    }
601}
602
603// FinancialInstitutionIdentification181: Information that locates and identifies a specific address, as defined by postal services.
604#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
605pub struct FinancialInstitutionIdentification181 {
606    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
607    pub bicfi: Option<String>,
608    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
609    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
610    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
611    pub lei: Option<String>,
612    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
613    pub nm: Option<String>,
614    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
615    pub pstl_adr: Option<PostalAddress241>,
616}
617
618impl Validate for FinancialInstitutionIdentification181 {
619    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
620        if let Some(ref val) = self.bicfi {
621            helpers::validate_pattern(
622                val,
623                "BICFI",
624                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
625                &helpers::child_path(path, "BICFI"),
626                config,
627                collector,
628            );
629        }
630        if let Some(ref val) = self.clr_sys_mmb_id
631            && config.validate_optional_fields
632        {
633            val.validate(&helpers::child_path(path, "ClrSysMmbId"), config, collector);
634        }
635        if let Some(ref val) = self.lei {
636            helpers::validate_pattern(
637                val,
638                "LEI",
639                "[A-Z0-9]{18,18}[0-9]{2,2}",
640                &helpers::child_path(path, "LEI"),
641                config,
642                collector,
643            );
644        }
645        if let Some(ref val) = self.nm {
646            helpers::validate_length(
647                val,
648                "Nm",
649                Some(1),
650                Some(140),
651                &helpers::child_path(path, "Nm"),
652                config,
653                collector,
654            );
655        }
656        if let Some(ref val) = self.nm {
657            helpers::validate_pattern(
658                val,
659                "Nm",
660                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
661                &helpers::child_path(path, "Nm"),
662                config,
663                collector,
664            );
665        }
666        if let Some(ref val) = self.pstl_adr
667            && config.validate_optional_fields
668        {
669            val.validate(&helpers::child_path(path, "PstlAdr"), config, collector);
670        }
671    }
672}
673
674// GenericAccountIdentification11: Entity that assigns the identification.
675#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
676pub struct GenericAccountIdentification11 {
677    #[serde(rename = "Id")]
678    pub id: String,
679    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
680    pub schme_nm: Option<AccountSchemeName1Choice1>,
681    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
682    pub issr: Option<String>,
683}
684
685impl Validate for GenericAccountIdentification11 {
686    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
687        helpers::validate_length(
688            &self.id,
689            "Id",
690            Some(1),
691            Some(34),
692            &helpers::child_path(path, "Id"),
693            config,
694            collector,
695        );
696        helpers::validate_pattern(
697            &self.id,
698            "Id",
699            "([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)",
700            &helpers::child_path(path, "Id"),
701            config,
702            collector,
703        );
704        if let Some(ref val) = self.schme_nm
705            && config.validate_optional_fields
706        {
707            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
708        }
709        if let Some(ref val) = self.issr {
710            helpers::validate_length(
711                val,
712                "Issr",
713                Some(1),
714                Some(35),
715                &helpers::child_path(path, "Issr"),
716                config,
717                collector,
718            );
719        }
720        if let Some(ref val) = self.issr {
721            helpers::validate_pattern(
722                val,
723                "Issr",
724                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
725                &helpers::child_path(path, "Issr"),
726                config,
727                collector,
728            );
729        }
730    }
731}
732
733// GenericOrganisationIdentification11: Entity that assigns the identification.
734#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
735pub struct GenericOrganisationIdentification11 {
736    #[serde(rename = "Id")]
737    pub id: String,
738    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
739    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
740    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
741    pub issr: Option<String>,
742}
743
744impl Validate for GenericOrganisationIdentification11 {
745    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
746        helpers::validate_length(
747            &self.id,
748            "Id",
749            Some(1),
750            Some(35),
751            &helpers::child_path(path, "Id"),
752            config,
753            collector,
754        );
755        helpers::validate_pattern(
756            &self.id,
757            "Id",
758            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
759            &helpers::child_path(path, "Id"),
760            config,
761            collector,
762        );
763        if let Some(ref val) = self.schme_nm
764            && config.validate_optional_fields
765        {
766            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
767        }
768        if let Some(ref val) = self.issr {
769            helpers::validate_length(
770                val,
771                "Issr",
772                Some(1),
773                Some(35),
774                &helpers::child_path(path, "Issr"),
775                config,
776                collector,
777            );
778        }
779        if let Some(ref val) = self.issr {
780            helpers::validate_pattern(
781                val,
782                "Issr",
783                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
784                &helpers::child_path(path, "Issr"),
785                config,
786                collector,
787            );
788        }
789    }
790}
791
792// GenericPersonIdentification11: Entity that assigns the identification.
793#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
794pub struct GenericPersonIdentification11 {
795    #[serde(rename = "Id")]
796    pub id: String,
797    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
798    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
799    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
800    pub issr: Option<String>,
801}
802
803impl Validate for GenericPersonIdentification11 {
804    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
805        helpers::validate_length(
806            &self.id,
807            "Id",
808            Some(1),
809            Some(35),
810            &helpers::child_path(path, "Id"),
811            config,
812            collector,
813        );
814        helpers::validate_pattern(
815            &self.id,
816            "Id",
817            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
818            &helpers::child_path(path, "Id"),
819            config,
820            collector,
821        );
822        if let Some(ref val) = self.schme_nm
823            && config.validate_optional_fields
824        {
825            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
826        }
827        if let Some(ref val) = self.issr {
828            helpers::validate_length(
829                val,
830                "Issr",
831                Some(1),
832                Some(35),
833                &helpers::child_path(path, "Issr"),
834                config,
835                collector,
836            );
837        }
838        if let Some(ref val) = self.issr {
839            helpers::validate_pattern(
840                val,
841                "Issr",
842                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
843                &helpers::child_path(path, "Issr"),
844                config,
845                collector,
846            );
847        }
848    }
849}
850
851// GroupHeader1031: Number of individual cheques contained in the message.
852#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
853pub struct GroupHeader1031 {
854    #[serde(rename = "MsgId")]
855    pub msg_id: String,
856    #[serde(rename = "CreDtTm")]
857    pub cre_dt_tm: String,
858    #[serde(rename = "NbOfChqs")]
859    pub nb_of_chqs: Max15NumericTextfixed,
860}
861
862impl Validate for GroupHeader1031 {
863    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
864        helpers::validate_length(
865            &self.msg_id,
866            "MsgId",
867            Some(1),
868            Some(16),
869            &helpers::child_path(path, "MsgId"),
870            config,
871            collector,
872        );
873        helpers::validate_pattern(
874            &self.msg_id,
875            "MsgId",
876            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
877            &helpers::child_path(path, "MsgId"),
878            config,
879            collector,
880        );
881        helpers::validate_pattern(
882            &self.cre_dt_tm,
883            "CreDtTm",
884            ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
885            &helpers::child_path(path, "CreDtTm"),
886            config,
887            collector,
888        );
889        self.nb_of_chqs
890            .validate(&helpers::child_path(path, "NbOfChqs"), config, collector);
891    }
892}
893
894// Max15NumericText_fixed: 1
895#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
896pub enum Max15NumericTextfixed {
897    #[default]
898    #[serde(rename = "1")]
899    Code1,
900}
901
902impl Validate for Max15NumericTextfixed {
903    fn validate(&self, _path: &str, _config: &ParserConfig, _collector: &mut ErrorCollector) {
904        // Enum validation is typically empty
905    }
906}
907
908// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
909#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
910pub struct OrganisationIdentification291 {
911    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
912    pub any_bic: Option<String>,
913    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
914    pub lei: Option<String>,
915    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
916    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
917}
918
919impl Validate for OrganisationIdentification291 {
920    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
921        if let Some(ref val) = self.any_bic {
922            helpers::validate_pattern(
923                val,
924                "AnyBIC",
925                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
926                &helpers::child_path(path, "AnyBIC"),
927                config,
928                collector,
929            );
930        }
931        if let Some(ref val) = self.lei {
932            helpers::validate_pattern(
933                val,
934                "LEI",
935                "[A-Z0-9]{18,18}[0-9]{2,2}",
936                &helpers::child_path(path, "LEI"),
937                config,
938                collector,
939            );
940        }
941        if let Some(ref vec) = self.othr
942            && config.validate_optional_fields
943        {
944            for item in vec {
945                item.validate(&helpers::child_path(path, "Othr"), config, collector);
946            }
947        }
948    }
949}
950
951// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
952#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
953pub struct OrganisationIdentificationSchemeName1Choice1 {
954    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
955    pub cd: Option<String>,
956    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
957    pub prtry: Option<String>,
958}
959
960impl Validate for OrganisationIdentificationSchemeName1Choice1 {
961    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
962        if let Some(ref val) = self.cd {
963            helpers::validate_length(
964                val,
965                "Cd",
966                Some(1),
967                Some(4),
968                &helpers::child_path(path, "Cd"),
969                config,
970                collector,
971            );
972        }
973        if let Some(ref val) = self.prtry {
974            helpers::validate_length(
975                val,
976                "Prtry",
977                Some(1),
978                Some(35),
979                &helpers::child_path(path, "Prtry"),
980                config,
981                collector,
982            );
983        }
984        if let Some(ref val) = self.prtry {
985            helpers::validate_pattern(
986                val,
987                "Prtry",
988                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
989                &helpers::child_path(path, "Prtry"),
990                config,
991                collector,
992            );
993        }
994    }
995}
996
997// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
998#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
999pub struct Party38Choice1 {
1000    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
1001    pub org_id: Option<OrganisationIdentification291>,
1002    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
1003    pub prvt_id: Option<PersonIdentification131>,
1004}
1005
1006impl Validate for Party38Choice1 {
1007    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1008        if let Some(ref val) = self.org_id
1009            && config.validate_optional_fields
1010        {
1011            val.validate(&helpers::child_path(path, "OrgId"), config, collector);
1012        }
1013        if let Some(ref val) = self.prvt_id
1014            && config.validate_optional_fields
1015        {
1016            val.validate(&helpers::child_path(path, "PrvtId"), config, collector);
1017        }
1018    }
1019}
1020
1021// 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.
1022#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1023pub struct PartyIdentification1351 {
1024    #[serde(rename = "Nm")]
1025    pub nm: String,
1026    #[serde(rename = "PstlAdr")]
1027    pub pstl_adr: PostalAddress241,
1028    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1029    pub id: Option<Party38Choice1>,
1030    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
1031    pub ctry_of_res: Option<String>,
1032}
1033
1034impl Validate for PartyIdentification1351 {
1035    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1036        helpers::validate_length(
1037            &self.nm,
1038            "Nm",
1039            Some(1),
1040            Some(140),
1041            &helpers::child_path(path, "Nm"),
1042            config,
1043            collector,
1044        );
1045        helpers::validate_pattern(
1046            &self.nm,
1047            "Nm",
1048            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1049            &helpers::child_path(path, "Nm"),
1050            config,
1051            collector,
1052        );
1053        self.pstl_adr
1054            .validate(&helpers::child_path(path, "PstlAdr"), config, collector);
1055        if let Some(ref val) = self.id
1056            && config.validate_optional_fields
1057        {
1058            val.validate(&helpers::child_path(path, "Id"), config, collector);
1059        }
1060        if let Some(ref val) = self.ctry_of_res {
1061            helpers::validate_pattern(
1062                val,
1063                "CtryOfRes",
1064                "[A-Z]{2,2}",
1065                &helpers::child_path(path, "CtryOfRes"),
1066                config,
1067                collector,
1068            );
1069        }
1070    }
1071}
1072
1073// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
1074#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1075pub struct PersonIdentification131 {
1076    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
1077    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
1078    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1079    pub othr: Option<Vec<GenericPersonIdentification11>>,
1080}
1081
1082impl Validate for PersonIdentification131 {
1083    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1084        if let Some(ref val) = self.dt_and_plc_of_birth
1085            && config.validate_optional_fields
1086        {
1087            val.validate(
1088                &helpers::child_path(path, "DtAndPlcOfBirth"),
1089                config,
1090                collector,
1091            );
1092        }
1093        if let Some(ref vec) = self.othr
1094            && config.validate_optional_fields
1095        {
1096            for item in vec {
1097                item.validate(&helpers::child_path(path, "Othr"), config, collector);
1098            }
1099        }
1100    }
1101}
1102
1103// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
1104#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1105pub struct PersonIdentificationSchemeName1Choice1 {
1106    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1107    pub cd: Option<String>,
1108    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1109    pub prtry: Option<String>,
1110}
1111
1112impl Validate for PersonIdentificationSchemeName1Choice1 {
1113    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1114        if let Some(ref val) = self.cd {
1115            helpers::validate_length(
1116                val,
1117                "Cd",
1118                Some(1),
1119                Some(4),
1120                &helpers::child_path(path, "Cd"),
1121                config,
1122                collector,
1123            );
1124        }
1125        if let Some(ref val) = self.prtry {
1126            helpers::validate_length(
1127                val,
1128                "Prtry",
1129                Some(1),
1130                Some(35),
1131                &helpers::child_path(path, "Prtry"),
1132                config,
1133                collector,
1134            );
1135        }
1136        if let Some(ref val) = self.prtry {
1137            helpers::validate_pattern(
1138                val,
1139                "Prtry",
1140                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1141                &helpers::child_path(path, "Prtry"),
1142                config,
1143                collector,
1144            );
1145        }
1146    }
1147}
1148
1149// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
1150#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1151pub struct PostalAddress241 {
1152    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1153    pub dept: Option<String>,
1154    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1155    pub sub_dept: Option<String>,
1156    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1157    pub strt_nm: Option<String>,
1158    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1159    pub bldg_nb: Option<String>,
1160    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1161    pub bldg_nm: Option<String>,
1162    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1163    pub flr: Option<String>,
1164    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1165    pub pst_bx: Option<String>,
1166    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1167    pub room: Option<String>,
1168    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1169    pub pst_cd: Option<String>,
1170    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1171    pub twn_nm: Option<String>,
1172    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1173    pub twn_lctn_nm: Option<String>,
1174    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1175    pub dstrct_nm: Option<String>,
1176    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1177    pub ctry_sub_dvsn: Option<String>,
1178    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1179    pub ctry: Option<String>,
1180    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1181    pub adr_line: Option<Vec<String>>,
1182}
1183
1184impl Validate for PostalAddress241 {
1185    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1186        if let Some(ref val) = self.dept {
1187            helpers::validate_length(
1188                val,
1189                "Dept",
1190                Some(1),
1191                Some(70),
1192                &helpers::child_path(path, "Dept"),
1193                config,
1194                collector,
1195            );
1196        }
1197        if let Some(ref val) = self.dept {
1198            helpers::validate_pattern(
1199                val,
1200                "Dept",
1201                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1202                &helpers::child_path(path, "Dept"),
1203                config,
1204                collector,
1205            );
1206        }
1207        if let Some(ref val) = self.sub_dept {
1208            helpers::validate_length(
1209                val,
1210                "SubDept",
1211                Some(1),
1212                Some(70),
1213                &helpers::child_path(path, "SubDept"),
1214                config,
1215                collector,
1216            );
1217        }
1218        if let Some(ref val) = self.sub_dept {
1219            helpers::validate_pattern(
1220                val,
1221                "SubDept",
1222                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1223                &helpers::child_path(path, "SubDept"),
1224                config,
1225                collector,
1226            );
1227        }
1228        if let Some(ref val) = self.strt_nm {
1229            helpers::validate_length(
1230                val,
1231                "StrtNm",
1232                Some(1),
1233                Some(70),
1234                &helpers::child_path(path, "StrtNm"),
1235                config,
1236                collector,
1237            );
1238        }
1239        if let Some(ref val) = self.strt_nm {
1240            helpers::validate_pattern(
1241                val,
1242                "StrtNm",
1243                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1244                &helpers::child_path(path, "StrtNm"),
1245                config,
1246                collector,
1247            );
1248        }
1249        if let Some(ref val) = self.bldg_nb {
1250            helpers::validate_length(
1251                val,
1252                "BldgNb",
1253                Some(1),
1254                Some(16),
1255                &helpers::child_path(path, "BldgNb"),
1256                config,
1257                collector,
1258            );
1259        }
1260        if let Some(ref val) = self.bldg_nb {
1261            helpers::validate_pattern(
1262                val,
1263                "BldgNb",
1264                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1265                &helpers::child_path(path, "BldgNb"),
1266                config,
1267                collector,
1268            );
1269        }
1270        if let Some(ref val) = self.bldg_nm {
1271            helpers::validate_length(
1272                val,
1273                "BldgNm",
1274                Some(1),
1275                Some(35),
1276                &helpers::child_path(path, "BldgNm"),
1277                config,
1278                collector,
1279            );
1280        }
1281        if let Some(ref val) = self.bldg_nm {
1282            helpers::validate_pattern(
1283                val,
1284                "BldgNm",
1285                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1286                &helpers::child_path(path, "BldgNm"),
1287                config,
1288                collector,
1289            );
1290        }
1291        if let Some(ref val) = self.flr {
1292            helpers::validate_length(
1293                val,
1294                "Flr",
1295                Some(1),
1296                Some(70),
1297                &helpers::child_path(path, "Flr"),
1298                config,
1299                collector,
1300            );
1301        }
1302        if let Some(ref val) = self.flr {
1303            helpers::validate_pattern(
1304                val,
1305                "Flr",
1306                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1307                &helpers::child_path(path, "Flr"),
1308                config,
1309                collector,
1310            );
1311        }
1312        if let Some(ref val) = self.pst_bx {
1313            helpers::validate_length(
1314                val,
1315                "PstBx",
1316                Some(1),
1317                Some(16),
1318                &helpers::child_path(path, "PstBx"),
1319                config,
1320                collector,
1321            );
1322        }
1323        if let Some(ref val) = self.pst_bx {
1324            helpers::validate_pattern(
1325                val,
1326                "PstBx",
1327                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1328                &helpers::child_path(path, "PstBx"),
1329                config,
1330                collector,
1331            );
1332        }
1333        if let Some(ref val) = self.room {
1334            helpers::validate_length(
1335                val,
1336                "Room",
1337                Some(1),
1338                Some(70),
1339                &helpers::child_path(path, "Room"),
1340                config,
1341                collector,
1342            );
1343        }
1344        if let Some(ref val) = self.room {
1345            helpers::validate_pattern(
1346                val,
1347                "Room",
1348                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1349                &helpers::child_path(path, "Room"),
1350                config,
1351                collector,
1352            );
1353        }
1354        if let Some(ref val) = self.pst_cd {
1355            helpers::validate_length(
1356                val,
1357                "PstCd",
1358                Some(1),
1359                Some(16),
1360                &helpers::child_path(path, "PstCd"),
1361                config,
1362                collector,
1363            );
1364        }
1365        if let Some(ref val) = self.pst_cd {
1366            helpers::validate_pattern(
1367                val,
1368                "PstCd",
1369                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1370                &helpers::child_path(path, "PstCd"),
1371                config,
1372                collector,
1373            );
1374        }
1375        if let Some(ref val) = self.twn_nm {
1376            helpers::validate_length(
1377                val,
1378                "TwnNm",
1379                Some(1),
1380                Some(35),
1381                &helpers::child_path(path, "TwnNm"),
1382                config,
1383                collector,
1384            );
1385        }
1386        if let Some(ref val) = self.twn_nm {
1387            helpers::validate_pattern(
1388                val,
1389                "TwnNm",
1390                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1391                &helpers::child_path(path, "TwnNm"),
1392                config,
1393                collector,
1394            );
1395        }
1396        if let Some(ref val) = self.twn_lctn_nm {
1397            helpers::validate_length(
1398                val,
1399                "TwnLctnNm",
1400                Some(1),
1401                Some(35),
1402                &helpers::child_path(path, "TwnLctnNm"),
1403                config,
1404                collector,
1405            );
1406        }
1407        if let Some(ref val) = self.twn_lctn_nm {
1408            helpers::validate_pattern(
1409                val,
1410                "TwnLctnNm",
1411                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1412                &helpers::child_path(path, "TwnLctnNm"),
1413                config,
1414                collector,
1415            );
1416        }
1417        if let Some(ref val) = self.dstrct_nm {
1418            helpers::validate_length(
1419                val,
1420                "DstrctNm",
1421                Some(1),
1422                Some(35),
1423                &helpers::child_path(path, "DstrctNm"),
1424                config,
1425                collector,
1426            );
1427        }
1428        if let Some(ref val) = self.dstrct_nm {
1429            helpers::validate_pattern(
1430                val,
1431                "DstrctNm",
1432                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1433                &helpers::child_path(path, "DstrctNm"),
1434                config,
1435                collector,
1436            );
1437        }
1438        if let Some(ref val) = self.ctry_sub_dvsn {
1439            helpers::validate_length(
1440                val,
1441                "CtrySubDvsn",
1442                Some(1),
1443                Some(35),
1444                &helpers::child_path(path, "CtrySubDvsn"),
1445                config,
1446                collector,
1447            );
1448        }
1449        if let Some(ref val) = self.ctry_sub_dvsn {
1450            helpers::validate_pattern(
1451                val,
1452                "CtrySubDvsn",
1453                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1454                &helpers::child_path(path, "CtrySubDvsn"),
1455                config,
1456                collector,
1457            );
1458        }
1459        if let Some(ref val) = self.ctry {
1460            helpers::validate_pattern(
1461                val,
1462                "Ctry",
1463                "[A-Z]{2,2}",
1464                &helpers::child_path(path, "Ctry"),
1465                config,
1466                collector,
1467            );
1468        }
1469        if let Some(ref vec) = self.adr_line {
1470            for item in vec {
1471                helpers::validate_length(
1472                    item,
1473                    "AdrLine",
1474                    Some(1),
1475                    Some(70),
1476                    &helpers::child_path(path, "AdrLine"),
1477                    config,
1478                    collector,
1479                );
1480            }
1481        }
1482        if let Some(ref vec) = self.adr_line {
1483            for item in vec {
1484                helpers::validate_pattern(
1485                    item,
1486                    "AdrLine",
1487                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1488                    &helpers::child_path(path, "AdrLine"),
1489                    config,
1490                    collector,
1491                );
1492            }
1493        }
1494    }
1495}
1496
1497// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
1498#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1499pub struct ProxyAccountIdentification11 {
1500    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1501    pub tp: Option<ProxyAccountType1Choice1>,
1502    #[serde(rename = "Id")]
1503    pub id: String,
1504}
1505
1506impl Validate for ProxyAccountIdentification11 {
1507    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1508        if let Some(ref val) = self.tp
1509            && config.validate_optional_fields
1510        {
1511            val.validate(&helpers::child_path(path, "Tp"), config, collector);
1512        }
1513        helpers::validate_length(
1514            &self.id,
1515            "Id",
1516            Some(1),
1517            Some(320),
1518            &helpers::child_path(path, "Id"),
1519            config,
1520            collector,
1521        );
1522        helpers::validate_pattern(
1523            &self.id,
1524            "Id",
1525            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1526            &helpers::child_path(path, "Id"),
1527            config,
1528            collector,
1529        );
1530    }
1531}
1532
1533// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
1534#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1535pub struct ProxyAccountType1Choice1 {
1536    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1537    pub cd: Option<String>,
1538    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1539    pub prtry: Option<String>,
1540}
1541
1542impl Validate for ProxyAccountType1Choice1 {
1543    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1544        if let Some(ref val) = self.cd {
1545            helpers::validate_length(
1546                val,
1547                "Cd",
1548                Some(1),
1549                Some(4),
1550                &helpers::child_path(path, "Cd"),
1551                config,
1552                collector,
1553            );
1554        }
1555        if let Some(ref val) = self.prtry {
1556            helpers::validate_length(
1557                val,
1558                "Prtry",
1559                Some(1),
1560                Some(35),
1561                &helpers::child_path(path, "Prtry"),
1562                config,
1563                collector,
1564            );
1565        }
1566        if let Some(ref val) = self.prtry {
1567            helpers::validate_pattern(
1568                val,
1569                "Prtry",
1570                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1571                &helpers::child_path(path, "Prtry"),
1572                config,
1573                collector,
1574            );
1575        }
1576    }
1577}