mx_message/document/
pacs_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(28),
78            &helpers::child_path(path, "MmbId"),
79            config,
80            collector,
81        );
82        helpers::validate_pattern(
83            &self.mmb_id,
84            "MmbId",
85            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
86            &helpers::child_path(path, "MmbId"),
87            config,
88            collector,
89        );
90    }
91}
92
93// DateAndDateTime2Choice1: Specified date and time.
94#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
95pub struct DateAndDateTime2Choice1 {
96    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
97    pub dt: Option<String>,
98    #[serde(rename = "DtTm", skip_serializing_if = "Option::is_none")]
99    pub dt_tm: Option<String>,
100}
101
102impl Validate for DateAndDateTime2Choice1 {
103    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
104        if let Some(ref val) = self.dt_tm {
105            helpers::validate_pattern(
106                val,
107                "DtTm",
108                ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
109                &helpers::child_path(path, "DtTm"),
110                config,
111                collector,
112            );
113        }
114    }
115}
116
117// DateAndPlaceOfBirth11: Country where a person was born.
118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
119pub struct DateAndPlaceOfBirth11 {
120    #[serde(rename = "BirthDt")]
121    pub birth_dt: String,
122    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
123    pub prvc_of_birth: Option<String>,
124    #[serde(rename = "CityOfBirth")]
125    pub city_of_birth: String,
126    #[serde(rename = "CtryOfBirth")]
127    pub ctry_of_birth: String,
128}
129
130impl Validate for DateAndPlaceOfBirth11 {
131    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
132        if let Some(ref val) = self.prvc_of_birth {
133            helpers::validate_length(
134                val,
135                "PrvcOfBirth",
136                Some(1),
137                Some(35),
138                &helpers::child_path(path, "PrvcOfBirth"),
139                config,
140                collector,
141            );
142        }
143        if let Some(ref val) = self.prvc_of_birth {
144            helpers::validate_pattern(
145                val,
146                "PrvcOfBirth",
147                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
148                &helpers::child_path(path, "PrvcOfBirth"),
149                config,
150                collector,
151            );
152        }
153        helpers::validate_length(
154            &self.city_of_birth,
155            "CityOfBirth",
156            Some(1),
157            Some(35),
158            &helpers::child_path(path, "CityOfBirth"),
159            config,
160            collector,
161        );
162        helpers::validate_pattern(
163            &self.city_of_birth,
164            "CityOfBirth",
165            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
166            &helpers::child_path(path, "CityOfBirth"),
167            config,
168            collector,
169        );
170        helpers::validate_pattern(
171            &self.ctry_of_birth,
172            "CtryOfBirth",
173            "[A-Z]{2,2}",
174            &helpers::child_path(path, "CtryOfBirth"),
175            config,
176            collector,
177        );
178    }
179}
180
181// FIToFIPaymentStatusReportV10: Information concerning the original transactions, to which the status report message refers.
182#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
183pub struct FIToFIPaymentStatusReportV10 {
184    #[serde(rename = "GrpHdr")]
185    pub grp_hdr: GroupHeader911,
186    #[serde(rename = "TxInfAndSts")]
187    pub tx_inf_and_sts: PaymentTransaction1101,
188}
189
190impl Validate for FIToFIPaymentStatusReportV10 {
191    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
192        self.grp_hdr
193            .validate(&helpers::child_path(path, "GrpHdr"), config, collector);
194        self.tx_inf_and_sts
195            .validate(&helpers::child_path(path, "TxInfAndSts"), config, collector);
196    }
197}
198
199// FinancialInstitutionIdentification181: Legal entity identifier of the financial institution.
200#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
201pub struct FinancialInstitutionIdentification181 {
202    #[serde(rename = "BICFI")]
203    pub bicfi: String,
204    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
205    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
206    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
207    pub lei: Option<String>,
208}
209
210impl Validate for FinancialInstitutionIdentification181 {
211    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
212        helpers::validate_pattern(
213            &self.bicfi,
214            "BICFI",
215            "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
216            &helpers::child_path(path, "BICFI"),
217            config,
218            collector,
219        );
220        if let Some(ref val) = self.clr_sys_mmb_id
221            && config.validate_optional_fields
222        {
223            val.validate(&helpers::child_path(path, "ClrSysMmbId"), config, collector);
224        }
225        if let Some(ref val) = self.lei {
226            helpers::validate_pattern(
227                val,
228                "LEI",
229                "[A-Z0-9]{18,18}[0-9]{2,2}",
230                &helpers::child_path(path, "LEI"),
231                config,
232                collector,
233            );
234        }
235    }
236}
237
238// GenericOrganisationIdentification11: Entity that assigns the identification.
239#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
240pub struct GenericOrganisationIdentification11 {
241    #[serde(rename = "Id")]
242    pub id: String,
243    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
244    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
245    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
246    pub issr: Option<String>,
247}
248
249impl Validate for GenericOrganisationIdentification11 {
250    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
251        helpers::validate_length(
252            &self.id,
253            "Id",
254            Some(1),
255            Some(35),
256            &helpers::child_path(path, "Id"),
257            config,
258            collector,
259        );
260        helpers::validate_pattern(
261            &self.id,
262            "Id",
263            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
264            &helpers::child_path(path, "Id"),
265            config,
266            collector,
267        );
268        if let Some(ref val) = self.schme_nm
269            && config.validate_optional_fields
270        {
271            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
272        }
273        if let Some(ref val) = self.issr {
274            helpers::validate_length(
275                val,
276                "Issr",
277                Some(1),
278                Some(35),
279                &helpers::child_path(path, "Issr"),
280                config,
281                collector,
282            );
283        }
284        if let Some(ref val) = self.issr {
285            helpers::validate_pattern(
286                val,
287                "Issr",
288                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
289                &helpers::child_path(path, "Issr"),
290                config,
291                collector,
292            );
293        }
294    }
295}
296
297// GenericPersonIdentification11: Entity that assigns the identification.
298#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
299pub struct GenericPersonIdentification11 {
300    #[serde(rename = "Id")]
301    pub id: String,
302    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
303    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
304    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
305    pub issr: Option<String>,
306}
307
308impl Validate for GenericPersonIdentification11 {
309    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
310        helpers::validate_length(
311            &self.id,
312            "Id",
313            Some(1),
314            Some(35),
315            &helpers::child_path(path, "Id"),
316            config,
317            collector,
318        );
319        helpers::validate_pattern(
320            &self.id,
321            "Id",
322            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
323            &helpers::child_path(path, "Id"),
324            config,
325            collector,
326        );
327        if let Some(ref val) = self.schme_nm
328            && config.validate_optional_fields
329        {
330            val.validate(&helpers::child_path(path, "SchmeNm"), config, collector);
331        }
332        if let Some(ref val) = self.issr {
333            helpers::validate_length(
334                val,
335                "Issr",
336                Some(1),
337                Some(35),
338                &helpers::child_path(path, "Issr"),
339                config,
340                collector,
341            );
342        }
343        if let Some(ref val) = self.issr {
344            helpers::validate_pattern(
345                val,
346                "Issr",
347                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
348                &helpers::child_path(path, "Issr"),
349                config,
350                collector,
351            );
352        }
353    }
354}
355
356// GroupHeader911: Date and time at which the message was created.
357#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
358pub struct GroupHeader911 {
359    #[serde(rename = "MsgId")]
360    pub msg_id: String,
361    #[serde(rename = "CreDtTm")]
362    pub cre_dt_tm: String,
363}
364
365impl Validate for GroupHeader911 {
366    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
367        helpers::validate_length(
368            &self.msg_id,
369            "MsgId",
370            Some(1),
371            Some(35),
372            &helpers::child_path(path, "MsgId"),
373            config,
374            collector,
375        );
376        helpers::validate_pattern(
377            &self.msg_id,
378            "MsgId",
379            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
380            &helpers::child_path(path, "MsgId"),
381            config,
382            collector,
383        );
384        helpers::validate_pattern(
385            &self.cre_dt_tm,
386            "CreDtTm",
387            ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
388            &helpers::child_path(path, "CreDtTm"),
389            config,
390            collector,
391        );
392    }
393}
394
395// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
396#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
397pub struct OrganisationIdentification291 {
398    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
399    pub any_bic: Option<String>,
400    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
401    pub lei: Option<String>,
402    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
403    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
404}
405
406impl Validate for OrganisationIdentification291 {
407    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
408        if let Some(ref val) = self.any_bic {
409            helpers::validate_pattern(
410                val,
411                "AnyBIC",
412                "[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}",
413                &helpers::child_path(path, "AnyBIC"),
414                config,
415                collector,
416            );
417        }
418        if let Some(ref val) = self.lei {
419            helpers::validate_pattern(
420                val,
421                "LEI",
422                "[A-Z0-9]{18,18}[0-9]{2,2}",
423                &helpers::child_path(path, "LEI"),
424                config,
425                collector,
426            );
427        }
428        if let Some(ref vec) = self.othr
429            && config.validate_optional_fields
430        {
431            for item in vec {
432                item.validate(&helpers::child_path(path, "Othr"), config, collector);
433            }
434        }
435    }
436}
437
438// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
439#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
440pub struct OrganisationIdentificationSchemeName1Choice1 {
441    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
442    pub cd: Option<String>,
443    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
444    pub prtry: Option<String>,
445}
446
447impl Validate for OrganisationIdentificationSchemeName1Choice1 {
448    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
449        if let Some(ref val) = self.cd {
450            helpers::validate_length(
451                val,
452                "Cd",
453                Some(1),
454                Some(4),
455                &helpers::child_path(path, "Cd"),
456                config,
457                collector,
458            );
459        }
460        if let Some(ref val) = self.prtry {
461            helpers::validate_length(
462                val,
463                "Prtry",
464                Some(1),
465                Some(35),
466                &helpers::child_path(path, "Prtry"),
467                config,
468                collector,
469            );
470        }
471        if let Some(ref val) = self.prtry {
472            helpers::validate_pattern(
473                val,
474                "Prtry",
475                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
476                &helpers::child_path(path, "Prtry"),
477                config,
478                collector,
479            );
480        }
481    }
482}
483
484// OriginalGroupInformation291: Original date and time at which the message was created.
485#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
486pub struct OriginalGroupInformation291 {
487    #[serde(rename = "OrgnlMsgId")]
488    pub orgnl_msg_id: String,
489    #[serde(rename = "OrgnlMsgNmId")]
490    pub orgnl_msg_nm_id: String,
491    #[serde(rename = "OrgnlCreDtTm", skip_serializing_if = "Option::is_none")]
492    pub orgnl_cre_dt_tm: Option<String>,
493}
494
495impl Validate for OriginalGroupInformation291 {
496    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
497        helpers::validate_length(
498            &self.orgnl_msg_id,
499            "OrgnlMsgId",
500            Some(1),
501            Some(35),
502            &helpers::child_path(path, "OrgnlMsgId"),
503            config,
504            collector,
505        );
506        helpers::validate_pattern(
507            &self.orgnl_msg_id,
508            "OrgnlMsgId",
509            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
510            &helpers::child_path(path, "OrgnlMsgId"),
511            config,
512            collector,
513        );
514        helpers::validate_length(
515            &self.orgnl_msg_nm_id,
516            "OrgnlMsgNmId",
517            Some(1),
518            Some(35),
519            &helpers::child_path(path, "OrgnlMsgNmId"),
520            config,
521            collector,
522        );
523        helpers::validate_pattern(
524            &self.orgnl_msg_nm_id,
525            "OrgnlMsgNmId",
526            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
527            &helpers::child_path(path, "OrgnlMsgNmId"),
528            config,
529            collector,
530        );
531        if let Some(ref val) = self.orgnl_cre_dt_tm {
532            helpers::validate_pattern(
533                val,
534                "OrgnlCreDtTm",
535                ".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]",
536                &helpers::child_path(path, "OrgnlCreDtTm"),
537                config,
538                collector,
539            );
540        }
541    }
542}
543
544// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
545#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
546pub struct Party38Choice1 {
547    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
548    pub org_id: Option<OrganisationIdentification291>,
549    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
550    pub prvt_id: Option<PersonIdentification131>,
551}
552
553impl Validate for Party38Choice1 {
554    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
555        if let Some(ref val) = self.org_id
556            && config.validate_optional_fields
557        {
558            val.validate(&helpers::child_path(path, "OrgId"), config, collector);
559        }
560        if let Some(ref val) = self.prvt_id
561            && config.validate_optional_fields
562        {
563            val.validate(&helpers::child_path(path, "PrvtId"), config, collector);
564        }
565    }
566}
567
568// 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.
569#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
570pub struct PartyIdentification1351 {
571    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
572    pub nm: Option<String>,
573    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
574    pub pstl_adr: Option<PostalAddress241>,
575    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
576    pub id: Option<Party38Choice1>,
577    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
578    pub ctry_of_res: Option<String>,
579}
580
581impl Validate for PartyIdentification1351 {
582    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
583        if let Some(ref val) = self.nm {
584            helpers::validate_length(
585                val,
586                "Nm",
587                Some(1),
588                Some(140),
589                &helpers::child_path(path, "Nm"),
590                config,
591                collector,
592            );
593        }
594        if let Some(ref val) = self.nm {
595            helpers::validate_pattern(
596                val,
597                "Nm",
598                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
599                &helpers::child_path(path, "Nm"),
600                config,
601                collector,
602            );
603        }
604        if let Some(ref val) = self.pstl_adr
605            && config.validate_optional_fields
606        {
607            val.validate(&helpers::child_path(path, "PstlAdr"), config, collector);
608        }
609        if let Some(ref val) = self.id
610            && config.validate_optional_fields
611        {
612            val.validate(&helpers::child_path(path, "Id"), config, collector);
613        }
614        if let Some(ref val) = self.ctry_of_res {
615            helpers::validate_pattern(
616                val,
617                "CtryOfRes",
618                "[A-Z]{2,2}",
619                &helpers::child_path(path, "CtryOfRes"),
620                config,
621                collector,
622            );
623        }
624    }
625}
626
627// PaymentTransaction1101: Agent that is instructed by the previous party in the chain to carry out the (set of) instruction(s).
628//
629// Usage: The instructed agent is the party receiving the status message and not the party that received the original instruction that is being reported on.
630#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
631pub struct PaymentTransaction1101 {
632    #[serde(rename = "OrgnlGrpInf")]
633    pub orgnl_grp_inf: OriginalGroupInformation291,
634    #[serde(rename = "OrgnlInstrId", skip_serializing_if = "Option::is_none")]
635    pub orgnl_instr_id: Option<String>,
636    #[serde(rename = "OrgnlEndToEndId")]
637    pub orgnl_end_to_end_id: String,
638    #[serde(rename = "OrgnlTxId", skip_serializing_if = "Option::is_none")]
639    pub orgnl_tx_id: Option<String>,
640    #[serde(rename = "OrgnlUETR")]
641    pub orgnl_uetr: String,
642    #[serde(rename = "TxSts")]
643    pub tx_sts: String,
644    #[serde(rename = "StsRsnInf", skip_serializing_if = "Option::is_none")]
645    pub sts_rsn_inf: Option<StatusReasonInformation121>,
646    #[serde(rename = "FctvIntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
647    pub fctv_intr_bk_sttlm_dt: Option<DateAndDateTime2Choice1>,
648    #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
649    pub clr_sys_ref: Option<String>,
650    #[serde(rename = "InstgAgt")]
651    pub instg_agt: BranchAndFinancialInstitutionIdentification61,
652    #[serde(rename = "InstdAgt")]
653    pub instd_agt: BranchAndFinancialInstitutionIdentification61,
654}
655
656impl Validate for PaymentTransaction1101 {
657    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
658        self.orgnl_grp_inf
659            .validate(&helpers::child_path(path, "OrgnlGrpInf"), config, collector);
660        if let Some(ref val) = self.orgnl_instr_id {
661            helpers::validate_length(
662                val,
663                "OrgnlInstrId",
664                Some(1),
665                Some(16),
666                &helpers::child_path(path, "OrgnlInstrId"),
667                config,
668                collector,
669            );
670        }
671        if let Some(ref val) = self.orgnl_instr_id {
672            helpers::validate_pattern(
673                val,
674                "OrgnlInstrId",
675                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
676                &helpers::child_path(path, "OrgnlInstrId"),
677                config,
678                collector,
679            );
680        }
681        helpers::validate_length(
682            &self.orgnl_end_to_end_id,
683            "OrgnlEndToEndId",
684            Some(1),
685            Some(35),
686            &helpers::child_path(path, "OrgnlEndToEndId"),
687            config,
688            collector,
689        );
690        helpers::validate_pattern(
691            &self.orgnl_end_to_end_id,
692            "OrgnlEndToEndId",
693            "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
694            &helpers::child_path(path, "OrgnlEndToEndId"),
695            config,
696            collector,
697        );
698        if let Some(ref val) = self.orgnl_tx_id {
699            helpers::validate_length(
700                val,
701                "OrgnlTxId",
702                Some(1),
703                Some(35),
704                &helpers::child_path(path, "OrgnlTxId"),
705                config,
706                collector,
707            );
708        }
709        if let Some(ref val) = self.orgnl_tx_id {
710            helpers::validate_pattern(
711                val,
712                "OrgnlTxId",
713                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
714                &helpers::child_path(path, "OrgnlTxId"),
715                config,
716                collector,
717            );
718        }
719        helpers::validate_pattern(
720            &self.orgnl_uetr,
721            "OrgnlUETR",
722            "[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}",
723            &helpers::child_path(path, "OrgnlUETR"),
724            config,
725            collector,
726        );
727        helpers::validate_length(
728            &self.tx_sts,
729            "TxSts",
730            Some(1),
731            Some(4),
732            &helpers::child_path(path, "TxSts"),
733            config,
734            collector,
735        );
736        if let Some(ref val) = self.sts_rsn_inf
737            && config.validate_optional_fields
738        {
739            val.validate(&helpers::child_path(path, "StsRsnInf"), config, collector);
740        }
741        if let Some(ref val) = self.fctv_intr_bk_sttlm_dt
742            && config.validate_optional_fields
743        {
744            val.validate(
745                &helpers::child_path(path, "FctvIntrBkSttlmDt"),
746                config,
747                collector,
748            );
749        }
750        if let Some(ref val) = self.clr_sys_ref {
751            helpers::validate_length(
752                val,
753                "ClrSysRef",
754                Some(1),
755                Some(35),
756                &helpers::child_path(path, "ClrSysRef"),
757                config,
758                collector,
759            );
760        }
761        if let Some(ref val) = self.clr_sys_ref {
762            helpers::validate_pattern(
763                val,
764                "ClrSysRef",
765                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
766                &helpers::child_path(path, "ClrSysRef"),
767                config,
768                collector,
769            );
770        }
771        self.instg_agt
772            .validate(&helpers::child_path(path, "InstgAgt"), config, collector);
773        self.instd_agt
774            .validate(&helpers::child_path(path, "InstdAgt"), config, collector);
775    }
776}
777
778// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
779#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
780pub struct PersonIdentification131 {
781    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
782    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
783    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
784    pub othr: Option<Vec<GenericPersonIdentification11>>,
785}
786
787impl Validate for PersonIdentification131 {
788    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
789        if let Some(ref val) = self.dt_and_plc_of_birth
790            && config.validate_optional_fields
791        {
792            val.validate(
793                &helpers::child_path(path, "DtAndPlcOfBirth"),
794                config,
795                collector,
796            );
797        }
798        if let Some(ref vec) = self.othr
799            && config.validate_optional_fields
800        {
801            for item in vec {
802                item.validate(&helpers::child_path(path, "Othr"), config, collector);
803            }
804        }
805    }
806}
807
808// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
809#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
810pub struct PersonIdentificationSchemeName1Choice1 {
811    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
812    pub cd: Option<String>,
813    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
814    pub prtry: Option<String>,
815}
816
817impl Validate for PersonIdentificationSchemeName1Choice1 {
818    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
819        if let Some(ref val) = self.cd {
820            helpers::validate_length(
821                val,
822                "Cd",
823                Some(1),
824                Some(4),
825                &helpers::child_path(path, "Cd"),
826                config,
827                collector,
828            );
829        }
830        if let Some(ref val) = self.prtry {
831            helpers::validate_length(
832                val,
833                "Prtry",
834                Some(1),
835                Some(35),
836                &helpers::child_path(path, "Prtry"),
837                config,
838                collector,
839            );
840        }
841        if let Some(ref val) = self.prtry {
842            helpers::validate_pattern(
843                val,
844                "Prtry",
845                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
846                &helpers::child_path(path, "Prtry"),
847                config,
848                collector,
849            );
850        }
851    }
852}
853
854// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
855#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
856pub struct PostalAddress241 {
857    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
858    pub dept: Option<String>,
859    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
860    pub sub_dept: Option<String>,
861    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
862    pub strt_nm: Option<String>,
863    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
864    pub bldg_nb: Option<String>,
865    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
866    pub bldg_nm: Option<String>,
867    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
868    pub flr: Option<String>,
869    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
870    pub pst_bx: Option<String>,
871    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
872    pub room: Option<String>,
873    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
874    pub pst_cd: Option<String>,
875    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
876    pub twn_nm: Option<String>,
877    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
878    pub twn_lctn_nm: Option<String>,
879    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
880    pub dstrct_nm: Option<String>,
881    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
882    pub ctry_sub_dvsn: Option<String>,
883    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
884    pub ctry: Option<String>,
885    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
886    pub adr_line: Option<Vec<String>>,
887}
888
889impl Validate for PostalAddress241 {
890    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
891        if let Some(ref val) = self.dept {
892            helpers::validate_length(
893                val,
894                "Dept",
895                Some(1),
896                Some(70),
897                &helpers::child_path(path, "Dept"),
898                config,
899                collector,
900            );
901        }
902        if let Some(ref val) = self.dept {
903            helpers::validate_pattern(
904                val,
905                "Dept",
906                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
907                &helpers::child_path(path, "Dept"),
908                config,
909                collector,
910            );
911        }
912        if let Some(ref val) = self.sub_dept {
913            helpers::validate_length(
914                val,
915                "SubDept",
916                Some(1),
917                Some(70),
918                &helpers::child_path(path, "SubDept"),
919                config,
920                collector,
921            );
922        }
923        if let Some(ref val) = self.sub_dept {
924            helpers::validate_pattern(
925                val,
926                "SubDept",
927                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
928                &helpers::child_path(path, "SubDept"),
929                config,
930                collector,
931            );
932        }
933        if let Some(ref val) = self.strt_nm {
934            helpers::validate_length(
935                val,
936                "StrtNm",
937                Some(1),
938                Some(70),
939                &helpers::child_path(path, "StrtNm"),
940                config,
941                collector,
942            );
943        }
944        if let Some(ref val) = self.strt_nm {
945            helpers::validate_pattern(
946                val,
947                "StrtNm",
948                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
949                &helpers::child_path(path, "StrtNm"),
950                config,
951                collector,
952            );
953        }
954        if let Some(ref val) = self.bldg_nb {
955            helpers::validate_length(
956                val,
957                "BldgNb",
958                Some(1),
959                Some(16),
960                &helpers::child_path(path, "BldgNb"),
961                config,
962                collector,
963            );
964        }
965        if let Some(ref val) = self.bldg_nb {
966            helpers::validate_pattern(
967                val,
968                "BldgNb",
969                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
970                &helpers::child_path(path, "BldgNb"),
971                config,
972                collector,
973            );
974        }
975        if let Some(ref val) = self.bldg_nm {
976            helpers::validate_length(
977                val,
978                "BldgNm",
979                Some(1),
980                Some(35),
981                &helpers::child_path(path, "BldgNm"),
982                config,
983                collector,
984            );
985        }
986        if let Some(ref val) = self.bldg_nm {
987            helpers::validate_pattern(
988                val,
989                "BldgNm",
990                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
991                &helpers::child_path(path, "BldgNm"),
992                config,
993                collector,
994            );
995        }
996        if let Some(ref val) = self.flr {
997            helpers::validate_length(
998                val,
999                "Flr",
1000                Some(1),
1001                Some(70),
1002                &helpers::child_path(path, "Flr"),
1003                config,
1004                collector,
1005            );
1006        }
1007        if let Some(ref val) = self.flr {
1008            helpers::validate_pattern(
1009                val,
1010                "Flr",
1011                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1012                &helpers::child_path(path, "Flr"),
1013                config,
1014                collector,
1015            );
1016        }
1017        if let Some(ref val) = self.pst_bx {
1018            helpers::validate_length(
1019                val,
1020                "PstBx",
1021                Some(1),
1022                Some(16),
1023                &helpers::child_path(path, "PstBx"),
1024                config,
1025                collector,
1026            );
1027        }
1028        if let Some(ref val) = self.pst_bx {
1029            helpers::validate_pattern(
1030                val,
1031                "PstBx",
1032                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1033                &helpers::child_path(path, "PstBx"),
1034                config,
1035                collector,
1036            );
1037        }
1038        if let Some(ref val) = self.room {
1039            helpers::validate_length(
1040                val,
1041                "Room",
1042                Some(1),
1043                Some(70),
1044                &helpers::child_path(path, "Room"),
1045                config,
1046                collector,
1047            );
1048        }
1049        if let Some(ref val) = self.room {
1050            helpers::validate_pattern(
1051                val,
1052                "Room",
1053                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1054                &helpers::child_path(path, "Room"),
1055                config,
1056                collector,
1057            );
1058        }
1059        if let Some(ref val) = self.pst_cd {
1060            helpers::validate_length(
1061                val,
1062                "PstCd",
1063                Some(1),
1064                Some(16),
1065                &helpers::child_path(path, "PstCd"),
1066                config,
1067                collector,
1068            );
1069        }
1070        if let Some(ref val) = self.pst_cd {
1071            helpers::validate_pattern(
1072                val,
1073                "PstCd",
1074                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1075                &helpers::child_path(path, "PstCd"),
1076                config,
1077                collector,
1078            );
1079        }
1080        if let Some(ref val) = self.twn_nm {
1081            helpers::validate_length(
1082                val,
1083                "TwnNm",
1084                Some(1),
1085                Some(35),
1086                &helpers::child_path(path, "TwnNm"),
1087                config,
1088                collector,
1089            );
1090        }
1091        if let Some(ref val) = self.twn_nm {
1092            helpers::validate_pattern(
1093                val,
1094                "TwnNm",
1095                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1096                &helpers::child_path(path, "TwnNm"),
1097                config,
1098                collector,
1099            );
1100        }
1101        if let Some(ref val) = self.twn_lctn_nm {
1102            helpers::validate_length(
1103                val,
1104                "TwnLctnNm",
1105                Some(1),
1106                Some(35),
1107                &helpers::child_path(path, "TwnLctnNm"),
1108                config,
1109                collector,
1110            );
1111        }
1112        if let Some(ref val) = self.twn_lctn_nm {
1113            helpers::validate_pattern(
1114                val,
1115                "TwnLctnNm",
1116                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1117                &helpers::child_path(path, "TwnLctnNm"),
1118                config,
1119                collector,
1120            );
1121        }
1122        if let Some(ref val) = self.dstrct_nm {
1123            helpers::validate_length(
1124                val,
1125                "DstrctNm",
1126                Some(1),
1127                Some(35),
1128                &helpers::child_path(path, "DstrctNm"),
1129                config,
1130                collector,
1131            );
1132        }
1133        if let Some(ref val) = self.dstrct_nm {
1134            helpers::validate_pattern(
1135                val,
1136                "DstrctNm",
1137                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1138                &helpers::child_path(path, "DstrctNm"),
1139                config,
1140                collector,
1141            );
1142        }
1143        if let Some(ref val) = self.ctry_sub_dvsn {
1144            helpers::validate_length(
1145                val,
1146                "CtrySubDvsn",
1147                Some(1),
1148                Some(35),
1149                &helpers::child_path(path, "CtrySubDvsn"),
1150                config,
1151                collector,
1152            );
1153        }
1154        if let Some(ref val) = self.ctry_sub_dvsn {
1155            helpers::validate_pattern(
1156                val,
1157                "CtrySubDvsn",
1158                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1159                &helpers::child_path(path, "CtrySubDvsn"),
1160                config,
1161                collector,
1162            );
1163        }
1164        if let Some(ref val) = self.ctry {
1165            helpers::validate_pattern(
1166                val,
1167                "Ctry",
1168                "[A-Z]{2,2}",
1169                &helpers::child_path(path, "Ctry"),
1170                config,
1171                collector,
1172            );
1173        }
1174        if let Some(ref vec) = self.adr_line {
1175            for item in vec {
1176                helpers::validate_length(
1177                    item,
1178                    "AdrLine",
1179                    Some(1),
1180                    Some(70),
1181                    &helpers::child_path(path, "AdrLine"),
1182                    config,
1183                    collector,
1184                );
1185            }
1186        }
1187        if let Some(ref vec) = self.adr_line {
1188            for item in vec {
1189                helpers::validate_pattern(
1190                    item,
1191                    "AdrLine",
1192                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1193                    &helpers::child_path(path, "AdrLine"),
1194                    config,
1195                    collector,
1196                );
1197            }
1198        }
1199    }
1200}
1201
1202// StatusReason6Choice1: Reason for the status, in a proprietary form.
1203#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1204pub struct StatusReason6Choice1 {
1205    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1206    pub cd: Option<String>,
1207    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1208    pub prtry: Option<String>,
1209}
1210
1211impl Validate for StatusReason6Choice1 {
1212    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1213        if let Some(ref val) = self.cd {
1214            helpers::validate_length(
1215                val,
1216                "Cd",
1217                Some(1),
1218                Some(4),
1219                &helpers::child_path(path, "Cd"),
1220                config,
1221                collector,
1222            );
1223        }
1224        if let Some(ref val) = self.prtry {
1225            helpers::validate_length(
1226                val,
1227                "Prtry",
1228                Some(1),
1229                Some(35),
1230                &helpers::child_path(path, "Prtry"),
1231                config,
1232                collector,
1233            );
1234        }
1235        if let Some(ref val) = self.prtry {
1236            helpers::validate_pattern(
1237                val,
1238                "Prtry",
1239                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1240                &helpers::child_path(path, "Prtry"),
1241                config,
1242                collector,
1243            );
1244        }
1245    }
1246}
1247
1248// StatusReasonInformation121: Further details on the status reason.
1249//
1250// Usage: Additional information can be used for several purposes such as the reporting of repaired information.
1251#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1252pub struct StatusReasonInformation121 {
1253    #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
1254    pub orgtr: Option<PartyIdentification1351>,
1255    #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1256    pub rsn: Option<StatusReason6Choice1>,
1257    #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1258    pub addtl_inf: Option<Vec<String>>,
1259}
1260
1261impl Validate for StatusReasonInformation121 {
1262    fn validate(&self, path: &str, config: &ParserConfig, collector: &mut ErrorCollector) {
1263        if let Some(ref val) = self.orgtr
1264            && config.validate_optional_fields
1265        {
1266            val.validate(&helpers::child_path(path, "Orgtr"), config, collector);
1267        }
1268        if let Some(ref val) = self.rsn
1269            && config.validate_optional_fields
1270        {
1271            val.validate(&helpers::child_path(path, "Rsn"), config, collector);
1272        }
1273        if let Some(ref vec) = self.addtl_inf {
1274            for item in vec {
1275                helpers::validate_length(
1276                    item,
1277                    "AddtlInf",
1278                    Some(1),
1279                    Some(105),
1280                    &helpers::child_path(path, "AddtlInf"),
1281                    config,
1282                    collector,
1283                );
1284            }
1285        }
1286        if let Some(ref vec) = self.addtl_inf {
1287            for item in vec {
1288                helpers::validate_pattern(
1289                    item,
1290                    "AddtlInf",
1291                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+",
1292                    &helpers::child_path(path, "AddtlInf"),
1293                    config,
1294                    collector,
1295                );
1296            }
1297        }
1298    }
1299}