mx_message/document/
camt_107_001_01.rs

1// Plasmatic MX Message Parsing Library
2// https://github.com/GoPlasmatic/MXMessage
3//
4// Copyright (c) 2025 Plasmatic
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//     http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// You may obtain a copy of this library at
18// https://github.com/GoPlasmatic/MXMessage
19
20use crate::error::*;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24// AccountIdentification4Choice1: Unique identification of an account, as assigned by the account servicer, using an identification scheme.
25#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice1 {
27    #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
28    pub iban: Option<String>,
29    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
30    pub othr: Option<GenericAccountIdentification11>,
31}
32
33impl AccountIdentification4Choice1 {
34    pub fn validate(&self) -> Result<(), ValidationError> {
35        if let Some(ref val) = self.iban {
36            let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
37            if !pattern.is_match(val) {
38                return Err(ValidationError::new(
39                    1005,
40                    "iban does not match the required pattern".to_string(),
41                ));
42            }
43        }
44        if let Some(ref val) = self.othr {
45            val.validate()?
46        }
47        Ok(())
48    }
49}
50
51// AccountSchemeName1Choice1: Name of the identification scheme, in a free text form.
52#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountSchemeName1Choice1 {
54    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55    pub cd: Option<String>,
56    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57    pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice1 {
61    pub fn validate(&self) -> Result<(), ValidationError> {
62        if let Some(ref val) = self.cd {
63            if val.chars().count() < 1 {
64                return Err(ValidationError::new(
65                    1001,
66                    "cd is shorter than the minimum length of 1".to_string(),
67                ));
68            }
69            if val.chars().count() > 4 {
70                return Err(ValidationError::new(
71                    1002,
72                    "cd exceeds the maximum length of 4".to_string(),
73                ));
74            }
75        }
76        if let Some(ref val) = self.prtry {
77            if val.chars().count() < 1 {
78                return Err(ValidationError::new(
79                    1001,
80                    "prtry is shorter than the minimum length of 1".to_string(),
81                ));
82            }
83            if val.chars().count() > 35 {
84                return Err(ValidationError::new(
85                    1002,
86                    "prtry exceeds the maximum length of 35".to_string(),
87                ));
88            }
89            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
90            if !pattern.is_match(val) {
91                return Err(ValidationError::new(
92                    1005,
93                    "prtry does not match the required pattern".to_string(),
94                ));
95            }
96        }
97        Ok(())
98    }
99}
100
101// BranchAndFinancialInstitutionIdentification61: Unique and unambiguous identification of a financial institution, as assigned under an internationally recognised or proprietary identification scheme.
102#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
103pub struct BranchAndFinancialInstitutionIdentification61 {
104    #[serde(rename = "FinInstnId")]
105    pub fin_instn_id: FinancialInstitutionIdentification181,
106}
107
108impl BranchAndFinancialInstitutionIdentification61 {
109    pub fn validate(&self) -> Result<(), ValidationError> {
110        self.fin_instn_id.validate()?;
111        Ok(())
112    }
113}
114
115// CBPRAmount: CBPR_Amount
116#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
117pub struct CBPRAmount {
118    #[serde(rename = "@Ccy")]
119    pub ccy: String,
120    #[serde(rename = "$value")]
121    pub value: f64,
122}
123
124impl CBPRAmount {
125    pub fn validate(&self) -> Result<(), ValidationError> {
126        Ok(())
127    }
128}
129
130// CashAccount401: Specifies an alternate assumed name for the identification of the account.
131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
132pub struct CashAccount401 {
133    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
134    pub id: Option<AccountIdentification4Choice1>,
135    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
136    pub tp: Option<CashAccountType2Choice1>,
137    #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
138    pub ccy: Option<String>,
139    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
140    pub nm: Option<String>,
141    #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
142    pub prxy: Option<ProxyAccountIdentification11>,
143}
144
145impl CashAccount401 {
146    pub fn validate(&self) -> Result<(), ValidationError> {
147        if let Some(ref val) = self.id {
148            val.validate()?
149        }
150        if let Some(ref val) = self.tp {
151            val.validate()?
152        }
153        if let Some(ref val) = self.ccy {
154            let pattern = Regex::new("[A-Z]{3,3}").unwrap();
155            if !pattern.is_match(val) {
156                return Err(ValidationError::new(
157                    1005,
158                    "ccy does not match the required pattern".to_string(),
159                ));
160            }
161        }
162        if let Some(ref val) = self.nm {
163            if val.chars().count() < 1 {
164                return Err(ValidationError::new(
165                    1001,
166                    "nm is shorter than the minimum length of 1".to_string(),
167                ));
168            }
169            if val.chars().count() > 70 {
170                return Err(ValidationError::new(
171                    1002,
172                    "nm exceeds the maximum length of 70".to_string(),
173                ));
174            }
175            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
176            if !pattern.is_match(val) {
177                return Err(ValidationError::new(
178                    1005,
179                    "nm does not match the required pattern".to_string(),
180                ));
181            }
182        }
183        if let Some(ref val) = self.prxy {
184            val.validate()?
185        }
186        Ok(())
187    }
188}
189
190// CashAccountType2Choice1: Nature or use of the account in a proprietary form.
191#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
192pub struct CashAccountType2Choice1 {
193    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
194    pub cd: Option<String>,
195    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
196    pub prtry: Option<String>,
197}
198
199impl CashAccountType2Choice1 {
200    pub fn validate(&self) -> Result<(), ValidationError> {
201        if let Some(ref val) = self.cd {
202            if val.chars().count() < 1 {
203                return Err(ValidationError::new(
204                    1001,
205                    "cd is shorter than the minimum length of 1".to_string(),
206                ));
207            }
208            if val.chars().count() > 4 {
209                return Err(ValidationError::new(
210                    1002,
211                    "cd exceeds the maximum length of 4".to_string(),
212                ));
213            }
214        }
215        if let Some(ref val) = self.prtry {
216            if val.chars().count() < 1 {
217                return Err(ValidationError::new(
218                    1001,
219                    "prtry is shorter than the minimum length of 1".to_string(),
220                ));
221            }
222            if val.chars().count() > 35 {
223                return Err(ValidationError::new(
224                    1002,
225                    "prtry exceeds the maximum length of 35".to_string(),
226                ));
227            }
228            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
229            if !pattern.is_match(val) {
230                return Err(ValidationError::new(
231                    1005,
232                    "prtry does not match the required pattern".to_string(),
233                ));
234            }
235        }
236        Ok(())
237    }
238}
239
240// Cheque131: Party that receives an amount of money as specified in the cheque.
241#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
242pub struct Cheque131 {
243    #[serde(rename = "InstrId")]
244    pub instr_id: String,
245    #[serde(rename = "ChqNb")]
246    pub chq_nb: String,
247    #[serde(rename = "IsseDt")]
248    pub isse_dt: String,
249    #[serde(rename = "StlDt", skip_serializing_if = "Option::is_none")]
250    pub stl_dt: Option<String>,
251    #[serde(rename = "Amt")]
252    pub amt: CBPRAmount,
253    #[serde(rename = "ValDt", skip_serializing_if = "Option::is_none")]
254    pub val_dt: Option<DateAndDateTime2Choice1>,
255    #[serde(rename = "Pyer")]
256    pub pyer: PartyIdentification1351,
257    #[serde(rename = "PyerAcct", skip_serializing_if = "Option::is_none")]
258    pub pyer_acct: Option<CashAccount401>,
259    #[serde(rename = "DrwrAgt", skip_serializing_if = "Option::is_none")]
260    pub drwr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
261    #[serde(rename = "DrwrAgtAcct", skip_serializing_if = "Option::is_none")]
262    pub drwr_agt_acct: Option<CashAccount401>,
263    #[serde(rename = "Pyee")]
264    pub pyee: PartyIdentification1352,
265}
266
267impl Cheque131 {
268    pub fn validate(&self) -> Result<(), ValidationError> {
269        if self.instr_id.chars().count() < 1 {
270            return Err(ValidationError::new(
271                1001,
272                "instr_id is shorter than the minimum length of 1".to_string(),
273            ));
274        }
275        if self.instr_id.chars().count() > 35 {
276            return Err(ValidationError::new(
277                1002,
278                "instr_id exceeds the maximum length of 35".to_string(),
279            ));
280        }
281        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
282        if !pattern.is_match(&self.instr_id) {
283            return Err(ValidationError::new(
284                1005,
285                "instr_id does not match the required pattern".to_string(),
286            ));
287        }
288        if self.chq_nb.chars().count() < 1 {
289            return Err(ValidationError::new(
290                1001,
291                "chq_nb is shorter than the minimum length of 1".to_string(),
292            ));
293        }
294        if self.chq_nb.chars().count() > 16 {
295            return Err(ValidationError::new(
296                1002,
297                "chq_nb exceeds the maximum length of 16".to_string(),
298            ));
299        }
300        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
301        if !pattern.is_match(&self.chq_nb) {
302            return Err(ValidationError::new(
303                1005,
304                "chq_nb does not match the required pattern".to_string(),
305            ));
306        }
307        self.amt.validate()?;
308        if let Some(ref val) = self.val_dt {
309            val.validate()?
310        }
311        self.pyer.validate()?;
312        if let Some(ref val) = self.pyer_acct {
313            val.validate()?
314        }
315        if let Some(ref val) = self.drwr_agt {
316            val.validate()?
317        }
318        if let Some(ref val) = self.drwr_agt_acct {
319            val.validate()?
320        }
321        self.pyee.validate()?;
322        Ok(())
323    }
324}
325
326// ChequePresentmentNotificationV01: Specifies the details of the cheque.
327#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
328pub struct ChequePresentmentNotificationV01 {
329    #[serde(rename = "GrpHdr")]
330    pub grp_hdr: GroupHeader1031,
331    #[serde(rename = "Chq")]
332    pub chq: Cheque131,
333}
334
335impl ChequePresentmentNotificationV01 {
336    pub fn validate(&self) -> Result<(), ValidationError> {
337        self.grp_hdr.validate()?;
338        self.chq.validate()?;
339        Ok(())
340    }
341}
342
343// ClearingSystemIdentification2Choice1: Identification of a clearing system, in a coded form as published in an external list.
344#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
345pub struct ClearingSystemIdentification2Choice1 {
346    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
347    pub cd: Option<String>,
348}
349
350impl ClearingSystemIdentification2Choice1 {
351    pub fn validate(&self) -> Result<(), ValidationError> {
352        if let Some(ref val) = self.cd {
353            if val.chars().count() < 1 {
354                return Err(ValidationError::new(
355                    1001,
356                    "cd is shorter than the minimum length of 1".to_string(),
357                ));
358            }
359            if val.chars().count() > 5 {
360                return Err(ValidationError::new(
361                    1002,
362                    "cd exceeds the maximum length of 5".to_string(),
363                ));
364            }
365        }
366        Ok(())
367    }
368}
369
370// ClearingSystemMemberIdentification21: Identification of a member of a clearing system.
371#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
372pub struct ClearingSystemMemberIdentification21 {
373    #[serde(rename = "ClrSysId")]
374    pub clr_sys_id: ClearingSystemIdentification2Choice1,
375    #[serde(rename = "MmbId")]
376    pub mmb_id: String,
377}
378
379impl ClearingSystemMemberIdentification21 {
380    pub fn validate(&self) -> Result<(), ValidationError> {
381        self.clr_sys_id.validate()?;
382        if self.mmb_id.chars().count() < 1 {
383            return Err(ValidationError::new(
384                1001,
385                "mmb_id is shorter than the minimum length of 1".to_string(),
386            ));
387        }
388        if self.mmb_id.chars().count() > 28 {
389            return Err(ValidationError::new(
390                1002,
391                "mmb_id exceeds the maximum length of 28".to_string(),
392            ));
393        }
394        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
395        if !pattern.is_match(&self.mmb_id) {
396            return Err(ValidationError::new(
397                1005,
398                "mmb_id does not match the required pattern".to_string(),
399            ));
400        }
401        Ok(())
402    }
403}
404
405// DateAndDateTime2Choice1: Specified date.
406#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
407pub struct DateAndDateTime2Choice1 {
408    #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
409    pub dt: Option<String>,
410}
411
412impl DateAndDateTime2Choice1 {
413    pub fn validate(&self) -> Result<(), ValidationError> {
414        Ok(())
415    }
416}
417
418// DateAndPlaceOfBirth11: Country where a person was born.
419#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
420pub struct DateAndPlaceOfBirth11 {
421    #[serde(rename = "BirthDt")]
422    pub birth_dt: String,
423    #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
424    pub prvc_of_birth: Option<String>,
425    #[serde(rename = "CityOfBirth")]
426    pub city_of_birth: String,
427    #[serde(rename = "CtryOfBirth")]
428    pub ctry_of_birth: String,
429}
430
431impl DateAndPlaceOfBirth11 {
432    pub fn validate(&self) -> Result<(), ValidationError> {
433        if let Some(ref val) = self.prvc_of_birth {
434            if val.chars().count() < 1 {
435                return Err(ValidationError::new(
436                    1001,
437                    "prvc_of_birth is shorter than the minimum length of 1".to_string(),
438                ));
439            }
440            if val.chars().count() > 35 {
441                return Err(ValidationError::new(
442                    1002,
443                    "prvc_of_birth exceeds the maximum length of 35".to_string(),
444                ));
445            }
446            let pattern = Regex::new(
447                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
448            )
449            .unwrap();
450            if !pattern.is_match(val) {
451                return Err(ValidationError::new(
452                    1005,
453                    "prvc_of_birth does not match the required pattern".to_string(),
454                ));
455            }
456        }
457        if self.city_of_birth.chars().count() < 1 {
458            return Err(ValidationError::new(
459                1001,
460                "city_of_birth is shorter than the minimum length of 1".to_string(),
461            ));
462        }
463        if self.city_of_birth.chars().count() > 35 {
464            return Err(ValidationError::new(
465                1002,
466                "city_of_birth exceeds the maximum length of 35".to_string(),
467            ));
468        }
469        let pattern =
470            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
471                .unwrap();
472        if !pattern.is_match(&self.city_of_birth) {
473            return Err(ValidationError::new(
474                1005,
475                "city_of_birth does not match the required pattern".to_string(),
476            ));
477        }
478        let pattern = Regex::new("[A-Z]{2,2}").unwrap();
479        if !pattern.is_match(&self.ctry_of_birth) {
480            return Err(ValidationError::new(
481                1005,
482                "ctry_of_birth does not match the required pattern".to_string(),
483            ));
484        }
485        Ok(())
486    }
487}
488
489// FinancialInstitutionIdentification181: Information that locates and identifies a specific address, as defined by postal services.
490#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
491pub struct FinancialInstitutionIdentification181 {
492    #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
493    pub bicfi: Option<String>,
494    #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
495    pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
496    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
497    pub lei: Option<String>,
498    #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
499    pub nm: Option<String>,
500    #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
501    pub pstl_adr: Option<PostalAddress241>,
502}
503
504impl FinancialInstitutionIdentification181 {
505    pub fn validate(&self) -> Result<(), ValidationError> {
506        if let Some(ref val) = self.bicfi {
507            let pattern =
508                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
509            if !pattern.is_match(val) {
510                return Err(ValidationError::new(
511                    1005,
512                    "bicfi does not match the required pattern".to_string(),
513                ));
514            }
515        }
516        if let Some(ref val) = self.clr_sys_mmb_id {
517            val.validate()?
518        }
519        if let Some(ref val) = self.lei {
520            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
521            if !pattern.is_match(val) {
522                return Err(ValidationError::new(
523                    1005,
524                    "lei does not match the required pattern".to_string(),
525                ));
526            }
527        }
528        if let Some(ref val) = self.nm {
529            if val.chars().count() < 1 {
530                return Err(ValidationError::new(
531                    1001,
532                    "nm is shorter than the minimum length of 1".to_string(),
533                ));
534            }
535            if val.chars().count() > 140 {
536                return Err(ValidationError::new(
537                    1002,
538                    "nm exceeds the maximum length of 140".to_string(),
539                ));
540            }
541            let pattern = Regex::new(
542                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
543            )
544            .unwrap();
545            if !pattern.is_match(val) {
546                return Err(ValidationError::new(
547                    1005,
548                    "nm does not match the required pattern".to_string(),
549                ));
550            }
551        }
552        if let Some(ref val) = self.pstl_adr {
553            val.validate()?
554        }
555        Ok(())
556    }
557}
558
559// GenericAccountIdentification11: Entity that assigns the identification.
560#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
561pub struct GenericAccountIdentification11 {
562    #[serde(rename = "Id")]
563    pub id: String,
564    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
565    pub schme_nm: Option<AccountSchemeName1Choice1>,
566    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
567    pub issr: Option<String>,
568}
569
570impl GenericAccountIdentification11 {
571    pub fn validate(&self) -> Result<(), ValidationError> {
572        if self.id.chars().count() < 1 {
573            return Err(ValidationError::new(
574                1001,
575                "id is shorter than the minimum length of 1".to_string(),
576            ));
577        }
578        if self.id.chars().count() > 34 {
579            return Err(ValidationError::new(
580                1002,
581                "id exceeds the maximum length of 34".to_string(),
582            ));
583        }
584        let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
585        if !pattern.is_match(&self.id) {
586            return Err(ValidationError::new(
587                1005,
588                "id does not match the required pattern".to_string(),
589            ));
590        }
591        if let Some(ref val) = self.schme_nm {
592            val.validate()?
593        }
594        if let Some(ref val) = self.issr {
595            if val.chars().count() < 1 {
596                return Err(ValidationError::new(
597                    1001,
598                    "issr is shorter than the minimum length of 1".to_string(),
599                ));
600            }
601            if val.chars().count() > 35 {
602                return Err(ValidationError::new(
603                    1002,
604                    "issr exceeds the maximum length of 35".to_string(),
605                ));
606            }
607            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
608            if !pattern.is_match(val) {
609                return Err(ValidationError::new(
610                    1005,
611                    "issr does not match the required pattern".to_string(),
612                ));
613            }
614        }
615        Ok(())
616    }
617}
618
619// GenericOrganisationIdentification11: Entity that assigns the identification.
620#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
621pub struct GenericOrganisationIdentification11 {
622    #[serde(rename = "Id")]
623    pub id: String,
624    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
625    pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
626    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
627    pub issr: Option<String>,
628}
629
630impl GenericOrganisationIdentification11 {
631    pub fn validate(&self) -> Result<(), ValidationError> {
632        if self.id.chars().count() < 1 {
633            return Err(ValidationError::new(
634                1001,
635                "id is shorter than the minimum length of 1".to_string(),
636            ));
637        }
638        if self.id.chars().count() > 35 {
639            return Err(ValidationError::new(
640                1002,
641                "id exceeds the maximum length of 35".to_string(),
642            ));
643        }
644        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
645        if !pattern.is_match(&self.id) {
646            return Err(ValidationError::new(
647                1005,
648                "id does not match the required pattern".to_string(),
649            ));
650        }
651        if let Some(ref val) = self.schme_nm {
652            val.validate()?
653        }
654        if let Some(ref val) = self.issr {
655            if val.chars().count() < 1 {
656                return Err(ValidationError::new(
657                    1001,
658                    "issr is shorter than the minimum length of 1".to_string(),
659                ));
660            }
661            if val.chars().count() > 35 {
662                return Err(ValidationError::new(
663                    1002,
664                    "issr exceeds the maximum length of 35".to_string(),
665                ));
666            }
667            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
668            if !pattern.is_match(val) {
669                return Err(ValidationError::new(
670                    1005,
671                    "issr does not match the required pattern".to_string(),
672                ));
673            }
674        }
675        Ok(())
676    }
677}
678
679// GenericPersonIdentification11: Entity that assigns the identification.
680#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
681pub struct GenericPersonIdentification11 {
682    #[serde(rename = "Id")]
683    pub id: String,
684    #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
685    pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
686    #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
687    pub issr: Option<String>,
688}
689
690impl GenericPersonIdentification11 {
691    pub fn validate(&self) -> Result<(), ValidationError> {
692        if self.id.chars().count() < 1 {
693            return Err(ValidationError::new(
694                1001,
695                "id is shorter than the minimum length of 1".to_string(),
696            ));
697        }
698        if self.id.chars().count() > 35 {
699            return Err(ValidationError::new(
700                1002,
701                "id exceeds the maximum length of 35".to_string(),
702            ));
703        }
704        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
705        if !pattern.is_match(&self.id) {
706            return Err(ValidationError::new(
707                1005,
708                "id does not match the required pattern".to_string(),
709            ));
710        }
711        if let Some(ref val) = self.schme_nm {
712            val.validate()?
713        }
714        if let Some(ref val) = self.issr {
715            if val.chars().count() < 1 {
716                return Err(ValidationError::new(
717                    1001,
718                    "issr is shorter than the minimum length of 1".to_string(),
719                ));
720            }
721            if val.chars().count() > 35 {
722                return Err(ValidationError::new(
723                    1002,
724                    "issr exceeds the maximum length of 35".to_string(),
725                ));
726            }
727            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
728            if !pattern.is_match(val) {
729                return Err(ValidationError::new(
730                    1005,
731                    "issr does not match the required pattern".to_string(),
732                ));
733            }
734        }
735        Ok(())
736    }
737}
738
739// GroupHeader1031: Number of individual cheques contained in the message.
740#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
741pub struct GroupHeader1031 {
742    #[serde(rename = "MsgId")]
743    pub msg_id: String,
744    #[serde(rename = "CreDtTm")]
745    pub cre_dt_tm: String,
746    #[serde(rename = "NbOfChqs")]
747    pub nb_of_chqs: Max15NumericTextfixed,
748}
749
750impl GroupHeader1031 {
751    pub fn validate(&self) -> Result<(), ValidationError> {
752        if self.msg_id.chars().count() < 1 {
753            return Err(ValidationError::new(
754                1001,
755                "msg_id is shorter than the minimum length of 1".to_string(),
756            ));
757        }
758        if self.msg_id.chars().count() > 16 {
759            return Err(ValidationError::new(
760                1002,
761                "msg_id exceeds the maximum length of 16".to_string(),
762            ));
763        }
764        let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
765        if !pattern.is_match(&self.msg_id) {
766            return Err(ValidationError::new(
767                1005,
768                "msg_id does not match the required pattern".to_string(),
769            ));
770        }
771        let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
772        if !pattern.is_match(&self.cre_dt_tm) {
773            return Err(ValidationError::new(
774                1005,
775                "cre_dt_tm does not match the required pattern".to_string(),
776            ));
777        }
778        self.nb_of_chqs.validate()?;
779        Ok(())
780    }
781}
782
783// Max15NumericText_fixed: 1
784#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
785pub enum Max15NumericTextfixed {
786    #[default]
787    #[serde(rename = "1")]
788    Code1,
789}
790
791impl Max15NumericTextfixed {
792    pub fn validate(&self) -> Result<(), ValidationError> {
793        Ok(())
794    }
795}
796
797// OrganisationIdentification291: Unique identification of an organisation, as assigned by an institution, using an identification scheme.
798#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
799pub struct OrganisationIdentification291 {
800    #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
801    pub any_bic: Option<String>,
802    #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
803    pub lei: Option<String>,
804    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
805    pub othr: Option<Vec<GenericOrganisationIdentification11>>,
806}
807
808impl OrganisationIdentification291 {
809    pub fn validate(&self) -> Result<(), ValidationError> {
810        if let Some(ref val) = self.any_bic {
811            let pattern =
812                Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
813            if !pattern.is_match(val) {
814                return Err(ValidationError::new(
815                    1005,
816                    "any_bic does not match the required pattern".to_string(),
817                ));
818            }
819        }
820        if let Some(ref val) = self.lei {
821            let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
822            if !pattern.is_match(val) {
823                return Err(ValidationError::new(
824                    1005,
825                    "lei does not match the required pattern".to_string(),
826                ));
827            }
828        }
829        if let Some(ref vec) = self.othr {
830            for item in vec {
831                item.validate()?
832            }
833        }
834        Ok(())
835    }
836}
837
838// OrganisationIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
839#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
840pub struct OrganisationIdentificationSchemeName1Choice1 {
841    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
842    pub cd: Option<String>,
843    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
844    pub prtry: Option<String>,
845}
846
847impl OrganisationIdentificationSchemeName1Choice1 {
848    pub fn validate(&self) -> Result<(), ValidationError> {
849        if let Some(ref val) = self.cd {
850            if val.chars().count() < 1 {
851                return Err(ValidationError::new(
852                    1001,
853                    "cd is shorter than the minimum length of 1".to_string(),
854                ));
855            }
856            if val.chars().count() > 4 {
857                return Err(ValidationError::new(
858                    1002,
859                    "cd exceeds the maximum length of 4".to_string(),
860                ));
861            }
862        }
863        if let Some(ref val) = self.prtry {
864            if val.chars().count() < 1 {
865                return Err(ValidationError::new(
866                    1001,
867                    "prtry is shorter than the minimum length of 1".to_string(),
868                ));
869            }
870            if val.chars().count() > 35 {
871                return Err(ValidationError::new(
872                    1002,
873                    "prtry exceeds the maximum length of 35".to_string(),
874                ));
875            }
876            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
877            if !pattern.is_match(val) {
878                return Err(ValidationError::new(
879                    1005,
880                    "prtry does not match the required pattern".to_string(),
881                ));
882            }
883        }
884        Ok(())
885    }
886}
887
888// Party38Choice1: Unique and unambiguous identification of a person, for example a passport.
889#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
890pub struct Party38Choice1 {
891    #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
892    pub org_id: Option<OrganisationIdentification291>,
893    #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
894    pub prvt_id: Option<PersonIdentification131>,
895}
896
897impl Party38Choice1 {
898    pub fn validate(&self) -> Result<(), ValidationError> {
899        if let Some(ref val) = self.org_id {
900            val.validate()?
901        }
902        if let Some(ref val) = self.prvt_id {
903            val.validate()?
904        }
905        Ok(())
906    }
907}
908
909// 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.
910#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
911pub struct PartyIdentification1351 {
912    #[serde(rename = "Nm")]
913    pub nm: String,
914    #[serde(rename = "PstlAdr")]
915    pub pstl_adr: PostalAddress241,
916    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
917    pub id: Option<Party38Choice1>,
918    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
919    pub ctry_of_res: Option<String>,
920}
921
922impl PartyIdentification1351 {
923    pub fn validate(&self) -> Result<(), ValidationError> {
924        if self.nm.chars().count() < 1 {
925            return Err(ValidationError::new(
926                1001,
927                "nm is shorter than the minimum length of 1".to_string(),
928            ));
929        }
930        if self.nm.chars().count() > 140 {
931            return Err(ValidationError::new(
932                1002,
933                "nm exceeds the maximum length of 140".to_string(),
934            ));
935        }
936        let pattern =
937            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
938                .unwrap();
939        if !pattern.is_match(&self.nm) {
940            return Err(ValidationError::new(
941                1005,
942                "nm does not match the required pattern".to_string(),
943            ));
944        }
945        self.pstl_adr.validate()?;
946        if let Some(ref val) = self.id {
947            val.validate()?
948        }
949        if let Some(ref val) = self.ctry_of_res {
950            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
951            if !pattern.is_match(val) {
952                return Err(ValidationError::new(
953                    1005,
954                    "ctry_of_res does not match the required pattern".to_string(),
955                ));
956            }
957        }
958        Ok(())
959    }
960}
961
962// PartyIdentification1352: Country in which a person resides (the place of a person's home). In the case of a company, it is the country from which the affairs of that company are directed.
963#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
964pub struct PartyIdentification1352 {
965    #[serde(rename = "Nm")]
966    pub nm: String,
967    #[serde(rename = "PstlAdr")]
968    pub pstl_adr: PostalAddress242,
969    #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
970    pub id: Option<Party38Choice1>,
971    #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
972    pub ctry_of_res: Option<String>,
973}
974
975impl PartyIdentification1352 {
976    pub fn validate(&self) -> Result<(), ValidationError> {
977        if self.nm.chars().count() < 1 {
978            return Err(ValidationError::new(
979                1001,
980                "nm is shorter than the minimum length of 1".to_string(),
981            ));
982        }
983        if self.nm.chars().count() > 140 {
984            return Err(ValidationError::new(
985                1002,
986                "nm exceeds the maximum length of 140".to_string(),
987            ));
988        }
989        let pattern =
990            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
991                .unwrap();
992        if !pattern.is_match(&self.nm) {
993            return Err(ValidationError::new(
994                1005,
995                "nm does not match the required pattern".to_string(),
996            ));
997        }
998        self.pstl_adr.validate()?;
999        if let Some(ref val) = self.id {
1000            val.validate()?
1001        }
1002        if let Some(ref val) = self.ctry_of_res {
1003            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1004            if !pattern.is_match(val) {
1005                return Err(ValidationError::new(
1006                    1005,
1007                    "ctry_of_res does not match the required pattern".to_string(),
1008                ));
1009            }
1010        }
1011        Ok(())
1012    }
1013}
1014
1015// PersonIdentification131: Unique identification of a person, as assigned by an institution, using an identification scheme.
1016#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1017pub struct PersonIdentification131 {
1018    #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
1019    pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
1020    #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1021    pub othr: Option<Vec<GenericPersonIdentification11>>,
1022}
1023
1024impl PersonIdentification131 {
1025    pub fn validate(&self) -> Result<(), ValidationError> {
1026        if let Some(ref val) = self.dt_and_plc_of_birth {
1027            val.validate()?
1028        }
1029        if let Some(ref vec) = self.othr {
1030            for item in vec {
1031                item.validate()?
1032            }
1033        }
1034        Ok(())
1035    }
1036}
1037
1038// PersonIdentificationSchemeName1Choice1: Name of the identification scheme, in a free text form.
1039#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1040pub struct PersonIdentificationSchemeName1Choice1 {
1041    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1042    pub cd: Option<String>,
1043    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1044    pub prtry: Option<String>,
1045}
1046
1047impl PersonIdentificationSchemeName1Choice1 {
1048    pub fn validate(&self) -> Result<(), ValidationError> {
1049        if let Some(ref val) = self.cd {
1050            if val.chars().count() < 1 {
1051                return Err(ValidationError::new(
1052                    1001,
1053                    "cd is shorter than the minimum length of 1".to_string(),
1054                ));
1055            }
1056            if val.chars().count() > 4 {
1057                return Err(ValidationError::new(
1058                    1002,
1059                    "cd exceeds the maximum length of 4".to_string(),
1060                ));
1061            }
1062        }
1063        if let Some(ref val) = self.prtry {
1064            if val.chars().count() < 1 {
1065                return Err(ValidationError::new(
1066                    1001,
1067                    "prtry is shorter than the minimum length of 1".to_string(),
1068                ));
1069            }
1070            if val.chars().count() > 35 {
1071                return Err(ValidationError::new(
1072                    1002,
1073                    "prtry exceeds the maximum length of 35".to_string(),
1074                ));
1075            }
1076            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1077            if !pattern.is_match(val) {
1078                return Err(ValidationError::new(
1079                    1005,
1080                    "prtry does not match the required pattern".to_string(),
1081                ));
1082            }
1083        }
1084        Ok(())
1085    }
1086}
1087
1088// PostalAddress241: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
1089#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1090pub struct PostalAddress241 {
1091    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1092    pub dept: Option<String>,
1093    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1094    pub sub_dept: Option<String>,
1095    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1096    pub strt_nm: Option<String>,
1097    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1098    pub bldg_nb: Option<String>,
1099    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1100    pub bldg_nm: Option<String>,
1101    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1102    pub flr: Option<String>,
1103    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1104    pub pst_bx: Option<String>,
1105    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1106    pub room: Option<String>,
1107    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1108    pub pst_cd: Option<String>,
1109    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1110    pub twn_nm: Option<String>,
1111    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1112    pub twn_lctn_nm: Option<String>,
1113    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1114    pub dstrct_nm: Option<String>,
1115    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1116    pub ctry_sub_dvsn: Option<String>,
1117    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1118    pub ctry: Option<String>,
1119    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1120    pub adr_line: Option<Vec<String>>,
1121}
1122
1123impl PostalAddress241 {
1124    pub fn validate(&self) -> Result<(), ValidationError> {
1125        if let Some(ref val) = self.dept {
1126            if val.chars().count() < 1 {
1127                return Err(ValidationError::new(
1128                    1001,
1129                    "dept is shorter than the minimum length of 1".to_string(),
1130                ));
1131            }
1132            if val.chars().count() > 70 {
1133                return Err(ValidationError::new(
1134                    1002,
1135                    "dept exceeds the maximum length of 70".to_string(),
1136                ));
1137            }
1138            let pattern = Regex::new(
1139                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1140            )
1141            .unwrap();
1142            if !pattern.is_match(val) {
1143                return Err(ValidationError::new(
1144                    1005,
1145                    "dept does not match the required pattern".to_string(),
1146                ));
1147            }
1148        }
1149        if let Some(ref val) = self.sub_dept {
1150            if val.chars().count() < 1 {
1151                return Err(ValidationError::new(
1152                    1001,
1153                    "sub_dept is shorter than the minimum length of 1".to_string(),
1154                ));
1155            }
1156            if val.chars().count() > 70 {
1157                return Err(ValidationError::new(
1158                    1002,
1159                    "sub_dept exceeds the maximum length of 70".to_string(),
1160                ));
1161            }
1162            let pattern = Regex::new(
1163                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1164            )
1165            .unwrap();
1166            if !pattern.is_match(val) {
1167                return Err(ValidationError::new(
1168                    1005,
1169                    "sub_dept does not match the required pattern".to_string(),
1170                ));
1171            }
1172        }
1173        if let Some(ref val) = self.strt_nm {
1174            if val.chars().count() < 1 {
1175                return Err(ValidationError::new(
1176                    1001,
1177                    "strt_nm is shorter than the minimum length of 1".to_string(),
1178                ));
1179            }
1180            if val.chars().count() > 70 {
1181                return Err(ValidationError::new(
1182                    1002,
1183                    "strt_nm exceeds the maximum length of 70".to_string(),
1184                ));
1185            }
1186            let pattern = Regex::new(
1187                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1188            )
1189            .unwrap();
1190            if !pattern.is_match(val) {
1191                return Err(ValidationError::new(
1192                    1005,
1193                    "strt_nm does not match the required pattern".to_string(),
1194                ));
1195            }
1196        }
1197        if let Some(ref val) = self.bldg_nb {
1198            if val.chars().count() < 1 {
1199                return Err(ValidationError::new(
1200                    1001,
1201                    "bldg_nb is shorter than the minimum length of 1".to_string(),
1202                ));
1203            }
1204            if val.chars().count() > 16 {
1205                return Err(ValidationError::new(
1206                    1002,
1207                    "bldg_nb exceeds the maximum length of 16".to_string(),
1208                ));
1209            }
1210            let pattern = Regex::new(
1211                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1212            )
1213            .unwrap();
1214            if !pattern.is_match(val) {
1215                return Err(ValidationError::new(
1216                    1005,
1217                    "bldg_nb does not match the required pattern".to_string(),
1218                ));
1219            }
1220        }
1221        if let Some(ref val) = self.bldg_nm {
1222            if val.chars().count() < 1 {
1223                return Err(ValidationError::new(
1224                    1001,
1225                    "bldg_nm is shorter than the minimum length of 1".to_string(),
1226                ));
1227            }
1228            if val.chars().count() > 35 {
1229                return Err(ValidationError::new(
1230                    1002,
1231                    "bldg_nm exceeds the maximum length of 35".to_string(),
1232                ));
1233            }
1234            let pattern = Regex::new(
1235                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1236            )
1237            .unwrap();
1238            if !pattern.is_match(val) {
1239                return Err(ValidationError::new(
1240                    1005,
1241                    "bldg_nm does not match the required pattern".to_string(),
1242                ));
1243            }
1244        }
1245        if let Some(ref val) = self.flr {
1246            if val.chars().count() < 1 {
1247                return Err(ValidationError::new(
1248                    1001,
1249                    "flr is shorter than the minimum length of 1".to_string(),
1250                ));
1251            }
1252            if val.chars().count() > 70 {
1253                return Err(ValidationError::new(
1254                    1002,
1255                    "flr exceeds the maximum length of 70".to_string(),
1256                ));
1257            }
1258            let pattern = Regex::new(
1259                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1260            )
1261            .unwrap();
1262            if !pattern.is_match(val) {
1263                return Err(ValidationError::new(
1264                    1005,
1265                    "flr does not match the required pattern".to_string(),
1266                ));
1267            }
1268        }
1269        if let Some(ref val) = self.pst_bx {
1270            if val.chars().count() < 1 {
1271                return Err(ValidationError::new(
1272                    1001,
1273                    "pst_bx is shorter than the minimum length of 1".to_string(),
1274                ));
1275            }
1276            if val.chars().count() > 16 {
1277                return Err(ValidationError::new(
1278                    1002,
1279                    "pst_bx exceeds the maximum length of 16".to_string(),
1280                ));
1281            }
1282            let pattern = Regex::new(
1283                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1284            )
1285            .unwrap();
1286            if !pattern.is_match(val) {
1287                return Err(ValidationError::new(
1288                    1005,
1289                    "pst_bx does not match the required pattern".to_string(),
1290                ));
1291            }
1292        }
1293        if let Some(ref val) = self.room {
1294            if val.chars().count() < 1 {
1295                return Err(ValidationError::new(
1296                    1001,
1297                    "room is shorter than the minimum length of 1".to_string(),
1298                ));
1299            }
1300            if val.chars().count() > 70 {
1301                return Err(ValidationError::new(
1302                    1002,
1303                    "room exceeds the maximum length of 70".to_string(),
1304                ));
1305            }
1306            let pattern = Regex::new(
1307                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1308            )
1309            .unwrap();
1310            if !pattern.is_match(val) {
1311                return Err(ValidationError::new(
1312                    1005,
1313                    "room does not match the required pattern".to_string(),
1314                ));
1315            }
1316        }
1317        if let Some(ref val) = self.pst_cd {
1318            if val.chars().count() < 1 {
1319                return Err(ValidationError::new(
1320                    1001,
1321                    "pst_cd is shorter than the minimum length of 1".to_string(),
1322                ));
1323            }
1324            if val.chars().count() > 16 {
1325                return Err(ValidationError::new(
1326                    1002,
1327                    "pst_cd exceeds the maximum length of 16".to_string(),
1328                ));
1329            }
1330            let pattern = Regex::new(
1331                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1332            )
1333            .unwrap();
1334            if !pattern.is_match(val) {
1335                return Err(ValidationError::new(
1336                    1005,
1337                    "pst_cd does not match the required pattern".to_string(),
1338                ));
1339            }
1340        }
1341        if let Some(ref val) = self.twn_nm {
1342            if val.chars().count() < 1 {
1343                return Err(ValidationError::new(
1344                    1001,
1345                    "twn_nm is shorter than the minimum length of 1".to_string(),
1346                ));
1347            }
1348            if val.chars().count() > 35 {
1349                return Err(ValidationError::new(
1350                    1002,
1351                    "twn_nm exceeds the maximum length of 35".to_string(),
1352                ));
1353            }
1354            let pattern = Regex::new(
1355                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1356            )
1357            .unwrap();
1358            if !pattern.is_match(val) {
1359                return Err(ValidationError::new(
1360                    1005,
1361                    "twn_nm does not match the required pattern".to_string(),
1362                ));
1363            }
1364        }
1365        if let Some(ref val) = self.twn_lctn_nm {
1366            if val.chars().count() < 1 {
1367                return Err(ValidationError::new(
1368                    1001,
1369                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
1370                ));
1371            }
1372            if val.chars().count() > 35 {
1373                return Err(ValidationError::new(
1374                    1002,
1375                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
1376                ));
1377            }
1378            let pattern = Regex::new(
1379                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1380            )
1381            .unwrap();
1382            if !pattern.is_match(val) {
1383                return Err(ValidationError::new(
1384                    1005,
1385                    "twn_lctn_nm does not match the required pattern".to_string(),
1386                ));
1387            }
1388        }
1389        if let Some(ref val) = self.dstrct_nm {
1390            if val.chars().count() < 1 {
1391                return Err(ValidationError::new(
1392                    1001,
1393                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
1394                ));
1395            }
1396            if val.chars().count() > 35 {
1397                return Err(ValidationError::new(
1398                    1002,
1399                    "dstrct_nm exceeds the maximum length of 35".to_string(),
1400                ));
1401            }
1402            let pattern = Regex::new(
1403                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1404            )
1405            .unwrap();
1406            if !pattern.is_match(val) {
1407                return Err(ValidationError::new(
1408                    1005,
1409                    "dstrct_nm does not match the required pattern".to_string(),
1410                ));
1411            }
1412        }
1413        if let Some(ref val) = self.ctry_sub_dvsn {
1414            if val.chars().count() < 1 {
1415                return Err(ValidationError::new(
1416                    1001,
1417                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
1418                ));
1419            }
1420            if val.chars().count() > 35 {
1421                return Err(ValidationError::new(
1422                    1002,
1423                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
1424                ));
1425            }
1426            let pattern = Regex::new(
1427                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1428            )
1429            .unwrap();
1430            if !pattern.is_match(val) {
1431                return Err(ValidationError::new(
1432                    1005,
1433                    "ctry_sub_dvsn does not match the required pattern".to_string(),
1434                ));
1435            }
1436        }
1437        if let Some(ref val) = self.ctry {
1438            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1439            if !pattern.is_match(val) {
1440                return Err(ValidationError::new(
1441                    1005,
1442                    "ctry does not match the required pattern".to_string(),
1443                ));
1444            }
1445        }
1446        if let Some(ref vec) = self.adr_line {
1447            for item in vec {
1448                if item.chars().count() < 1 {
1449                    return Err(ValidationError::new(
1450                        1001,
1451                        "adr_line is shorter than the minimum length of 1".to_string(),
1452                    ));
1453                }
1454                if item.chars().count() > 70 {
1455                    return Err(ValidationError::new(
1456                        1002,
1457                        "adr_line exceeds the maximum length of 70".to_string(),
1458                    ));
1459                }
1460                let pattern = Regex::new(
1461                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1462                )
1463                .unwrap();
1464                if !pattern.is_match(&item) {
1465                    return Err(ValidationError::new(
1466                        1005,
1467                        "adr_line does not match the required pattern".to_string(),
1468                    ));
1469                }
1470            }
1471        }
1472        Ok(())
1473    }
1474}
1475
1476// PostalAddress242: Information that locates and identifies a specific address, as defined by postal services, presented in free format text.
1477#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1478pub struct PostalAddress242 {
1479    #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1480    pub dept: Option<String>,
1481    #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1482    pub sub_dept: Option<String>,
1483    #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1484    pub strt_nm: Option<String>,
1485    #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1486    pub bldg_nb: Option<String>,
1487    #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1488    pub bldg_nm: Option<String>,
1489    #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1490    pub flr: Option<String>,
1491    #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1492    pub pst_bx: Option<String>,
1493    #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1494    pub room: Option<String>,
1495    #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1496    pub pst_cd: Option<String>,
1497    #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1498    pub twn_nm: Option<String>,
1499    #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1500    pub twn_lctn_nm: Option<String>,
1501    #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1502    pub dstrct_nm: Option<String>,
1503    #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1504    pub ctry_sub_dvsn: Option<String>,
1505    #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1506    pub ctry: Option<String>,
1507    #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1508    pub adr_line: Option<Vec<String>>,
1509}
1510
1511impl PostalAddress242 {
1512    pub fn validate(&self) -> Result<(), ValidationError> {
1513        if let Some(ref val) = self.dept {
1514            if val.chars().count() < 1 {
1515                return Err(ValidationError::new(
1516                    1001,
1517                    "dept is shorter than the minimum length of 1".to_string(),
1518                ));
1519            }
1520            if val.chars().count() > 70 {
1521                return Err(ValidationError::new(
1522                    1002,
1523                    "dept exceeds the maximum length of 70".to_string(),
1524                ));
1525            }
1526            let pattern = Regex::new(
1527                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1528            )
1529            .unwrap();
1530            if !pattern.is_match(val) {
1531                return Err(ValidationError::new(
1532                    1005,
1533                    "dept does not match the required pattern".to_string(),
1534                ));
1535            }
1536        }
1537        if let Some(ref val) = self.sub_dept {
1538            if val.chars().count() < 1 {
1539                return Err(ValidationError::new(
1540                    1001,
1541                    "sub_dept is shorter than the minimum length of 1".to_string(),
1542                ));
1543            }
1544            if val.chars().count() > 70 {
1545                return Err(ValidationError::new(
1546                    1002,
1547                    "sub_dept exceeds the maximum length of 70".to_string(),
1548                ));
1549            }
1550            let pattern = Regex::new(
1551                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1552            )
1553            .unwrap();
1554            if !pattern.is_match(val) {
1555                return Err(ValidationError::new(
1556                    1005,
1557                    "sub_dept does not match the required pattern".to_string(),
1558                ));
1559            }
1560        }
1561        if let Some(ref val) = self.strt_nm {
1562            if val.chars().count() < 1 {
1563                return Err(ValidationError::new(
1564                    1001,
1565                    "strt_nm is shorter than the minimum length of 1".to_string(),
1566                ));
1567            }
1568            if val.chars().count() > 70 {
1569                return Err(ValidationError::new(
1570                    1002,
1571                    "strt_nm exceeds the maximum length of 70".to_string(),
1572                ));
1573            }
1574            let pattern = Regex::new(
1575                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1576            )
1577            .unwrap();
1578            if !pattern.is_match(val) {
1579                return Err(ValidationError::new(
1580                    1005,
1581                    "strt_nm does not match the required pattern".to_string(),
1582                ));
1583            }
1584        }
1585        if let Some(ref val) = self.bldg_nb {
1586            if val.chars().count() < 1 {
1587                return Err(ValidationError::new(
1588                    1001,
1589                    "bldg_nb is shorter than the minimum length of 1".to_string(),
1590                ));
1591            }
1592            if val.chars().count() > 16 {
1593                return Err(ValidationError::new(
1594                    1002,
1595                    "bldg_nb exceeds the maximum length of 16".to_string(),
1596                ));
1597            }
1598            let pattern = Regex::new(
1599                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1600            )
1601            .unwrap();
1602            if !pattern.is_match(val) {
1603                return Err(ValidationError::new(
1604                    1005,
1605                    "bldg_nb does not match the required pattern".to_string(),
1606                ));
1607            }
1608        }
1609        if let Some(ref val) = self.bldg_nm {
1610            if val.chars().count() < 1 {
1611                return Err(ValidationError::new(
1612                    1001,
1613                    "bldg_nm is shorter than the minimum length of 1".to_string(),
1614                ));
1615            }
1616            if val.chars().count() > 35 {
1617                return Err(ValidationError::new(
1618                    1002,
1619                    "bldg_nm exceeds the maximum length of 35".to_string(),
1620                ));
1621            }
1622            let pattern = Regex::new(
1623                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1624            )
1625            .unwrap();
1626            if !pattern.is_match(val) {
1627                return Err(ValidationError::new(
1628                    1005,
1629                    "bldg_nm does not match the required pattern".to_string(),
1630                ));
1631            }
1632        }
1633        if let Some(ref val) = self.flr {
1634            if val.chars().count() < 1 {
1635                return Err(ValidationError::new(
1636                    1001,
1637                    "flr is shorter than the minimum length of 1".to_string(),
1638                ));
1639            }
1640            if val.chars().count() > 70 {
1641                return Err(ValidationError::new(
1642                    1002,
1643                    "flr exceeds the maximum length of 70".to_string(),
1644                ));
1645            }
1646            let pattern = Regex::new(
1647                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1648            )
1649            .unwrap();
1650            if !pattern.is_match(val) {
1651                return Err(ValidationError::new(
1652                    1005,
1653                    "flr does not match the required pattern".to_string(),
1654                ));
1655            }
1656        }
1657        if let Some(ref val) = self.pst_bx {
1658            if val.chars().count() < 1 {
1659                return Err(ValidationError::new(
1660                    1001,
1661                    "pst_bx is shorter than the minimum length of 1".to_string(),
1662                ));
1663            }
1664            if val.chars().count() > 16 {
1665                return Err(ValidationError::new(
1666                    1002,
1667                    "pst_bx exceeds the maximum length of 16".to_string(),
1668                ));
1669            }
1670            let pattern = Regex::new(
1671                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1672            )
1673            .unwrap();
1674            if !pattern.is_match(val) {
1675                return Err(ValidationError::new(
1676                    1005,
1677                    "pst_bx does not match the required pattern".to_string(),
1678                ));
1679            }
1680        }
1681        if let Some(ref val) = self.room {
1682            if val.chars().count() < 1 {
1683                return Err(ValidationError::new(
1684                    1001,
1685                    "room is shorter than the minimum length of 1".to_string(),
1686                ));
1687            }
1688            if val.chars().count() > 70 {
1689                return Err(ValidationError::new(
1690                    1002,
1691                    "room exceeds the maximum length of 70".to_string(),
1692                ));
1693            }
1694            let pattern = Regex::new(
1695                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1696            )
1697            .unwrap();
1698            if !pattern.is_match(val) {
1699                return Err(ValidationError::new(
1700                    1005,
1701                    "room does not match the required pattern".to_string(),
1702                ));
1703            }
1704        }
1705        if let Some(ref val) = self.pst_cd {
1706            if val.chars().count() < 1 {
1707                return Err(ValidationError::new(
1708                    1001,
1709                    "pst_cd is shorter than the minimum length of 1".to_string(),
1710                ));
1711            }
1712            if val.chars().count() > 16 {
1713                return Err(ValidationError::new(
1714                    1002,
1715                    "pst_cd exceeds the maximum length of 16".to_string(),
1716                ));
1717            }
1718            let pattern = Regex::new(
1719                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1720            )
1721            .unwrap();
1722            if !pattern.is_match(val) {
1723                return Err(ValidationError::new(
1724                    1005,
1725                    "pst_cd does not match the required pattern".to_string(),
1726                ));
1727            }
1728        }
1729        if let Some(ref val) = self.twn_nm {
1730            if val.chars().count() < 1 {
1731                return Err(ValidationError::new(
1732                    1001,
1733                    "twn_nm is shorter than the minimum length of 1".to_string(),
1734                ));
1735            }
1736            if val.chars().count() > 35 {
1737                return Err(ValidationError::new(
1738                    1002,
1739                    "twn_nm exceeds the maximum length of 35".to_string(),
1740                ));
1741            }
1742        }
1743        if let Some(ref val) = self.twn_lctn_nm {
1744            if val.chars().count() < 1 {
1745                return Err(ValidationError::new(
1746                    1001,
1747                    "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
1748                ));
1749            }
1750            if val.chars().count() > 35 {
1751                return Err(ValidationError::new(
1752                    1002,
1753                    "twn_lctn_nm exceeds the maximum length of 35".to_string(),
1754                ));
1755            }
1756            let pattern = Regex::new(
1757                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1758            )
1759            .unwrap();
1760            if !pattern.is_match(val) {
1761                return Err(ValidationError::new(
1762                    1005,
1763                    "twn_lctn_nm does not match the required pattern".to_string(),
1764                ));
1765            }
1766        }
1767        if let Some(ref val) = self.dstrct_nm {
1768            if val.chars().count() < 1 {
1769                return Err(ValidationError::new(
1770                    1001,
1771                    "dstrct_nm is shorter than the minimum length of 1".to_string(),
1772                ));
1773            }
1774            if val.chars().count() > 35 {
1775                return Err(ValidationError::new(
1776                    1002,
1777                    "dstrct_nm exceeds the maximum length of 35".to_string(),
1778                ));
1779            }
1780            let pattern = Regex::new(
1781                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1782            )
1783            .unwrap();
1784            if !pattern.is_match(val) {
1785                return Err(ValidationError::new(
1786                    1005,
1787                    "dstrct_nm does not match the required pattern".to_string(),
1788                ));
1789            }
1790        }
1791        if let Some(ref val) = self.ctry_sub_dvsn {
1792            if val.chars().count() < 1 {
1793                return Err(ValidationError::new(
1794                    1001,
1795                    "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
1796                ));
1797            }
1798            if val.chars().count() > 35 {
1799                return Err(ValidationError::new(
1800                    1002,
1801                    "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
1802                ));
1803            }
1804            let pattern = Regex::new(
1805                "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1806            )
1807            .unwrap();
1808            if !pattern.is_match(val) {
1809                return Err(ValidationError::new(
1810                    1005,
1811                    "ctry_sub_dvsn does not match the required pattern".to_string(),
1812                ));
1813            }
1814        }
1815        if let Some(ref val) = self.ctry {
1816            let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1817            if !pattern.is_match(val) {
1818                return Err(ValidationError::new(
1819                    1005,
1820                    "ctry does not match the required pattern".to_string(),
1821                ));
1822            }
1823        }
1824        if let Some(ref vec) = self.adr_line {
1825            for item in vec {
1826                if item.chars().count() < 1 {
1827                    return Err(ValidationError::new(
1828                        1001,
1829                        "adr_line is shorter than the minimum length of 1".to_string(),
1830                    ));
1831                }
1832                if item.chars().count() > 70 {
1833                    return Err(ValidationError::new(
1834                        1002,
1835                        "adr_line exceeds the maximum length of 70".to_string(),
1836                    ));
1837                }
1838                let pattern = Regex::new(
1839                    "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1840                )
1841                .unwrap();
1842                if !pattern.is_match(&item) {
1843                    return Err(ValidationError::new(
1844                        1005,
1845                        "adr_line does not match the required pattern".to_string(),
1846                    ));
1847                }
1848            }
1849        }
1850        Ok(())
1851    }
1852}
1853
1854// ProxyAccountIdentification11: Identification used to indicate the account identification under another specified name.
1855#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1856pub struct ProxyAccountIdentification11 {
1857    #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1858    pub tp: Option<ProxyAccountType1Choice1>,
1859    #[serde(rename = "Id")]
1860    pub id: String,
1861}
1862
1863impl ProxyAccountIdentification11 {
1864    pub fn validate(&self) -> Result<(), ValidationError> {
1865        if let Some(ref val) = self.tp {
1866            val.validate()?
1867        }
1868        if self.id.chars().count() < 1 {
1869            return Err(ValidationError::new(
1870                1001,
1871                "id is shorter than the minimum length of 1".to_string(),
1872            ));
1873        }
1874        if self.id.chars().count() > 320 {
1875            return Err(ValidationError::new(
1876                1002,
1877                "id exceeds the maximum length of 320".to_string(),
1878            ));
1879        }
1880        let pattern =
1881            Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
1882                .unwrap();
1883        if !pattern.is_match(&self.id) {
1884            return Err(ValidationError::new(
1885                1005,
1886                "id does not match the required pattern".to_string(),
1887            ));
1888        }
1889        Ok(())
1890    }
1891}
1892
1893// ProxyAccountType1Choice1: Name of the identification scheme, in a free text form.
1894#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1895pub struct ProxyAccountType1Choice1 {
1896    #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1897    pub cd: Option<String>,
1898    #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1899    pub prtry: Option<String>,
1900}
1901
1902impl ProxyAccountType1Choice1 {
1903    pub fn validate(&self) -> Result<(), ValidationError> {
1904        if let Some(ref val) = self.cd {
1905            if val.chars().count() < 1 {
1906                return Err(ValidationError::new(
1907                    1001,
1908                    "cd is shorter than the minimum length of 1".to_string(),
1909                ));
1910            }
1911            if val.chars().count() > 4 {
1912                return Err(ValidationError::new(
1913                    1002,
1914                    "cd exceeds the maximum length of 4".to_string(),
1915                ));
1916            }
1917        }
1918        if let Some(ref val) = self.prtry {
1919            if val.chars().count() < 1 {
1920                return Err(ValidationError::new(
1921                    1001,
1922                    "prtry is shorter than the minimum length of 1".to_string(),
1923                ));
1924            }
1925            if val.chars().count() > 35 {
1926                return Err(ValidationError::new(
1927                    1002,
1928                    "prtry exceeds the maximum length of 35".to_string(),
1929                ));
1930            }
1931            let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1932            if !pattern.is_match(val) {
1933                return Err(ValidationError::new(
1934                    1005,
1935                    "prtry does not match the required pattern".to_string(),
1936                ));
1937            }
1938        }
1939        Ok(())
1940    }
1941}