1use crate::error::*;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24#[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#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountReportingRequestV05 {
54 #[serde(rename = "GrpHdr")]
55 pub grp_hdr: GroupHeader771,
56 #[serde(rename = "RptgReq")]
57 pub rptg_req: Vec<ReportingRequest51>,
58}
59
60impl AccountReportingRequestV05 {
61 pub fn validate(&self) -> Result<(), ValidationError> {
62 self.grp_hdr.validate()?;
63 for item in &self.rptg_req {
64 item.validate()?
65 }
66 Ok(())
67 }
68}
69
70#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
72pub struct AccountSchemeName1Choice1 {
73 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
74 pub cd: Option<String>,
75 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
76 pub prtry: Option<String>,
77}
78
79impl AccountSchemeName1Choice1 {
80 pub fn validate(&self) -> Result<(), ValidationError> {
81 if let Some(ref val) = self.cd {
82 if val.chars().count() < 1 {
83 return Err(ValidationError::new(
84 1001,
85 "cd is shorter than the minimum length of 1".to_string(),
86 ));
87 }
88 if val.chars().count() > 4 {
89 return Err(ValidationError::new(
90 1002,
91 "cd exceeds the maximum length of 4".to_string(),
92 ));
93 }
94 }
95 if let Some(ref val) = self.prtry {
96 if val.chars().count() < 1 {
97 return Err(ValidationError::new(
98 1001,
99 "prtry is shorter than the minimum length of 1".to_string(),
100 ));
101 }
102 if val.chars().count() > 35 {
103 return Err(ValidationError::new(
104 1002,
105 "prtry exceeds the maximum length of 35".to_string(),
106 ));
107 }
108 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
109 if !pattern.is_match(val) {
110 return Err(ValidationError::new(
111 1005,
112 "prtry does not match the required pattern".to_string(),
113 ));
114 }
115 }
116 Ok(())
117 }
118}
119
120#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
122pub struct ActiveOrHistoricCurrencyAndAmount {
123 #[serde(rename = "@Ccy")]
124 pub ccy: String,
125 #[serde(rename = "$value")]
126 pub value: f64,
127}
128
129impl ActiveOrHistoricCurrencyAndAmount {
130 pub fn validate(&self) -> Result<(), ValidationError> {
131 Ok(())
132 }
133}
134
135#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
137pub enum AddressType2Code {
138 #[default]
139 #[serde(rename = "ADDR")]
140 CodeADDR,
141 #[serde(rename = "PBOX")]
142 CodePBOX,
143 #[serde(rename = "HOME")]
144 CodeHOME,
145 #[serde(rename = "BIZZ")]
146 CodeBIZZ,
147 #[serde(rename = "MLTO")]
148 CodeMLTO,
149 #[serde(rename = "DLVY")]
150 CodeDLVY,
151}
152
153impl AddressType2Code {
154 pub fn validate(&self) -> Result<(), ValidationError> {
155 Ok(())
156 }
157}
158
159#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
161pub struct AddressType3Choice1 {
162 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
163 pub cd: Option<AddressType2Code>,
164 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
165 pub prtry: Option<GenericIdentification301>,
166}
167
168impl AddressType3Choice1 {
169 pub fn validate(&self) -> Result<(), ValidationError> {
170 if let Some(ref val) = self.cd {
171 val.validate()?
172 }
173 if let Some(ref val) = self.prtry {
174 val.validate()?
175 }
176 Ok(())
177 }
178}
179
180#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
182pub struct BalanceSubType1Choice1 {
183 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
184 pub cd: Option<String>,
185 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
186 pub prtry: Option<String>,
187}
188
189impl BalanceSubType1Choice1 {
190 pub fn validate(&self) -> Result<(), ValidationError> {
191 if let Some(ref val) = self.cd {
192 if val.chars().count() < 1 {
193 return Err(ValidationError::new(
194 1001,
195 "cd is shorter than the minimum length of 1".to_string(),
196 ));
197 }
198 if val.chars().count() > 4 {
199 return Err(ValidationError::new(
200 1002,
201 "cd exceeds the maximum length of 4".to_string(),
202 ));
203 }
204 }
205 if let Some(ref val) = self.prtry {
206 if val.chars().count() < 1 {
207 return Err(ValidationError::new(
208 1001,
209 "prtry is shorter than the minimum length of 1".to_string(),
210 ));
211 }
212 if val.chars().count() > 35 {
213 return Err(ValidationError::new(
214 1002,
215 "prtry exceeds the maximum length of 35".to_string(),
216 ));
217 }
218 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
219 if !pattern.is_match(val) {
220 return Err(ValidationError::new(
221 1005,
222 "prtry does not match the required pattern".to_string(),
223 ));
224 }
225 }
226 Ok(())
227 }
228}
229
230#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
232pub struct BalanceType10Choice1 {
233 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
234 pub cd: Option<String>,
235 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
236 pub prtry: Option<String>,
237}
238
239impl BalanceType10Choice1 {
240 pub fn validate(&self) -> Result<(), ValidationError> {
241 if let Some(ref val) = self.cd {
242 if val.chars().count() < 1 {
243 return Err(ValidationError::new(
244 1001,
245 "cd is shorter than the minimum length of 1".to_string(),
246 ));
247 }
248 if val.chars().count() > 4 {
249 return Err(ValidationError::new(
250 1002,
251 "cd exceeds the maximum length of 4".to_string(),
252 ));
253 }
254 }
255 if let Some(ref val) = self.prtry {
256 if val.chars().count() < 1 {
257 return Err(ValidationError::new(
258 1001,
259 "prtry is shorter than the minimum length of 1".to_string(),
260 ));
261 }
262 if val.chars().count() > 35 {
263 return Err(ValidationError::new(
264 1002,
265 "prtry exceeds the maximum length of 35".to_string(),
266 ));
267 }
268 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
269 if !pattern.is_match(val) {
270 return Err(ValidationError::new(
271 1005,
272 "prtry does not match the required pattern".to_string(),
273 ));
274 }
275 }
276 Ok(())
277 }
278}
279
280#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
282pub struct BalanceType131 {
283 #[serde(rename = "CdOrPrtry")]
284 pub cd_or_prtry: BalanceType10Choice1,
285 #[serde(rename = "SubTp", skip_serializing_if = "Option::is_none")]
286 pub sub_tp: Option<BalanceSubType1Choice1>,
287}
288
289impl BalanceType131 {
290 pub fn validate(&self) -> Result<(), ValidationError> {
291 self.cd_or_prtry.validate()?;
292 if let Some(ref val) = self.sub_tp {
293 val.validate()?
294 }
295 Ok(())
296 }
297}
298
299#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
301pub struct BranchAndFinancialInstitutionIdentification61 {
302 #[serde(rename = "FinInstnId")]
303 pub fin_instn_id: FinancialInstitutionIdentification181,
304}
305
306impl BranchAndFinancialInstitutionIdentification61 {
307 pub fn validate(&self) -> Result<(), ValidationError> {
308 self.fin_instn_id.validate()?;
309 Ok(())
310 }
311}
312
313#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
315pub struct CashAccount381 {
316 #[serde(rename = "Id")]
317 pub id: AccountIdentification4Choice1,
318 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
319 pub tp: Option<CashAccountType2Choice1>,
320 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
321 pub ccy: Option<String>,
322 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
323 pub nm: Option<String>,
324 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
325 pub prxy: Option<ProxyAccountIdentification11>,
326}
327
328impl CashAccount381 {
329 pub fn validate(&self) -> Result<(), ValidationError> {
330 self.id.validate()?;
331 if let Some(ref val) = self.tp {
332 val.validate()?
333 }
334 if let Some(ref val) = self.ccy {
335 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
336 if !pattern.is_match(val) {
337 return Err(ValidationError::new(
338 1005,
339 "ccy does not match the required pattern".to_string(),
340 ));
341 }
342 }
343 if let Some(ref val) = self.nm {
344 if val.chars().count() < 1 {
345 return Err(ValidationError::new(
346 1001,
347 "nm is shorter than the minimum length of 1".to_string(),
348 ));
349 }
350 if val.chars().count() > 70 {
351 return Err(ValidationError::new(
352 1002,
353 "nm exceeds the maximum length of 70".to_string(),
354 ));
355 }
356 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
357 if !pattern.is_match(val) {
358 return Err(ValidationError::new(
359 1005,
360 "nm does not match the required pattern".to_string(),
361 ));
362 }
363 }
364 if let Some(ref val) = self.prxy {
365 val.validate()?
366 }
367 Ok(())
368 }
369}
370
371#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
373pub struct CashAccountType2Choice1 {
374 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
375 pub cd: Option<String>,
376 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
377 pub prtry: Option<String>,
378}
379
380impl CashAccountType2Choice1 {
381 pub fn validate(&self) -> Result<(), ValidationError> {
382 if let Some(ref val) = self.cd {
383 if val.chars().count() < 1 {
384 return Err(ValidationError::new(
385 1001,
386 "cd is shorter than the minimum length of 1".to_string(),
387 ));
388 }
389 if val.chars().count() > 4 {
390 return Err(ValidationError::new(
391 1002,
392 "cd exceeds the maximum length of 4".to_string(),
393 ));
394 }
395 }
396 if let Some(ref val) = self.prtry {
397 if val.chars().count() < 1 {
398 return Err(ValidationError::new(
399 1001,
400 "prtry is shorter than the minimum length of 1".to_string(),
401 ));
402 }
403 if val.chars().count() > 35 {
404 return Err(ValidationError::new(
405 1002,
406 "prtry exceeds the maximum length of 35".to_string(),
407 ));
408 }
409 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
410 if !pattern.is_match(val) {
411 return Err(ValidationError::new(
412 1005,
413 "prtry does not match the required pattern".to_string(),
414 ));
415 }
416 }
417 Ok(())
418 }
419}
420
421#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
423pub struct ClearingSystemIdentification2Choice1 {
424 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
425 pub cd: Option<String>,
426}
427
428impl ClearingSystemIdentification2Choice1 {
429 pub fn validate(&self) -> Result<(), ValidationError> {
430 if let Some(ref val) = self.cd {
431 if val.chars().count() < 1 {
432 return Err(ValidationError::new(
433 1001,
434 "cd is shorter than the minimum length of 1".to_string(),
435 ));
436 }
437 if val.chars().count() > 5 {
438 return Err(ValidationError::new(
439 1002,
440 "cd exceeds the maximum length of 5".to_string(),
441 ));
442 }
443 }
444 Ok(())
445 }
446}
447
448#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
450pub struct ClearingSystemMemberIdentification21 {
451 #[serde(rename = "ClrSysId")]
452 pub clr_sys_id: ClearingSystemIdentification2Choice1,
453 #[serde(rename = "MmbId")]
454 pub mmb_id: String,
455}
456
457impl ClearingSystemMemberIdentification21 {
458 pub fn validate(&self) -> Result<(), ValidationError> {
459 self.clr_sys_id.validate()?;
460 if self.mmb_id.chars().count() < 1 {
461 return Err(ValidationError::new(
462 1001,
463 "mmb_id is shorter than the minimum length of 1".to_string(),
464 ));
465 }
466 if self.mmb_id.chars().count() > 28 {
467 return Err(ValidationError::new(
468 1002,
469 "mmb_id exceeds the maximum length of 28".to_string(),
470 ));
471 }
472 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
473 if !pattern.is_match(&self.mmb_id) {
474 return Err(ValidationError::new(
475 1005,
476 "mmb_id does not match the required pattern".to_string(),
477 ));
478 }
479 Ok(())
480 }
481}
482
483#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
485pub enum CreditDebitCode {
486 #[default]
487 #[serde(rename = "CRDT")]
488 CodeCRDT,
489 #[serde(rename = "DBIT")]
490 CodeDBIT,
491}
492
493impl CreditDebitCode {
494 pub fn validate(&self) -> Result<(), ValidationError> {
495 Ok(())
496 }
497}
498
499#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
501pub struct DateAndPlaceOfBirth11 {
502 #[serde(rename = "BirthDt")]
503 pub birth_dt: String,
504 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
505 pub prvc_of_birth: Option<String>,
506 #[serde(rename = "CityOfBirth")]
507 pub city_of_birth: String,
508 #[serde(rename = "CtryOfBirth")]
509 pub ctry_of_birth: String,
510}
511
512impl DateAndPlaceOfBirth11 {
513 pub fn validate(&self) -> Result<(), ValidationError> {
514 if let Some(ref val) = self.prvc_of_birth {
515 if val.chars().count() < 1 {
516 return Err(ValidationError::new(
517 1001,
518 "prvc_of_birth is shorter than the minimum length of 1".to_string(),
519 ));
520 }
521 if val.chars().count() > 35 {
522 return Err(ValidationError::new(
523 1002,
524 "prvc_of_birth exceeds the maximum length of 35".to_string(),
525 ));
526 }
527 let pattern = Regex::new(
528 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
529 )
530 .unwrap();
531 if !pattern.is_match(val) {
532 return Err(ValidationError::new(
533 1005,
534 "prvc_of_birth does not match the required pattern".to_string(),
535 ));
536 }
537 }
538 if self.city_of_birth.chars().count() < 1 {
539 return Err(ValidationError::new(
540 1001,
541 "city_of_birth is shorter than the minimum length of 1".to_string(),
542 ));
543 }
544 if self.city_of_birth.chars().count() > 35 {
545 return Err(ValidationError::new(
546 1002,
547 "city_of_birth exceeds the maximum length of 35".to_string(),
548 ));
549 }
550 let pattern =
551 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
552 .unwrap();
553 if !pattern.is_match(&self.city_of_birth) {
554 return Err(ValidationError::new(
555 1005,
556 "city_of_birth does not match the required pattern".to_string(),
557 ));
558 }
559 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
560 if !pattern.is_match(&self.ctry_of_birth) {
561 return Err(ValidationError::new(
562 1005,
563 "ctry_of_birth does not match the required pattern".to_string(),
564 ));
565 }
566 Ok(())
567 }
568}
569
570#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
572pub struct DatePeriodDetails1 {
573 #[serde(rename = "FrDt")]
574 pub fr_dt: String,
575 #[serde(rename = "ToDt", skip_serializing_if = "Option::is_none")]
576 pub to_dt: Option<String>,
577}
578
579impl DatePeriodDetails1 {
580 pub fn validate(&self) -> Result<(), ValidationError> {
581 Ok(())
582 }
583}
584
585#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
587pub struct EntryStatus1Choice1 {
588 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
589 pub cd: Option<String>,
590 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
591 pub prtry: Option<String>,
592}
593
594impl EntryStatus1Choice1 {
595 pub fn validate(&self) -> Result<(), ValidationError> {
596 if let Some(ref val) = self.cd {
597 if val.chars().count() < 1 {
598 return Err(ValidationError::new(
599 1001,
600 "cd is shorter than the minimum length of 1".to_string(),
601 ));
602 }
603 if val.chars().count() > 4 {
604 return Err(ValidationError::new(
605 1002,
606 "cd exceeds the maximum length of 4".to_string(),
607 ));
608 }
609 }
610 if let Some(ref val) = self.prtry {
611 if val.chars().count() < 1 {
612 return Err(ValidationError::new(
613 1001,
614 "prtry is shorter than the minimum length of 1".to_string(),
615 ));
616 }
617 if val.chars().count() > 35 {
618 return Err(ValidationError::new(
619 1002,
620 "prtry exceeds the maximum length of 35".to_string(),
621 ));
622 }
623 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
624 if !pattern.is_match(val) {
625 return Err(ValidationError::new(
626 1005,
627 "prtry does not match the required pattern".to_string(),
628 ));
629 }
630 }
631 Ok(())
632 }
633}
634
635#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
637pub struct FinancialInstitutionIdentification181 {
638 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
639 pub bicfi: Option<String>,
640 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
641 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
642 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
643 pub lei: Option<String>,
644 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
645 pub nm: Option<String>,
646 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
647 pub pstl_adr: Option<PostalAddress242>,
648}
649
650impl FinancialInstitutionIdentification181 {
651 pub fn validate(&self) -> Result<(), ValidationError> {
652 if let Some(ref val) = self.bicfi {
653 let pattern =
654 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
655 if !pattern.is_match(val) {
656 return Err(ValidationError::new(
657 1005,
658 "bicfi does not match the required pattern".to_string(),
659 ));
660 }
661 }
662 if let Some(ref val) = self.clr_sys_mmb_id {
663 val.validate()?
664 }
665 if let Some(ref val) = self.lei {
666 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
667 if !pattern.is_match(val) {
668 return Err(ValidationError::new(
669 1005,
670 "lei does not match the required pattern".to_string(),
671 ));
672 }
673 }
674 if let Some(ref val) = self.nm {
675 if val.chars().count() < 1 {
676 return Err(ValidationError::new(
677 1001,
678 "nm is shorter than the minimum length of 1".to_string(),
679 ));
680 }
681 if val.chars().count() > 140 {
682 return Err(ValidationError::new(
683 1002,
684 "nm exceeds the maximum length of 140".to_string(),
685 ));
686 }
687 let pattern = Regex::new(
688 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
689 )
690 .unwrap();
691 if !pattern.is_match(val) {
692 return Err(ValidationError::new(
693 1005,
694 "nm does not match the required pattern".to_string(),
695 ));
696 }
697 }
698 if let Some(ref val) = self.pstl_adr {
699 val.validate()?
700 }
701 Ok(())
702 }
703}
704
705#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
707pub enum FloorLimitType1Code {
708 #[default]
709 #[serde(rename = "CRED")]
710 CodeCRED,
711 #[serde(rename = "DEBT")]
712 CodeDEBT,
713 #[serde(rename = "BOTH")]
714 CodeBOTH,
715}
716
717impl FloorLimitType1Code {
718 pub fn validate(&self) -> Result<(), ValidationError> {
719 Ok(())
720 }
721}
722
723#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
725pub struct GenericAccountIdentification11 {
726 #[serde(rename = "Id")]
727 pub id: String,
728 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
729 pub schme_nm: Option<AccountSchemeName1Choice1>,
730 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
731 pub issr: Option<String>,
732}
733
734impl GenericAccountIdentification11 {
735 pub fn validate(&self) -> Result<(), ValidationError> {
736 if self.id.chars().count() < 1 {
737 return Err(ValidationError::new(
738 1001,
739 "id is shorter than the minimum length of 1".to_string(),
740 ));
741 }
742 if self.id.chars().count() > 34 {
743 return Err(ValidationError::new(
744 1002,
745 "id exceeds the maximum length of 34".to_string(),
746 ));
747 }
748 let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
749 if !pattern.is_match(&self.id) {
750 return Err(ValidationError::new(
751 1005,
752 "id does not match the required pattern".to_string(),
753 ));
754 }
755 if let Some(ref val) = self.schme_nm {
756 val.validate()?
757 }
758 if let Some(ref val) = self.issr {
759 if val.chars().count() < 1 {
760 return Err(ValidationError::new(
761 1001,
762 "issr is shorter than the minimum length of 1".to_string(),
763 ));
764 }
765 if val.chars().count() > 35 {
766 return Err(ValidationError::new(
767 1002,
768 "issr exceeds the maximum length of 35".to_string(),
769 ));
770 }
771 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
772 if !pattern.is_match(val) {
773 return Err(ValidationError::new(
774 1005,
775 "issr does not match the required pattern".to_string(),
776 ));
777 }
778 }
779 Ok(())
780 }
781}
782
783#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
785pub struct GenericIdentification301 {
786 #[serde(rename = "Id")]
787 pub id: String,
788 #[serde(rename = "Issr")]
789 pub issr: String,
790 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
791 pub schme_nm: Option<String>,
792}
793
794impl GenericIdentification301 {
795 pub fn validate(&self) -> Result<(), ValidationError> {
796 let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
797 if !pattern.is_match(&self.id) {
798 return Err(ValidationError::new(
799 1005,
800 "id does not match the required pattern".to_string(),
801 ));
802 }
803 if self.issr.chars().count() < 1 {
804 return Err(ValidationError::new(
805 1001,
806 "issr is shorter than the minimum length of 1".to_string(),
807 ));
808 }
809 if self.issr.chars().count() > 35 {
810 return Err(ValidationError::new(
811 1002,
812 "issr exceeds the maximum length of 35".to_string(),
813 ));
814 }
815 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
816 if !pattern.is_match(&self.issr) {
817 return Err(ValidationError::new(
818 1005,
819 "issr does not match the required pattern".to_string(),
820 ));
821 }
822 if let Some(ref val) = self.schme_nm {
823 if val.chars().count() < 1 {
824 return Err(ValidationError::new(
825 1001,
826 "schme_nm is shorter than the minimum length of 1".to_string(),
827 ));
828 }
829 if val.chars().count() > 35 {
830 return Err(ValidationError::new(
831 1002,
832 "schme_nm exceeds the maximum length of 35".to_string(),
833 ));
834 }
835 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
836 if !pattern.is_match(val) {
837 return Err(ValidationError::new(
838 1005,
839 "schme_nm does not match the required pattern".to_string(),
840 ));
841 }
842 }
843 Ok(())
844 }
845}
846
847#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
849pub struct GenericOrganisationIdentification11 {
850 #[serde(rename = "Id")]
851 pub id: String,
852 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
853 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
854 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
855 pub issr: Option<String>,
856}
857
858impl GenericOrganisationIdentification11 {
859 pub fn validate(&self) -> Result<(), ValidationError> {
860 if self.id.chars().count() < 1 {
861 return Err(ValidationError::new(
862 1001,
863 "id is shorter than the minimum length of 1".to_string(),
864 ));
865 }
866 if self.id.chars().count() > 35 {
867 return Err(ValidationError::new(
868 1002,
869 "id exceeds the maximum length of 35".to_string(),
870 ));
871 }
872 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
873 if !pattern.is_match(&self.id) {
874 return Err(ValidationError::new(
875 1005,
876 "id does not match the required pattern".to_string(),
877 ));
878 }
879 if let Some(ref val) = self.schme_nm {
880 val.validate()?
881 }
882 if let Some(ref val) = self.issr {
883 if val.chars().count() < 1 {
884 return Err(ValidationError::new(
885 1001,
886 "issr is shorter than the minimum length of 1".to_string(),
887 ));
888 }
889 if val.chars().count() > 35 {
890 return Err(ValidationError::new(
891 1002,
892 "issr exceeds the maximum length of 35".to_string(),
893 ));
894 }
895 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
896 if !pattern.is_match(val) {
897 return Err(ValidationError::new(
898 1005,
899 "issr does not match the required pattern".to_string(),
900 ));
901 }
902 }
903 Ok(())
904 }
905}
906
907#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
909pub struct GenericPersonIdentification11 {
910 #[serde(rename = "Id")]
911 pub id: String,
912 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
913 pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
914 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
915 pub issr: Option<String>,
916}
917
918impl GenericPersonIdentification11 {
919 pub fn validate(&self) -> Result<(), ValidationError> {
920 if self.id.chars().count() < 1 {
921 return Err(ValidationError::new(
922 1001,
923 "id is shorter than the minimum length of 1".to_string(),
924 ));
925 }
926 if self.id.chars().count() > 35 {
927 return Err(ValidationError::new(
928 1002,
929 "id exceeds the maximum length of 35".to_string(),
930 ));
931 }
932 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
933 if !pattern.is_match(&self.id) {
934 return Err(ValidationError::new(
935 1005,
936 "id does not match the required pattern".to_string(),
937 ));
938 }
939 if let Some(ref val) = self.schme_nm {
940 val.validate()?
941 }
942 if let Some(ref val) = self.issr {
943 if val.chars().count() < 1 {
944 return Err(ValidationError::new(
945 1001,
946 "issr is shorter than the minimum length of 1".to_string(),
947 ));
948 }
949 if val.chars().count() > 35 {
950 return Err(ValidationError::new(
951 1002,
952 "issr exceeds the maximum length of 35".to_string(),
953 ));
954 }
955 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
956 if !pattern.is_match(val) {
957 return Err(ValidationError::new(
958 1005,
959 "issr does not match the required pattern".to_string(),
960 ));
961 }
962 }
963 Ok(())
964 }
965}
966
967#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
969pub struct GroupHeader771 {
970 #[serde(rename = "MsgId")]
971 pub msg_id: String,
972 #[serde(rename = "CreDtTm")]
973 pub cre_dt_tm: String,
974 #[serde(rename = "MsgSndr", skip_serializing_if = "Option::is_none")]
975 pub msg_sndr: Option<Party40Choice1>,
976}
977
978impl GroupHeader771 {
979 pub fn validate(&self) -> Result<(), ValidationError> {
980 if self.msg_id.chars().count() < 1 {
981 return Err(ValidationError::new(
982 1001,
983 "msg_id is shorter than the minimum length of 1".to_string(),
984 ));
985 }
986 if self.msg_id.chars().count() > 35 {
987 return Err(ValidationError::new(
988 1002,
989 "msg_id exceeds the maximum length of 35".to_string(),
990 ));
991 }
992 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
993 if !pattern.is_match(&self.msg_id) {
994 return Err(ValidationError::new(
995 1005,
996 "msg_id does not match the required pattern".to_string(),
997 ));
998 }
999 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
1000 if !pattern.is_match(&self.cre_dt_tm) {
1001 return Err(ValidationError::new(
1002 1005,
1003 "cre_dt_tm does not match the required pattern".to_string(),
1004 ));
1005 }
1006 if let Some(ref val) = self.msg_sndr {
1007 val.validate()?
1008 }
1009 Ok(())
1010 }
1011}
1012
1013#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1015pub struct Limit2 {
1016 #[serde(rename = "Amt")]
1017 pub amt: ActiveOrHistoricCurrencyAndAmount,
1018 #[serde(rename = "CdtDbtInd")]
1019 pub cdt_dbt_ind: FloorLimitType1Code,
1020}
1021
1022impl Limit2 {
1023 pub fn validate(&self) -> Result<(), ValidationError> {
1024 self.amt.validate()?;
1025 self.cdt_dbt_ind.validate()?;
1026 Ok(())
1027 }
1028}
1029
1030#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1032pub struct OrganisationIdentification291 {
1033 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
1034 pub any_bic: Option<String>,
1035 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1036 pub lei: Option<String>,
1037 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1038 pub othr: Option<Vec<GenericOrganisationIdentification11>>,
1039}
1040
1041impl OrganisationIdentification291 {
1042 pub fn validate(&self) -> Result<(), ValidationError> {
1043 if let Some(ref val) = self.any_bic {
1044 let pattern =
1045 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1046 if !pattern.is_match(val) {
1047 return Err(ValidationError::new(
1048 1005,
1049 "any_bic does not match the required pattern".to_string(),
1050 ));
1051 }
1052 }
1053 if let Some(ref val) = self.lei {
1054 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1055 if !pattern.is_match(val) {
1056 return Err(ValidationError::new(
1057 1005,
1058 "lei does not match the required pattern".to_string(),
1059 ));
1060 }
1061 }
1062 if let Some(ref vec) = self.othr {
1063 for item in vec {
1064 item.validate()?
1065 }
1066 }
1067 Ok(())
1068 }
1069}
1070
1071#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1073pub struct OrganisationIdentificationSchemeName1Choice1 {
1074 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1075 pub cd: Option<String>,
1076 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1077 pub prtry: Option<String>,
1078}
1079
1080impl OrganisationIdentificationSchemeName1Choice1 {
1081 pub fn validate(&self) -> Result<(), ValidationError> {
1082 if let Some(ref val) = self.cd {
1083 if val.chars().count() < 1 {
1084 return Err(ValidationError::new(
1085 1001,
1086 "cd is shorter than the minimum length of 1".to_string(),
1087 ));
1088 }
1089 if val.chars().count() > 4 {
1090 return Err(ValidationError::new(
1091 1002,
1092 "cd exceeds the maximum length of 4".to_string(),
1093 ));
1094 }
1095 }
1096 if let Some(ref val) = self.prtry {
1097 if val.chars().count() < 1 {
1098 return Err(ValidationError::new(
1099 1001,
1100 "prtry is shorter than the minimum length of 1".to_string(),
1101 ));
1102 }
1103 if val.chars().count() > 35 {
1104 return Err(ValidationError::new(
1105 1002,
1106 "prtry exceeds the maximum length of 35".to_string(),
1107 ));
1108 }
1109 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1110 if !pattern.is_match(val) {
1111 return Err(ValidationError::new(
1112 1005,
1113 "prtry does not match the required pattern".to_string(),
1114 ));
1115 }
1116 }
1117 Ok(())
1118 }
1119}
1120
1121#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1123pub struct Party38Choice1 {
1124 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
1125 pub org_id: Option<OrganisationIdentification291>,
1126 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
1127 pub prvt_id: Option<PersonIdentification131>,
1128}
1129
1130impl Party38Choice1 {
1131 pub fn validate(&self) -> Result<(), ValidationError> {
1132 if let Some(ref val) = self.org_id {
1133 val.validate()?
1134 }
1135 if let Some(ref val) = self.prvt_id {
1136 val.validate()?
1137 }
1138 Ok(())
1139 }
1140}
1141
1142#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1144pub struct Party40Choice1 {
1145 #[serde(rename = "Pty", skip_serializing_if = "Option::is_none")]
1146 pub pty: Option<PartyIdentification1351>,
1147 #[serde(rename = "Agt", skip_serializing_if = "Option::is_none")]
1148 pub agt: Option<BranchAndFinancialInstitutionIdentification61>,
1149}
1150
1151impl Party40Choice1 {
1152 pub fn validate(&self) -> Result<(), ValidationError> {
1153 if let Some(ref val) = self.pty {
1154 val.validate()?
1155 }
1156 if let Some(ref val) = self.agt {
1157 val.validate()?
1158 }
1159 Ok(())
1160 }
1161}
1162
1163#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1165pub struct PartyIdentification1351 {
1166 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1167 pub nm: Option<String>,
1168 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1169 pub pstl_adr: Option<PostalAddress241>,
1170 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1171 pub id: Option<Party38Choice1>,
1172 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
1173 pub ctry_of_res: Option<String>,
1174}
1175
1176impl PartyIdentification1351 {
1177 pub fn validate(&self) -> Result<(), ValidationError> {
1178 if let Some(ref val) = self.nm {
1179 if val.chars().count() < 1 {
1180 return Err(ValidationError::new(
1181 1001,
1182 "nm is shorter than the minimum length of 1".to_string(),
1183 ));
1184 }
1185 if val.chars().count() > 140 {
1186 return Err(ValidationError::new(
1187 1002,
1188 "nm exceeds the maximum length of 140".to_string(),
1189 ));
1190 }
1191 let pattern = Regex::new(
1192 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1193 )
1194 .unwrap();
1195 if !pattern.is_match(val) {
1196 return Err(ValidationError::new(
1197 1005,
1198 "nm does not match the required pattern".to_string(),
1199 ));
1200 }
1201 }
1202 if let Some(ref val) = self.pstl_adr {
1203 val.validate()?
1204 }
1205 if let Some(ref val) = self.id {
1206 val.validate()?
1207 }
1208 if let Some(ref val) = self.ctry_of_res {
1209 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1210 if !pattern.is_match(val) {
1211 return Err(ValidationError::new(
1212 1005,
1213 "ctry_of_res does not match the required pattern".to_string(),
1214 ));
1215 }
1216 }
1217 Ok(())
1218 }
1219}
1220
1221#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1223pub struct PersonIdentification131 {
1224 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
1225 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
1226 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1227 pub othr: Option<Vec<GenericPersonIdentification11>>,
1228}
1229
1230impl PersonIdentification131 {
1231 pub fn validate(&self) -> Result<(), ValidationError> {
1232 if let Some(ref val) = self.dt_and_plc_of_birth {
1233 val.validate()?
1234 }
1235 if let Some(ref vec) = self.othr {
1236 for item in vec {
1237 item.validate()?
1238 }
1239 }
1240 Ok(())
1241 }
1242}
1243
1244#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1246pub struct PersonIdentificationSchemeName1Choice1 {
1247 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1248 pub cd: Option<String>,
1249 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1250 pub prtry: Option<String>,
1251}
1252
1253impl PersonIdentificationSchemeName1Choice1 {
1254 pub fn validate(&self) -> Result<(), ValidationError> {
1255 if let Some(ref val) = self.cd {
1256 if val.chars().count() < 1 {
1257 return Err(ValidationError::new(
1258 1001,
1259 "cd is shorter than the minimum length of 1".to_string(),
1260 ));
1261 }
1262 if val.chars().count() > 4 {
1263 return Err(ValidationError::new(
1264 1002,
1265 "cd exceeds the maximum length of 4".to_string(),
1266 ));
1267 }
1268 }
1269 if let Some(ref val) = self.prtry {
1270 if val.chars().count() < 1 {
1271 return Err(ValidationError::new(
1272 1001,
1273 "prtry is shorter than the minimum length of 1".to_string(),
1274 ));
1275 }
1276 if val.chars().count() > 35 {
1277 return Err(ValidationError::new(
1278 1002,
1279 "prtry exceeds the maximum length of 35".to_string(),
1280 ));
1281 }
1282 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1283 if !pattern.is_match(val) {
1284 return Err(ValidationError::new(
1285 1005,
1286 "prtry does not match the required pattern".to_string(),
1287 ));
1288 }
1289 }
1290 Ok(())
1291 }
1292}
1293
1294#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1296pub struct PostalAddress241 {
1297 #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
1298 pub adr_tp: Option<AddressType3Choice1>,
1299 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1300 pub dept: Option<String>,
1301 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1302 pub sub_dept: Option<String>,
1303 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1304 pub strt_nm: Option<String>,
1305 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1306 pub bldg_nb: Option<String>,
1307 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1308 pub bldg_nm: Option<String>,
1309 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1310 pub flr: Option<String>,
1311 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1312 pub pst_bx: Option<String>,
1313 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1314 pub room: Option<String>,
1315 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1316 pub pst_cd: Option<String>,
1317 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1318 pub twn_nm: Option<String>,
1319 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1320 pub twn_lctn_nm: Option<String>,
1321 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1322 pub dstrct_nm: Option<String>,
1323 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1324 pub ctry_sub_dvsn: Option<String>,
1325 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1326 pub ctry: Option<String>,
1327 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1328 pub adr_line: Option<Vec<String>>,
1329}
1330
1331impl PostalAddress241 {
1332 pub fn validate(&self) -> Result<(), ValidationError> {
1333 if let Some(ref val) = self.adr_tp {
1334 val.validate()?
1335 }
1336 if let Some(ref val) = self.dept {
1337 if val.chars().count() < 1 {
1338 return Err(ValidationError::new(
1339 1001,
1340 "dept is shorter than the minimum length of 1".to_string(),
1341 ));
1342 }
1343 if val.chars().count() > 70 {
1344 return Err(ValidationError::new(
1345 1002,
1346 "dept exceeds the maximum length of 70".to_string(),
1347 ));
1348 }
1349 let pattern = Regex::new(
1350 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1351 )
1352 .unwrap();
1353 if !pattern.is_match(val) {
1354 return Err(ValidationError::new(
1355 1005,
1356 "dept does not match the required pattern".to_string(),
1357 ));
1358 }
1359 }
1360 if let Some(ref val) = self.sub_dept {
1361 if val.chars().count() < 1 {
1362 return Err(ValidationError::new(
1363 1001,
1364 "sub_dept is shorter than the minimum length of 1".to_string(),
1365 ));
1366 }
1367 if val.chars().count() > 70 {
1368 return Err(ValidationError::new(
1369 1002,
1370 "sub_dept exceeds the maximum length of 70".to_string(),
1371 ));
1372 }
1373 let pattern = Regex::new(
1374 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1375 )
1376 .unwrap();
1377 if !pattern.is_match(val) {
1378 return Err(ValidationError::new(
1379 1005,
1380 "sub_dept does not match the required pattern".to_string(),
1381 ));
1382 }
1383 }
1384 if let Some(ref val) = self.strt_nm {
1385 if val.chars().count() < 1 {
1386 return Err(ValidationError::new(
1387 1001,
1388 "strt_nm is shorter than the minimum length of 1".to_string(),
1389 ));
1390 }
1391 if val.chars().count() > 70 {
1392 return Err(ValidationError::new(
1393 1002,
1394 "strt_nm exceeds the maximum length of 70".to_string(),
1395 ));
1396 }
1397 let pattern = Regex::new(
1398 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1399 )
1400 .unwrap();
1401 if !pattern.is_match(val) {
1402 return Err(ValidationError::new(
1403 1005,
1404 "strt_nm does not match the required pattern".to_string(),
1405 ));
1406 }
1407 }
1408 if let Some(ref val) = self.bldg_nb {
1409 if val.chars().count() < 1 {
1410 return Err(ValidationError::new(
1411 1001,
1412 "bldg_nb is shorter than the minimum length of 1".to_string(),
1413 ));
1414 }
1415 if val.chars().count() > 16 {
1416 return Err(ValidationError::new(
1417 1002,
1418 "bldg_nb exceeds the maximum length of 16".to_string(),
1419 ));
1420 }
1421 let pattern = Regex::new(
1422 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1423 )
1424 .unwrap();
1425 if !pattern.is_match(val) {
1426 return Err(ValidationError::new(
1427 1005,
1428 "bldg_nb does not match the required pattern".to_string(),
1429 ));
1430 }
1431 }
1432 if let Some(ref val) = self.bldg_nm {
1433 if val.chars().count() < 1 {
1434 return Err(ValidationError::new(
1435 1001,
1436 "bldg_nm is shorter than the minimum length of 1".to_string(),
1437 ));
1438 }
1439 if val.chars().count() > 35 {
1440 return Err(ValidationError::new(
1441 1002,
1442 "bldg_nm exceeds the maximum length of 35".to_string(),
1443 ));
1444 }
1445 let pattern = Regex::new(
1446 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1447 )
1448 .unwrap();
1449 if !pattern.is_match(val) {
1450 return Err(ValidationError::new(
1451 1005,
1452 "bldg_nm does not match the required pattern".to_string(),
1453 ));
1454 }
1455 }
1456 if let Some(ref val) = self.flr {
1457 if val.chars().count() < 1 {
1458 return Err(ValidationError::new(
1459 1001,
1460 "flr is shorter than the minimum length of 1".to_string(),
1461 ));
1462 }
1463 if val.chars().count() > 70 {
1464 return Err(ValidationError::new(
1465 1002,
1466 "flr exceeds the maximum length of 70".to_string(),
1467 ));
1468 }
1469 let pattern = Regex::new(
1470 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1471 )
1472 .unwrap();
1473 if !pattern.is_match(val) {
1474 return Err(ValidationError::new(
1475 1005,
1476 "flr does not match the required pattern".to_string(),
1477 ));
1478 }
1479 }
1480 if let Some(ref val) = self.pst_bx {
1481 if val.chars().count() < 1 {
1482 return Err(ValidationError::new(
1483 1001,
1484 "pst_bx is shorter than the minimum length of 1".to_string(),
1485 ));
1486 }
1487 if val.chars().count() > 16 {
1488 return Err(ValidationError::new(
1489 1002,
1490 "pst_bx exceeds the maximum length of 16".to_string(),
1491 ));
1492 }
1493 let pattern = Regex::new(
1494 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1495 )
1496 .unwrap();
1497 if !pattern.is_match(val) {
1498 return Err(ValidationError::new(
1499 1005,
1500 "pst_bx does not match the required pattern".to_string(),
1501 ));
1502 }
1503 }
1504 if let Some(ref val) = self.room {
1505 if val.chars().count() < 1 {
1506 return Err(ValidationError::new(
1507 1001,
1508 "room is shorter than the minimum length of 1".to_string(),
1509 ));
1510 }
1511 if val.chars().count() > 70 {
1512 return Err(ValidationError::new(
1513 1002,
1514 "room exceeds the maximum length of 70".to_string(),
1515 ));
1516 }
1517 let pattern = Regex::new(
1518 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1519 )
1520 .unwrap();
1521 if !pattern.is_match(val) {
1522 return Err(ValidationError::new(
1523 1005,
1524 "room does not match the required pattern".to_string(),
1525 ));
1526 }
1527 }
1528 if let Some(ref val) = self.pst_cd {
1529 if val.chars().count() < 1 {
1530 return Err(ValidationError::new(
1531 1001,
1532 "pst_cd is shorter than the minimum length of 1".to_string(),
1533 ));
1534 }
1535 if val.chars().count() > 16 {
1536 return Err(ValidationError::new(
1537 1002,
1538 "pst_cd exceeds the maximum length of 16".to_string(),
1539 ));
1540 }
1541 let pattern = Regex::new(
1542 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1543 )
1544 .unwrap();
1545 if !pattern.is_match(val) {
1546 return Err(ValidationError::new(
1547 1005,
1548 "pst_cd does not match the required pattern".to_string(),
1549 ));
1550 }
1551 }
1552 if let Some(ref val) = self.twn_nm {
1553 if val.chars().count() < 1 {
1554 return Err(ValidationError::new(
1555 1001,
1556 "twn_nm is shorter than the minimum length of 1".to_string(),
1557 ));
1558 }
1559 if val.chars().count() > 35 {
1560 return Err(ValidationError::new(
1561 1002,
1562 "twn_nm exceeds the maximum length of 35".to_string(),
1563 ));
1564 }
1565 let pattern = Regex::new(
1566 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1567 )
1568 .unwrap();
1569 if !pattern.is_match(val) {
1570 return Err(ValidationError::new(
1571 1005,
1572 "twn_nm does not match the required pattern".to_string(),
1573 ));
1574 }
1575 }
1576 if let Some(ref val) = self.twn_lctn_nm {
1577 if val.chars().count() < 1 {
1578 return Err(ValidationError::new(
1579 1001,
1580 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
1581 ));
1582 }
1583 if val.chars().count() > 35 {
1584 return Err(ValidationError::new(
1585 1002,
1586 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
1587 ));
1588 }
1589 let pattern = Regex::new(
1590 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1591 )
1592 .unwrap();
1593 if !pattern.is_match(val) {
1594 return Err(ValidationError::new(
1595 1005,
1596 "twn_lctn_nm does not match the required pattern".to_string(),
1597 ));
1598 }
1599 }
1600 if let Some(ref val) = self.dstrct_nm {
1601 if val.chars().count() < 1 {
1602 return Err(ValidationError::new(
1603 1001,
1604 "dstrct_nm is shorter than the minimum length of 1".to_string(),
1605 ));
1606 }
1607 if val.chars().count() > 35 {
1608 return Err(ValidationError::new(
1609 1002,
1610 "dstrct_nm exceeds the maximum length of 35".to_string(),
1611 ));
1612 }
1613 let pattern = Regex::new(
1614 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1615 )
1616 .unwrap();
1617 if !pattern.is_match(val) {
1618 return Err(ValidationError::new(
1619 1005,
1620 "dstrct_nm does not match the required pattern".to_string(),
1621 ));
1622 }
1623 }
1624 if let Some(ref val) = self.ctry_sub_dvsn {
1625 if val.chars().count() < 1 {
1626 return Err(ValidationError::new(
1627 1001,
1628 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
1629 ));
1630 }
1631 if val.chars().count() > 35 {
1632 return Err(ValidationError::new(
1633 1002,
1634 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
1635 ));
1636 }
1637 let pattern = Regex::new(
1638 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1639 )
1640 .unwrap();
1641 if !pattern.is_match(val) {
1642 return Err(ValidationError::new(
1643 1005,
1644 "ctry_sub_dvsn does not match the required pattern".to_string(),
1645 ));
1646 }
1647 }
1648 if let Some(ref val) = self.ctry {
1649 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1650 if !pattern.is_match(val) {
1651 return Err(ValidationError::new(
1652 1005,
1653 "ctry does not match the required pattern".to_string(),
1654 ));
1655 }
1656 }
1657 if let Some(ref vec) = self.adr_line {
1658 for item in vec {
1659 if item.chars().count() < 1 {
1660 return Err(ValidationError::new(
1661 1001,
1662 "adr_line is shorter than the minimum length of 1".to_string(),
1663 ));
1664 }
1665 if item.chars().count() > 70 {
1666 return Err(ValidationError::new(
1667 1002,
1668 "adr_line exceeds the maximum length of 70".to_string(),
1669 ));
1670 }
1671 let pattern = Regex::new(
1672 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1673 )
1674 .unwrap();
1675 if !pattern.is_match(&item) {
1676 return Err(ValidationError::new(
1677 1005,
1678 "adr_line does not match the required pattern".to_string(),
1679 ));
1680 }
1681 }
1682 }
1683 Ok(())
1684 }
1685}
1686
1687#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1689pub struct PostalAddress242 {
1690 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1691 pub dept: Option<String>,
1692 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1693 pub sub_dept: Option<String>,
1694 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1695 pub strt_nm: Option<String>,
1696 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1697 pub bldg_nb: Option<String>,
1698 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1699 pub bldg_nm: Option<String>,
1700 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1701 pub flr: Option<String>,
1702 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1703 pub pst_bx: Option<String>,
1704 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1705 pub room: Option<String>,
1706 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1707 pub pst_cd: Option<String>,
1708 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1709 pub twn_nm: Option<String>,
1710 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1711 pub twn_lctn_nm: Option<String>,
1712 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1713 pub dstrct_nm: Option<String>,
1714 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1715 pub ctry_sub_dvsn: Option<String>,
1716 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1717 pub ctry: Option<String>,
1718 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1719 pub adr_line: Option<Vec<String>>,
1720}
1721
1722impl PostalAddress242 {
1723 pub fn validate(&self) -> Result<(), ValidationError> {
1724 if let Some(ref val) = self.dept {
1725 if val.chars().count() < 1 {
1726 return Err(ValidationError::new(
1727 1001,
1728 "dept is shorter than the minimum length of 1".to_string(),
1729 ));
1730 }
1731 if val.chars().count() > 70 {
1732 return Err(ValidationError::new(
1733 1002,
1734 "dept exceeds the maximum length of 70".to_string(),
1735 ));
1736 }
1737 let pattern = Regex::new(
1738 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1739 )
1740 .unwrap();
1741 if !pattern.is_match(val) {
1742 return Err(ValidationError::new(
1743 1005,
1744 "dept does not match the required pattern".to_string(),
1745 ));
1746 }
1747 }
1748 if let Some(ref val) = self.sub_dept {
1749 if val.chars().count() < 1 {
1750 return Err(ValidationError::new(
1751 1001,
1752 "sub_dept is shorter than the minimum length of 1".to_string(),
1753 ));
1754 }
1755 if val.chars().count() > 70 {
1756 return Err(ValidationError::new(
1757 1002,
1758 "sub_dept exceeds the maximum length of 70".to_string(),
1759 ));
1760 }
1761 let pattern = Regex::new(
1762 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1763 )
1764 .unwrap();
1765 if !pattern.is_match(val) {
1766 return Err(ValidationError::new(
1767 1005,
1768 "sub_dept does not match the required pattern".to_string(),
1769 ));
1770 }
1771 }
1772 if let Some(ref val) = self.strt_nm {
1773 if val.chars().count() < 1 {
1774 return Err(ValidationError::new(
1775 1001,
1776 "strt_nm is shorter than the minimum length of 1".to_string(),
1777 ));
1778 }
1779 if val.chars().count() > 70 {
1780 return Err(ValidationError::new(
1781 1002,
1782 "strt_nm exceeds the maximum length of 70".to_string(),
1783 ));
1784 }
1785 let pattern = Regex::new(
1786 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1787 )
1788 .unwrap();
1789 if !pattern.is_match(val) {
1790 return Err(ValidationError::new(
1791 1005,
1792 "strt_nm does not match the required pattern".to_string(),
1793 ));
1794 }
1795 }
1796 if let Some(ref val) = self.bldg_nb {
1797 if val.chars().count() < 1 {
1798 return Err(ValidationError::new(
1799 1001,
1800 "bldg_nb is shorter than the minimum length of 1".to_string(),
1801 ));
1802 }
1803 if val.chars().count() > 16 {
1804 return Err(ValidationError::new(
1805 1002,
1806 "bldg_nb exceeds the maximum length of 16".to_string(),
1807 ));
1808 }
1809 let pattern = Regex::new(
1810 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1811 )
1812 .unwrap();
1813 if !pattern.is_match(val) {
1814 return Err(ValidationError::new(
1815 1005,
1816 "bldg_nb does not match the required pattern".to_string(),
1817 ));
1818 }
1819 }
1820 if let Some(ref val) = self.bldg_nm {
1821 if val.chars().count() < 1 {
1822 return Err(ValidationError::new(
1823 1001,
1824 "bldg_nm is shorter than the minimum length of 1".to_string(),
1825 ));
1826 }
1827 if val.chars().count() > 35 {
1828 return Err(ValidationError::new(
1829 1002,
1830 "bldg_nm exceeds the maximum length of 35".to_string(),
1831 ));
1832 }
1833 let pattern = Regex::new(
1834 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1835 )
1836 .unwrap();
1837 if !pattern.is_match(val) {
1838 return Err(ValidationError::new(
1839 1005,
1840 "bldg_nm does not match the required pattern".to_string(),
1841 ));
1842 }
1843 }
1844 if let Some(ref val) = self.flr {
1845 if val.chars().count() < 1 {
1846 return Err(ValidationError::new(
1847 1001,
1848 "flr is shorter than the minimum length of 1".to_string(),
1849 ));
1850 }
1851 if val.chars().count() > 70 {
1852 return Err(ValidationError::new(
1853 1002,
1854 "flr exceeds the maximum length of 70".to_string(),
1855 ));
1856 }
1857 let pattern = Regex::new(
1858 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1859 )
1860 .unwrap();
1861 if !pattern.is_match(val) {
1862 return Err(ValidationError::new(
1863 1005,
1864 "flr does not match the required pattern".to_string(),
1865 ));
1866 }
1867 }
1868 if let Some(ref val) = self.pst_bx {
1869 if val.chars().count() < 1 {
1870 return Err(ValidationError::new(
1871 1001,
1872 "pst_bx is shorter than the minimum length of 1".to_string(),
1873 ));
1874 }
1875 if val.chars().count() > 16 {
1876 return Err(ValidationError::new(
1877 1002,
1878 "pst_bx exceeds the maximum length of 16".to_string(),
1879 ));
1880 }
1881 let pattern = Regex::new(
1882 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1883 )
1884 .unwrap();
1885 if !pattern.is_match(val) {
1886 return Err(ValidationError::new(
1887 1005,
1888 "pst_bx does not match the required pattern".to_string(),
1889 ));
1890 }
1891 }
1892 if let Some(ref val) = self.room {
1893 if val.chars().count() < 1 {
1894 return Err(ValidationError::new(
1895 1001,
1896 "room is shorter than the minimum length of 1".to_string(),
1897 ));
1898 }
1899 if val.chars().count() > 70 {
1900 return Err(ValidationError::new(
1901 1002,
1902 "room exceeds the maximum length of 70".to_string(),
1903 ));
1904 }
1905 let pattern = Regex::new(
1906 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1907 )
1908 .unwrap();
1909 if !pattern.is_match(val) {
1910 return Err(ValidationError::new(
1911 1005,
1912 "room does not match the required pattern".to_string(),
1913 ));
1914 }
1915 }
1916 if let Some(ref val) = self.pst_cd {
1917 if val.chars().count() < 1 {
1918 return Err(ValidationError::new(
1919 1001,
1920 "pst_cd is shorter than the minimum length of 1".to_string(),
1921 ));
1922 }
1923 if val.chars().count() > 16 {
1924 return Err(ValidationError::new(
1925 1002,
1926 "pst_cd exceeds the maximum length of 16".to_string(),
1927 ));
1928 }
1929 let pattern = Regex::new(
1930 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1931 )
1932 .unwrap();
1933 if !pattern.is_match(val) {
1934 return Err(ValidationError::new(
1935 1005,
1936 "pst_cd does not match the required pattern".to_string(),
1937 ));
1938 }
1939 }
1940 if let Some(ref val) = self.twn_nm {
1941 if val.chars().count() < 1 {
1942 return Err(ValidationError::new(
1943 1001,
1944 "twn_nm is shorter than the minimum length of 1".to_string(),
1945 ));
1946 }
1947 if val.chars().count() > 35 {
1948 return Err(ValidationError::new(
1949 1002,
1950 "twn_nm exceeds the maximum length of 35".to_string(),
1951 ));
1952 }
1953 let pattern = Regex::new(
1954 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1955 )
1956 .unwrap();
1957 if !pattern.is_match(val) {
1958 return Err(ValidationError::new(
1959 1005,
1960 "twn_nm does not match the required pattern".to_string(),
1961 ));
1962 }
1963 }
1964 if let Some(ref val) = self.twn_lctn_nm {
1965 if val.chars().count() < 1 {
1966 return Err(ValidationError::new(
1967 1001,
1968 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
1969 ));
1970 }
1971 if val.chars().count() > 35 {
1972 return Err(ValidationError::new(
1973 1002,
1974 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
1975 ));
1976 }
1977 let pattern = Regex::new(
1978 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1979 )
1980 .unwrap();
1981 if !pattern.is_match(val) {
1982 return Err(ValidationError::new(
1983 1005,
1984 "twn_lctn_nm does not match the required pattern".to_string(),
1985 ));
1986 }
1987 }
1988 if let Some(ref val) = self.dstrct_nm {
1989 if val.chars().count() < 1 {
1990 return Err(ValidationError::new(
1991 1001,
1992 "dstrct_nm is shorter than the minimum length of 1".to_string(),
1993 ));
1994 }
1995 if val.chars().count() > 35 {
1996 return Err(ValidationError::new(
1997 1002,
1998 "dstrct_nm exceeds the maximum length of 35".to_string(),
1999 ));
2000 }
2001 let pattern = Regex::new(
2002 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2003 )
2004 .unwrap();
2005 if !pattern.is_match(val) {
2006 return Err(ValidationError::new(
2007 1005,
2008 "dstrct_nm does not match the required pattern".to_string(),
2009 ));
2010 }
2011 }
2012 if let Some(ref val) = self.ctry_sub_dvsn {
2013 if val.chars().count() < 1 {
2014 return Err(ValidationError::new(
2015 1001,
2016 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
2017 ));
2018 }
2019 if val.chars().count() > 35 {
2020 return Err(ValidationError::new(
2021 1002,
2022 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
2023 ));
2024 }
2025 let pattern = Regex::new(
2026 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2027 )
2028 .unwrap();
2029 if !pattern.is_match(val) {
2030 return Err(ValidationError::new(
2031 1005,
2032 "ctry_sub_dvsn does not match the required pattern".to_string(),
2033 ));
2034 }
2035 }
2036 if let Some(ref val) = self.ctry {
2037 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2038 if !pattern.is_match(val) {
2039 return Err(ValidationError::new(
2040 1005,
2041 "ctry does not match the required pattern".to_string(),
2042 ));
2043 }
2044 }
2045 if let Some(ref vec) = self.adr_line {
2046 for item in vec {
2047 if item.chars().count() < 1 {
2048 return Err(ValidationError::new(
2049 1001,
2050 "adr_line is shorter than the minimum length of 1".to_string(),
2051 ));
2052 }
2053 if item.chars().count() > 70 {
2054 return Err(ValidationError::new(
2055 1002,
2056 "adr_line exceeds the maximum length of 70".to_string(),
2057 ));
2058 }
2059 let pattern = Regex::new(
2060 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2061 )
2062 .unwrap();
2063 if !pattern.is_match(&item) {
2064 return Err(ValidationError::new(
2065 1005,
2066 "adr_line does not match the required pattern".to_string(),
2067 ));
2068 }
2069 }
2070 }
2071 Ok(())
2072 }
2073}
2074
2075#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2077pub struct ProxyAccountIdentification11 {
2078 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2079 pub tp: Option<ProxyAccountType1Choice1>,
2080 #[serde(rename = "Id")]
2081 pub id: String,
2082}
2083
2084impl ProxyAccountIdentification11 {
2085 pub fn validate(&self) -> Result<(), ValidationError> {
2086 if let Some(ref val) = self.tp {
2087 val.validate()?
2088 }
2089 if self.id.chars().count() < 1 {
2090 return Err(ValidationError::new(
2091 1001,
2092 "id is shorter than the minimum length of 1".to_string(),
2093 ));
2094 }
2095 if self.id.chars().count() > 320 {
2096 return Err(ValidationError::new(
2097 1002,
2098 "id exceeds the maximum length of 320".to_string(),
2099 ));
2100 }
2101 let pattern =
2102 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
2103 .unwrap();
2104 if !pattern.is_match(&self.id) {
2105 return Err(ValidationError::new(
2106 1005,
2107 "id does not match the required pattern".to_string(),
2108 ));
2109 }
2110 Ok(())
2111 }
2112}
2113
2114#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2116pub struct ProxyAccountType1Choice1 {
2117 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2118 pub cd: Option<String>,
2119 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2120 pub prtry: Option<String>,
2121}
2122
2123impl ProxyAccountType1Choice1 {
2124 pub fn validate(&self) -> Result<(), ValidationError> {
2125 if let Some(ref val) = self.cd {
2126 if val.chars().count() < 1 {
2127 return Err(ValidationError::new(
2128 1001,
2129 "cd is shorter than the minimum length of 1".to_string(),
2130 ));
2131 }
2132 if val.chars().count() > 4 {
2133 return Err(ValidationError::new(
2134 1002,
2135 "cd exceeds the maximum length of 4".to_string(),
2136 ));
2137 }
2138 }
2139 if let Some(ref val) = self.prtry {
2140 if val.chars().count() < 1 {
2141 return Err(ValidationError::new(
2142 1001,
2143 "prtry is shorter than the minimum length of 1".to_string(),
2144 ));
2145 }
2146 if val.chars().count() > 35 {
2147 return Err(ValidationError::new(
2148 1002,
2149 "prtry exceeds the maximum length of 35".to_string(),
2150 ));
2151 }
2152 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2153 if !pattern.is_match(val) {
2154 return Err(ValidationError::new(
2155 1005,
2156 "prtry does not match the required pattern".to_string(),
2157 ));
2158 }
2159 }
2160 Ok(())
2161 }
2162}
2163
2164#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2166pub enum QueryType3Code {
2167 #[default]
2168 #[serde(rename = "ALLL")]
2169 CodeALLL,
2170 #[serde(rename = "CHNG")]
2171 CodeCHNG,
2172 #[serde(rename = "MODF")]
2173 CodeMODF,
2174}
2175
2176impl QueryType3Code {
2177 pub fn validate(&self) -> Result<(), ValidationError> {
2178 Ok(())
2179 }
2180}
2181
2182#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2184pub struct ReportingPeriod21 {
2185 #[serde(rename = "FrToDt")]
2186 pub fr_to_dt: DatePeriodDetails1,
2187 #[serde(rename = "FrToTm", skip_serializing_if = "Option::is_none")]
2188 pub fr_to_tm: Option<TimePeriodDetails11>,
2189 #[serde(rename = "Tp")]
2190 pub tp: QueryType3Code,
2191}
2192
2193impl ReportingPeriod21 {
2194 pub fn validate(&self) -> Result<(), ValidationError> {
2195 self.fr_to_dt.validate()?;
2196 if let Some(ref val) = self.fr_to_tm {
2197 val.validate()?
2198 }
2199 self.tp.validate()?;
2200 Ok(())
2201 }
2202}
2203
2204#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2206pub struct ReportingRequest51 {
2207 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2208 pub id: Option<String>,
2209 #[serde(rename = "ReqdMsgNmId")]
2210 pub reqd_msg_nm_id: String,
2211 #[serde(rename = "Acct", skip_serializing_if = "Option::is_none")]
2212 pub acct: Option<CashAccount381>,
2213 #[serde(rename = "AcctOwnr")]
2214 pub acct_ownr: Party40Choice1,
2215 #[serde(rename = "AcctSvcr", skip_serializing_if = "Option::is_none")]
2216 pub acct_svcr: Option<BranchAndFinancialInstitutionIdentification61>,
2217 #[serde(rename = "RptgPrd", skip_serializing_if = "Option::is_none")]
2218 pub rptg_prd: Option<ReportingPeriod21>,
2219 #[serde(rename = "RptgSeq", skip_serializing_if = "Option::is_none")]
2220 pub rptg_seq: Option<SequenceRange1Choice1>,
2221 #[serde(rename = "ReqdTxTp", skip_serializing_if = "Option::is_none")]
2222 pub reqd_tx_tp: Option<TransactionType21>,
2223 #[serde(rename = "ReqdBalTp", skip_serializing_if = "Option::is_none")]
2224 pub reqd_bal_tp: Option<Vec<BalanceType131>>,
2225}
2226
2227impl ReportingRequest51 {
2228 pub fn validate(&self) -> Result<(), ValidationError> {
2229 if let Some(ref val) = self.id {
2230 if val.chars().count() < 1 {
2231 return Err(ValidationError::new(
2232 1001,
2233 "id is shorter than the minimum length of 1".to_string(),
2234 ));
2235 }
2236 if val.chars().count() > 35 {
2237 return Err(ValidationError::new(
2238 1002,
2239 "id exceeds the maximum length of 35".to_string(),
2240 ));
2241 }
2242 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2243 if !pattern.is_match(val) {
2244 return Err(ValidationError::new(
2245 1005,
2246 "id does not match the required pattern".to_string(),
2247 ));
2248 }
2249 }
2250 if self.reqd_msg_nm_id.chars().count() < 1 {
2251 return Err(ValidationError::new(
2252 1001,
2253 "reqd_msg_nm_id is shorter than the minimum length of 1".to_string(),
2254 ));
2255 }
2256 if self.reqd_msg_nm_id.chars().count() > 35 {
2257 return Err(ValidationError::new(
2258 1002,
2259 "reqd_msg_nm_id exceeds the maximum length of 35".to_string(),
2260 ));
2261 }
2262 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2263 if !pattern.is_match(&self.reqd_msg_nm_id) {
2264 return Err(ValidationError::new(
2265 1005,
2266 "reqd_msg_nm_id does not match the required pattern".to_string(),
2267 ));
2268 }
2269 if let Some(ref val) = self.acct {
2270 val.validate()?
2271 }
2272 self.acct_ownr.validate()?;
2273 if let Some(ref val) = self.acct_svcr {
2274 val.validate()?
2275 }
2276 if let Some(ref val) = self.rptg_prd {
2277 val.validate()?
2278 }
2279 if let Some(ref val) = self.rptg_seq {
2280 val.validate()?
2281 }
2282 if let Some(ref val) = self.reqd_tx_tp {
2283 val.validate()?
2284 }
2285 if let Some(ref vec) = self.reqd_bal_tp {
2286 for item in vec {
2287 item.validate()?
2288 }
2289 }
2290 Ok(())
2291 }
2292}
2293
2294#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2296pub struct SequenceRange1Choice1 {
2297 #[serde(rename = "FrSeq", skip_serializing_if = "Option::is_none")]
2298 pub fr_seq: Option<String>,
2299 #[serde(rename = "ToSeq", skip_serializing_if = "Option::is_none")]
2300 pub to_seq: Option<String>,
2301 #[serde(rename = "FrToSeq", skip_serializing_if = "Option::is_none")]
2302 pub fr_to_seq: Option<Vec<SequenceRange11>>,
2303 #[serde(rename = "EQSeq", skip_serializing_if = "Option::is_none")]
2304 pub eq_seq: Option<Vec<String>>,
2305 #[serde(rename = "NEQSeq", skip_serializing_if = "Option::is_none")]
2306 pub neq_seq: Option<Vec<String>>,
2307}
2308
2309impl SequenceRange1Choice1 {
2310 pub fn validate(&self) -> Result<(), ValidationError> {
2311 if let Some(ref val) = self.fr_seq {
2312 if val.chars().count() < 1 {
2313 return Err(ValidationError::new(
2314 1001,
2315 "fr_seq is shorter than the minimum length of 1".to_string(),
2316 ));
2317 }
2318 if val.chars().count() > 35 {
2319 return Err(ValidationError::new(
2320 1002,
2321 "fr_seq exceeds the maximum length of 35".to_string(),
2322 ));
2323 }
2324 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2325 if !pattern.is_match(val) {
2326 return Err(ValidationError::new(
2327 1005,
2328 "fr_seq does not match the required pattern".to_string(),
2329 ));
2330 }
2331 }
2332 if let Some(ref val) = self.to_seq {
2333 if val.chars().count() < 1 {
2334 return Err(ValidationError::new(
2335 1001,
2336 "to_seq is shorter than the minimum length of 1".to_string(),
2337 ));
2338 }
2339 if val.chars().count() > 35 {
2340 return Err(ValidationError::new(
2341 1002,
2342 "to_seq exceeds the maximum length of 35".to_string(),
2343 ));
2344 }
2345 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2346 if !pattern.is_match(val) {
2347 return Err(ValidationError::new(
2348 1005,
2349 "to_seq does not match the required pattern".to_string(),
2350 ));
2351 }
2352 }
2353 if let Some(ref vec) = self.fr_to_seq {
2354 for item in vec {
2355 item.validate()?
2356 }
2357 }
2358 if let Some(ref vec) = self.eq_seq {
2359 for item in vec {
2360 if item.chars().count() < 1 {
2361 return Err(ValidationError::new(
2362 1001,
2363 "eq_seq is shorter than the minimum length of 1".to_string(),
2364 ));
2365 }
2366 if item.chars().count() > 35 {
2367 return Err(ValidationError::new(
2368 1002,
2369 "eq_seq exceeds the maximum length of 35".to_string(),
2370 ));
2371 }
2372 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2373 if !pattern.is_match(&item) {
2374 return Err(ValidationError::new(
2375 1005,
2376 "eq_seq does not match the required pattern".to_string(),
2377 ));
2378 }
2379 }
2380 }
2381 if let Some(ref vec) = self.neq_seq {
2382 for item in vec {
2383 if item.chars().count() < 1 {
2384 return Err(ValidationError::new(
2385 1001,
2386 "neq_seq is shorter than the minimum length of 1".to_string(),
2387 ));
2388 }
2389 if item.chars().count() > 35 {
2390 return Err(ValidationError::new(
2391 1002,
2392 "neq_seq exceeds the maximum length of 35".to_string(),
2393 ));
2394 }
2395 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2396 if !pattern.is_match(&item) {
2397 return Err(ValidationError::new(
2398 1005,
2399 "neq_seq does not match the required pattern".to_string(),
2400 ));
2401 }
2402 }
2403 }
2404 Ok(())
2405 }
2406}
2407
2408#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2410pub struct SequenceRange11 {
2411 #[serde(rename = "FrSeq")]
2412 pub fr_seq: String,
2413 #[serde(rename = "ToSeq")]
2414 pub to_seq: String,
2415}
2416
2417impl SequenceRange11 {
2418 pub fn validate(&self) -> Result<(), ValidationError> {
2419 if self.fr_seq.chars().count() < 1 {
2420 return Err(ValidationError::new(
2421 1001,
2422 "fr_seq is shorter than the minimum length of 1".to_string(),
2423 ));
2424 }
2425 if self.fr_seq.chars().count() > 35 {
2426 return Err(ValidationError::new(
2427 1002,
2428 "fr_seq exceeds the maximum length of 35".to_string(),
2429 ));
2430 }
2431 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2432 if !pattern.is_match(&self.fr_seq) {
2433 return Err(ValidationError::new(
2434 1005,
2435 "fr_seq does not match the required pattern".to_string(),
2436 ));
2437 }
2438 if self.to_seq.chars().count() < 1 {
2439 return Err(ValidationError::new(
2440 1001,
2441 "to_seq is shorter than the minimum length of 1".to_string(),
2442 ));
2443 }
2444 if self.to_seq.chars().count() > 35 {
2445 return Err(ValidationError::new(
2446 1002,
2447 "to_seq exceeds the maximum length of 35".to_string(),
2448 ));
2449 }
2450 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2451 if !pattern.is_match(&self.to_seq) {
2452 return Err(ValidationError::new(
2453 1005,
2454 "to_seq does not match the required pattern".to_string(),
2455 ));
2456 }
2457 Ok(())
2458 }
2459}
2460
2461#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2463pub struct TimePeriodDetails11 {
2464 #[serde(rename = "FrTm")]
2465 pub fr_tm: String,
2466 #[serde(rename = "ToTm", skip_serializing_if = "Option::is_none")]
2467 pub to_tm: Option<String>,
2468}
2469
2470impl TimePeriodDetails11 {
2471 pub fn validate(&self) -> Result<(), ValidationError> {
2472 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2473 if !pattern.is_match(&self.fr_tm) {
2474 return Err(ValidationError::new(
2475 1005,
2476 "fr_tm does not match the required pattern".to_string(),
2477 ));
2478 }
2479 if let Some(ref val) = self.to_tm {
2480 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2481 if !pattern.is_match(val) {
2482 return Err(ValidationError::new(
2483 1005,
2484 "to_tm does not match the required pattern".to_string(),
2485 ));
2486 }
2487 }
2488 Ok(())
2489 }
2490}
2491
2492#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2494pub struct TransactionType21 {
2495 #[serde(rename = "Sts")]
2496 pub sts: EntryStatus1Choice1,
2497 #[serde(rename = "CdtDbtInd")]
2498 pub cdt_dbt_ind: CreditDebitCode,
2499 #[serde(rename = "FlrLmt", skip_serializing_if = "Option::is_none")]
2500 pub flr_lmt: Option<Vec<Limit2>>,
2501}
2502
2503impl TransactionType21 {
2504 pub fn validate(&self) -> Result<(), ValidationError> {
2505 self.sts.validate()?;
2506 self.cdt_dbt_ind.validate()?;
2507 if let Some(ref vec) = self.flr_lmt {
2508 for item in vec {
2509 item.validate()?
2510 }
2511 }
2512 Ok(())
2513 }
2514}