mx_message/document/
pain_002_001_10.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// BranchAndFinancialInstitutionIdentification61: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
24#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
25pub struct BranchAndFinancialInstitutionIdentification61 {
26    #[serde(rename = "FinInstnId")]
27    pub fin_instn_id: FinancialInstitutionIdentification181,
28}
29
30impl Validate for BranchAndFinancialInstitutionIdentification61 {
31    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
32        self.fin_instn_id
33            .validate(&helpers::child_path(path, "FinInstnId"), config, collector);
34    }
35}
36
37// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
38#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
39pub struct ClearingSystemIdentification2Choice1 {
40    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
41    pub cd: Option<String>,
42}
43
44impl Validate for ClearingSystemIdentification2Choice1 {
45    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
46        if let Some(ref val) = self.cd {
47            helpers::validate_length(
48                val,
49                "Cd",
50                Some(1),
51                Some(5),
52                &helpers::child_path(path, "Cd"),
53                config,
54                collector,
55            );
56        }
57    }
58}
59
60// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
61#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
62pub struct ClearingSystemMemberIdentification21 {
63    #[serde(rename = "ClrSysId")]
64    pub clr_sys_id: ClearingSystemIdentification2Choice1,
65    #[serde(rename = "MmbId")]
66    pub mmb_id: String,
67}
68
69impl Validate for ClearingSystemMemberIdentification21 {
70    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
71        self.clr_sys_id
72            .validate(&helpers::child_path(path, "ClrSysId"), config, collector);
73        helpers::validate_length(
74            &self.mmb_id,
75            "MmbId",
76            Some(1),
77            Some(35),
78            &helpers::child_path(path, "MmbId"),
79            config,
80            collector,
81        );
82    }
83}
84
85// CustomerPaymentStatusReportV10: Information concerning the original payment information, to which the status report message refers.
86#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
87pub struct CustomerPaymentStatusReportV10 {
88    #[serde(rename = "GrpHdr")]
89    pub grp_hdr: GroupHeader861,
90    #[serde(rename = "OrgnlGrpInfAndSts")]
91    pub orgnl_grp_inf_and_sts: OriginalGroupHeader171,
92    #[serde(rename = "OrgnlPmtInfAndSts")]
93    pub orgnl_pmt_inf_and_sts: OriginalPaymentInstruction321,
94}
95
96impl Validate for CustomerPaymentStatusReportV10 {
97    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
98        self.grp_hdr
99            .validate(&helpers::child_path(path, "GrpHdr"), config, collector);
100        self.orgnl_grp_inf_and_sts.validate(
101            &helpers::child_path(path, "OrgnlGrpInfAndSts"),
102            config,
103            collector,
104        );
105        self.orgnl_pmt_inf_and_sts.validate(
106            &helpers::child_path(path, "OrgnlPmtInfAndSts"),
107            config,
108            collector,
109        );
110    }
111}
112
113// DateAndPlaceOfBirth1: Country where a person was born.
114#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
115pub struct DateAndPlaceOfBirth1 {
116    #[serde(rename = "BirthDt")]
117    pub birth_dt: String,
118    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
119    pub prvc_of_birth: Option<String>,
120    #[serde(rename = "CityOfBirth")]
121    pub city_of_birth: String,
122    #[serde(rename = "CtryOfBirth")]
123    pub ctry_of_birth: String,
124}
125
126impl Validate for DateAndPlaceOfBirth1 {
127    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
128        if let Some(ref val) = self.prvc_of_birth {
129            helpers::validate_length(
130                val,
131                "PrvcOfBirth",
132                Some(1),
133                Some(35),
134                &helpers::child_path(path, "PrvcOfBirth"),
135                config,
136                collector,
137            );
138        }
139        helpers::validate_length(
140            &self.city_of_birth,
141            "CityOfBirth",
142            Some(1),
143            Some(35),
144            &helpers::child_path(path, "CityOfBirth"),
145            config,
146            collector,
147        );
148        helpers::validate_pattern(
149            &self.ctry_of_birth,
150            "CtryOfBirth",
151            "[A-Z]{2,2}",
152            &helpers::child_path(path, "CtryOfBirth"),
153            config,
154            collector,
155        );
156    }
157}
158
159// FinancialInstitutionIdentification181: Legal entity identifier of the financial institution.
160#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
161pub struct FinancialInstitutionIdentification181 {
162    #[serde(rename = "BICFI")]
163    pub bicfi: String,
164    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
165    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
166    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
167    pub lei: Option<String>,
168}
169
170impl Validate for FinancialInstitutionIdentification181 {
171    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
172        helpers::validate_pattern(
173            &self.bicfi,
174            "BICFI",
175            "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
176            &helpers::child_path(path, "BICFI"),
177            config,
178            collector,
179        );
180        if let Some(ref val) = self.clr_sys_mmb_id
181            && config.validate_optional_fields
182        {
183            val.validate(&helpers::child_path(path, "ClrSysMmbId"), config, collector);
184        }
185        if let Some(ref val) = self.lei {
186            helpers::validate_pattern(
187                val,
188                "LEI",
189                "[A-Z0-9]{18,18}[0-9]{2,2}",
190                &helpers::child_path(path, "LEI"),
191                config,
192                collector,
193            );
194        }
195    }
196}
197
198// GenericOrganisationIdentification1: Entity that assigns the identification.
199#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
200pub struct GenericOrganisationIdentification1 {
201    #[serde(rename = "Id")]
202    pub id: String,
203    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
204    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
205    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
206    pub issr: Option<String>,
207}
208
209impl Validate for GenericOrganisationIdentification1 {
210    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
211        helpers::validate_length(
212            &self.id,
213            "Id",
214            Some(1),
215            Some(35),
216            &helpers::child_path(path, "Id"),
217            config,
218            collector,
219        );
220        if let Some(ref val) = self.schme_nm
221            && config.validate_optional_fields
222        {
223            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
224        }
225        if let Some(ref val) = self.issr {
226            helpers::validate_length(
227                val,
228                "Issr",
229                Some(1),
230                Some(35),
231                &helpers::child_path(path, "Issr"),
232                config,
233                collector,
234            );
235        }
236    }
237}
238
239// GenericPersonIdentification1: Entity that assigns the identification.
240#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
241pub struct GenericPersonIdentification1 {
242    #[serde(rename = "Id")]
243    pub id: String,
244    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
245    pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
246    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
247    pub issr: Option<String>,
248}
249
250impl Validate for GenericPersonIdentification1 {
251    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
252        helpers::validate_length(
253            &self.id,
254            "Id",
255            Some(1),
256            Some(35),
257            &helpers::child_path(path, "Id"),
258            config,
259            collector,
260        );
261        if let Some(ref val) = self.schme_nm
262            && config.validate_optional_fields
263        {
264            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
265        }
266        if let Some(ref val) = self.issr {
267            helpers::validate_length(
268                val,
269                "Issr",
270                Some(1),
271                Some(35),
272                &helpers::child_path(path, "Issr"),
273                config,
274                collector,
275            );
276        }
277    }
278}
279
280// GroupHeader861: Financial institution that receives the instruction from the initiating party and forwards it to the next agent in the payment chain.
281#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
282pub struct GroupHeader861 {
283    #[serde(rename = "MsgId")]
284    pub msg_id: String,
285    #[serde(rename = "CreDtTm")]
286    pub cre_dt_tm: String,
287    #[serde(rename = "InitgPty")]
288    pub initg_pty: PartyIdentification1351,
289    #[serde(rename = "FwdgAgt", skip_serializing_if = "Option::is_none")]
290    pub fwdg_agt: Option<BranchAndFinancialInstitutionIdentification61>,
291}
292
293impl Validate for GroupHeader861 {
294    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
295        helpers::validate_length(
296            &self.msg_id,
297            "MsgId",
298            Some(1),
299            Some(35),
300            &helpers::child_path(path, "MsgId"),
301            config,
302            collector,
303        );
304        helpers::validate_pattern(
305            &self.msg_id,
306            "MsgId",
307            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
308            &helpers::child_path(path, "MsgId"),
309            config,
310            collector,
311        );
312        self.initg_pty
313            .validate(&helpers::child_path(path, "InitgPty"), config, collector);
314        if let Some(ref val) = self.fwdg_agt
315            && config.validate_optional_fields
316        {
317            val.validate(&helpers::child_path(path, "FwdgAgt"), config, collector);
318        }
319    }
320}
321
322// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
323#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
324pub struct OrganisationIdentification291 {
325    #[serde(rename = "AnyBIC")]
326    pub any_bic: String,
327    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
328    pub lei: Option<String>,
329    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
330    pub othr: Option<Vec<GenericOrganisationIdentification1>>,
331}
332
333impl Validate for OrganisationIdentification291 {
334    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
335        helpers::validate_pattern(
336            &self.any_bic,
337            "AnyBIC",
338            "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
339            &helpers::child_path(path, "AnyBIC"),
340            config,
341            collector,
342        );
343        if let Some(ref val) = self.lei {
344            helpers::validate_pattern(
345                val,
346                "LEI",
347                "[A-Z0-9]{18,18}[0-9]{2,2}",
348                &helpers::child_path(path, "LEI"),
349                config,
350                collector,
351            );
352        }
353        if let Some(ref vec) = self.othr
354            && config.validate_optional_fields
355        {
356            for item in vec {
357                item.validate(&helpers::child_path(path, "Othr"), config, collector);
358            }
359        }
360    }
361}
362
363// OrganisationIdentification292: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
364#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
365pub struct OrganisationIdentification292 {
366    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
367    pub any_bic: Option<String>,
368    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
369    pub lei: Option<String>,
370    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
371    pub othr: Option<Vec<GenericOrganisationIdentification1>>,
372}
373
374impl Validate for OrganisationIdentification292 {
375    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
376        if let Some(ref val) = self.any_bic {
377            helpers::validate_pattern(
378                val,
379                "AnyBIC",
380                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
381                &helpers::child_path(path, "AnyBIC"),
382                config,
383                collector,
384            );
385        }
386        if let Some(ref val) = self.lei {
387            helpers::validate_pattern(
388                val,
389                "LEI",
390                "[A-Z0-9]{18,18}[0-9]{2,2}",
391                &helpers::child_path(path, "LEI"),
392                config,
393                collector,
394            );
395        }
396        if let Some(ref vec) = self.othr
397            && config.validate_optional_fields
398        {
399            for item in vec {
400                item.validate(&helpers::child_path(path, "Othr"), config, collector);
401            }
402        }
403    }
404}
405
406// OrganisationIdentificationSchemeName1Choice: Name of the identification scheme, in a free text form.
407#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
408pub struct OrganisationIdentificationSchemeName1Choice {
409    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
410    pub cd: Option<String>,
411    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
412    pub prtry: Option<String>,
413}
414
415impl Validate for OrganisationIdentificationSchemeName1Choice {
416    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
417        if let Some(ref val) = self.cd {
418            helpers::validate_length(
419                val,
420                "Cd",
421                Some(1),
422                Some(4),
423                &helpers::child_path(path, "Cd"),
424                config,
425                collector,
426            );
427        }
428        if let Some(ref val) = self.prtry {
429            helpers::validate_length(
430                val,
431                "Prtry",
432                Some(1),
433                Some(35),
434                &helpers::child_path(path, "Prtry"),
435                config,
436                collector,
437            );
438        }
439    }
440}
441
442// OriginalGroupHeader171: Date and time at which the original message was created.
443#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
444pub struct OriginalGroupHeader171 {
445    #[serde(rename = "OrgnlMsgId")]
446    pub orgnl_msg_id: String,
447    #[serde(rename = "OrgnlMsgNmId")]
448    pub orgnl_msg_nm_id: String,
449    #[serde(rename = "OrgnlCreDtTm", skip_serializing_if = "Option::is_none")]
450    pub orgnl_cre_dt_tm: Option<String>,
451}
452
453impl Validate for OriginalGroupHeader171 {
454    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
455        helpers::validate_length(
456            &self.orgnl_msg_id,
457            "OrgnlMsgId",
458            Some(1),
459            Some(35),
460            &helpers::child_path(path, "OrgnlMsgId"),
461            config,
462            collector,
463        );
464        helpers::validate_length(
465            &self.orgnl_msg_nm_id,
466            "OrgnlMsgNmId",
467            Some(1),
468            Some(35),
469            &helpers::child_path(path, "OrgnlMsgNmId"),
470            config,
471            collector,
472        );
473    }
474}
475
476// OriginalPaymentInstruction321: Provides information on the original transactions to which the status report message refers.
477#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
478pub struct OriginalPaymentInstruction321 {
479    #[serde(rename = "OrgnlPmtInfId")]
480    pub orgnl_pmt_inf_id: String,
481    #[serde(rename = "TxInfAndSts")]
482    pub tx_inf_and_sts: PaymentTransaction1051,
483}
484
485impl Validate for OriginalPaymentInstruction321 {
486    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
487        helpers::validate_length(
488            &self.orgnl_pmt_inf_id,
489            "OrgnlPmtInfId",
490            Some(1),
491            Some(35),
492            &helpers::child_path(path, "OrgnlPmtInfId"),
493            config,
494            collector,
495        );
496        self.tx_inf_and_sts
497            .validate(&helpers::child_path(path, "TxInfAndSts"), config, collector);
498    }
499}
500
501// Party38Choice1: Unique and unambiguous way to identify an organisation.
502#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
503pub struct Party38Choice1 {
504    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
505    pub org_id: Option<OrganisationIdentification291>,
506}
507
508impl Validate for Party38Choice1 {
509    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
510        if let Some(ref val) = self.org_id
511            && config.validate_optional_fields
512        {
513            val.validate(&helpers::child_path(path, "OrgId"), config, collector);
514        }
515    }
516}
517
518// Party38Choice2: Unique and unambiguous identification of a person, for example a passport.
519#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
520pub struct Party38Choice2 {
521    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
522    pub org_id: Option<OrganisationIdentification292>,
523    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
524    pub prvt_id: Option<PersonIdentification131>,
525}
526
527impl Validate for Party38Choice2 {
528    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
529        if let Some(ref val) = self.org_id
530            && config.validate_optional_fields
531        {
532            val.validate(&helpers::child_path(path, "OrgId"), config, collector);
533        }
534        if let Some(ref val) = self.prvt_id
535            && config.validate_optional_fields
536        {
537            val.validate(&helpers::child_path(path, "PrvtId"), config, collector);
538        }
539    }
540}
541
542// PartyIdentification1351: Unique and unambiguous identification of a party.
543#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
544pub struct PartyIdentification1351 {
545    #[serde(rename = "Id")]
546    pub id: Party38Choice1,
547}
548
549impl Validate for PartyIdentification1351 {
550    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
551        self.id
552            .validate(&helpers::child_path(path, "Id"), config, collector);
553    }
554}
555
556// PartyIdentification1352: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
557#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
558pub struct PartyIdentification1352 {
559    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
560    pub nm: Option<String>,
561    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
562    pub pstl_adr: Option<PostalAddress241>,
563    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
564    pub id: Option<Party38Choice2>,
565    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
566    pub ctry_of_res: Option<String>,
567}
568
569impl Validate for PartyIdentification1352 {
570    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
571        if let Some(ref val) = self.nm {
572            helpers::validate_length(
573                val,
574                "Nm",
575                Some(1),
576                Some(140),
577                &helpers::child_path(path, "Nm"),
578                config,
579                collector,
580            );
581        }
582        if let Some(ref val) = self.pstl_adr
583            && config.validate_optional_fields
584        {
585            val.validate(&helpers::child_path(path, "PstlAdr"), config, collector);
586        }
587        if let Some(ref val) = self.id
588            && config.validate_optional_fields
589        {
590            val.validate(&helpers::child_path(path, "Id"), config, collector);
591        }
592        if let Some(ref val) = self.ctry_of_res {
593            helpers::validate_pattern(
594                val,
595                "CtryOfRes",
596                "[A-Z]{2,2}",
597                &helpers::child_path(path, "CtryOfRes"),
598                config,
599                collector,
600            );
601        }
602    }
603}
604
605// PaymentTransaction1051: Provides detailed information on the status reason.
606#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
607pub struct PaymentTransaction1051 {
608    #[serde(rename = "OrgnlInstrId", skip_serializing_if = "Option::is_none")]
609    pub orgnl_instr_id: Option<String>,
610    #[serde(rename = "OrgnlEndToEndId")]
611    pub orgnl_end_to_end_id: String,
612    #[serde(rename = "OrgnlUETR")]
613    pub orgnl_uetr: String,
614    #[serde(rename = "TxSts")]
615    pub tx_sts: String,
616    #[serde(rename = "StsRsnInf", skip_serializing_if = "Option::is_none")]
617    pub sts_rsn_inf: Option<StatusReasonInformation121>,
618}
619
620impl Validate for PaymentTransaction1051 {
621    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
622        if let Some(ref val) = self.orgnl_instr_id {
623            helpers::validate_length(
624                val,
625                "OrgnlInstrId",
626                Some(1),
627                Some(35),
628                &helpers::child_path(path, "OrgnlInstrId"),
629                config,
630                collector,
631            );
632        }
633        helpers::validate_length(
634            &self.orgnl_end_to_end_id,
635            "OrgnlEndToEndId",
636            Some(1),
637            Some(35),
638            &helpers::child_path(path, "OrgnlEndToEndId"),
639            config,
640            collector,
641        );
642        helpers::validate_pattern(
643            &self.orgnl_uetr,
644            "OrgnlUETR",
645            "[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}",
646            &helpers::child_path(path, "OrgnlUETR"),
647            config,
648            collector,
649        );
650        helpers::validate_length(
651            &self.tx_sts,
652            "TxSts",
653            Some(1),
654            Some(4),
655            &helpers::child_path(path, "TxSts"),
656            config,
657            collector,
658        );
659        if let Some(ref val) = self.sts_rsn_inf
660            && config.validate_optional_fields
661        {
662            val.validate(&helpers::child_path(path, "StsRsnInf"), config, collector);
663        }
664    }
665}
666
667// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
668#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
669pub struct PersonIdentification131 {
670    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
671    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
672    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
673    pub othr: Option<Vec<GenericPersonIdentification1>>,
674}
675
676impl Validate for PersonIdentification131 {
677    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
678        if let Some(ref val) = self.dt_and_plc_of_birth
679            && config.validate_optional_fields
680        {
681            val.validate(
682                &helpers::child_path(path, "DtAndPlcOfBirth"),
683                config,
684                collector,
685            );
686        }
687        if let Some(ref vec) = self.othr
688            && config.validate_optional_fields
689        {
690            for item in vec {
691                item.validate(&helpers::child_path(path, "Othr"), config, collector);
692            }
693        }
694    }
695}
696
697// PersonIdentificationSchemeName1Choice: Name of the identification scheme, in a free text form.
698#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
699pub struct PersonIdentificationSchemeName1Choice {
700    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
701    pub cd: Option<String>,
702    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
703    pub prtry: Option<String>,
704}
705
706impl Validate for PersonIdentificationSchemeName1Choice {
707    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
708        if let Some(ref val) = self.cd {
709            helpers::validate_length(
710                val,
711                "Cd",
712                Some(1),
713                Some(4),
714                &helpers::child_path(path, "Cd"),
715                config,
716                collector,
717            );
718        }
719        if let Some(ref val) = self.prtry {
720            helpers::validate_length(
721                val,
722                "Prtry",
723                Some(1),
724                Some(35),
725                &helpers::child_path(path, "Prtry"),
726                config,
727                collector,
728            );
729        }
730    }
731}
732
733// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
734#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
735pub struct PostalAddress241 {
736    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
737    pub dept: Option<String>,
738    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
739    pub sub_dept: Option<String>,
740    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
741    pub strt_nm: Option<String>,
742    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
743    pub bldg_nb: Option<String>,
744    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
745    pub bldg_nm: Option<String>,
746    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
747    pub flr: Option<String>,
748    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
749    pub pst_bx: Option<String>,
750    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
751    pub room: Option<String>,
752    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
753    pub pst_cd: Option<String>,
754    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
755    pub twn_nm: Option<String>,
756    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
757    pub twn_lctn_nm: Option<String>,
758    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
759    pub dstrct_nm: Option<String>,
760    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
761    pub ctry_sub_dvsn: Option<String>,
762    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
763    pub ctry: Option<String>,
764    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
765    pub adr_line: Option<Vec<String>>,
766}
767
768impl Validate for PostalAddress241 {
769    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
770        if let Some(ref val) = self.dept {
771            helpers::validate_length(
772                val,
773                "Dept",
774                Some(1),
775                Some(70),
776                &helpers::child_path(path, "Dept"),
777                config,
778                collector,
779            );
780        }
781        if let Some(ref val) = self.sub_dept {
782            helpers::validate_length(
783                val,
784                "SubDept",
785                Some(1),
786                Some(70),
787                &helpers::child_path(path, "SubDept"),
788                config,
789                collector,
790            );
791        }
792        if let Some(ref val) = self.strt_nm {
793            helpers::validate_length(
794                val,
795                "StrtNm",
796                Some(1),
797                Some(70),
798                &helpers::child_path(path, "StrtNm"),
799                config,
800                collector,
801            );
802        }
803        if let Some(ref val) = self.bldg_nb {
804            helpers::validate_length(
805                val,
806                "BldgNb",
807                Some(1),
808                Some(16),
809                &helpers::child_path(path, "BldgNb"),
810                config,
811                collector,
812            );
813        }
814        if let Some(ref val) = self.bldg_nm {
815            helpers::validate_length(
816                val,
817                "BldgNm",
818                Some(1),
819                Some(35),
820                &helpers::child_path(path, "BldgNm"),
821                config,
822                collector,
823            );
824        }
825        if let Some(ref val) = self.flr {
826            helpers::validate_length(
827                val,
828                "Flr",
829                Some(1),
830                Some(70),
831                &helpers::child_path(path, "Flr"),
832                config,
833                collector,
834            );
835        }
836        if let Some(ref val) = self.pst_bx {
837            helpers::validate_length(
838                val,
839                "PstBx",
840                Some(1),
841                Some(16),
842                &helpers::child_path(path, "PstBx"),
843                config,
844                collector,
845            );
846        }
847        if let Some(ref val) = self.room {
848            helpers::validate_length(
849                val,
850                "Room",
851                Some(1),
852                Some(70),
853                &helpers::child_path(path, "Room"),
854                config,
855                collector,
856            );
857        }
858        if let Some(ref val) = self.pst_cd {
859            helpers::validate_length(
860                val,
861                "PstCd",
862                Some(1),
863                Some(16),
864                &helpers::child_path(path, "PstCd"),
865                config,
866                collector,
867            );
868        }
869        if let Some(ref val) = self.twn_nm {
870            helpers::validate_length(
871                val,
872                "TwnNm",
873                Some(1),
874                Some(35),
875                &helpers::child_path(path, "TwnNm"),
876                config,
877                collector,
878            );
879        }
880        if let Some(ref val) = self.twn_lctn_nm {
881            helpers::validate_length(
882                val,
883                "TwnLctnNm",
884                Some(1),
885                Some(35),
886                &helpers::child_path(path, "TwnLctnNm"),
887                config,
888                collector,
889            );
890        }
891        if let Some(ref val) = self.dstrct_nm {
892            helpers::validate_length(
893                val,
894                "DstrctNm",
895                Some(1),
896                Some(35),
897                &helpers::child_path(path, "DstrctNm"),
898                config,
899                collector,
900            );
901        }
902        if let Some(ref val) = self.ctry_sub_dvsn {
903            helpers::validate_length(
904                val,
905                "CtrySubDvsn",
906                Some(1),
907                Some(35),
908                &helpers::child_path(path, "CtrySubDvsn"),
909                config,
910                collector,
911            );
912        }
913        if let Some(ref val) = self.ctry {
914            helpers::validate_pattern(
915                val,
916                "Ctry",
917                "[A-Z]{2,2}",
918                &helpers::child_path(path, "Ctry"),
919                config,
920                collector,
921            );
922        }
923        if let Some(ref vec) = self.adr_line {
924            for item in vec {
925                helpers::validate_length(
926                    item,
927                    "AdrLine",
928                    Some(1),
929                    Some(70),
930                    &helpers::child_path(path, "AdrLine"),
931                    config,
932                    collector,
933                );
934            }
935        }
936    }
937}
938
939// StatusReason6Choice1: Reason for the status, as published in an external reason code list.
940#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
941pub struct StatusReason6Choice1 {
942    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
943    pub cd: Option<String>,
944}
945
946impl Validate for StatusReason6Choice1 {
947    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
948        if let Some(ref val) = self.cd {
949            helpers::validate_length(
950                val,
951                "Cd",
952                Some(1),
953                Some(4),
954                &helpers::child_path(path, "Cd"),
955                config,
956                collector,
957            );
958        }
959    }
960}
961
962// StatusReasonInformation121: Further details on the status reason.
963//
964// Usage: Additional information can be used for several purposes such as the reporting of repaired information.
965#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
966pub struct StatusReasonInformation121 {
967    #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
968    pub orgtr: Option<PartyIdentification1352>,
969    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
970    pub rsn: Option<StatusReason6Choice1>,
971    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
972    pub addtl_inf: Option<Vec<String>>,
973}
974
975impl Validate for StatusReasonInformation121 {
976    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
977        if let Some(ref val) = self.orgtr
978            && config.validate_optional_fields
979        {
980            val.validate(&helpers::child_path(path, "Orgtr"), config, collector);
981        }
982        if let Some(ref val) = self.rsn
983            && config.validate_optional_fields
984        {
985            val.validate(&helpers::child_path(path, "Rsn"), config, collector);
986        }
987        if let Some(ref vec) = self.addtl_inf {
988            for item in vec {
989                helpers::validate_length(
990                    item,
991                    "AddtlInf",
992                    Some(1),
993                    Some(105),
994                    &helpers::child_path(path, "AddtlInf"),
995                    config,
996                    collector,
997                );
998            }
999        }
1000    }
1001}