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