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 AccountIdentification4Choice2 {
54 #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
55 pub iban: Option<String>,
56 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
57 pub othr: Option<GenericAccountIdentification12>,
58}
59
60impl AccountIdentification4Choice2 {
61 pub fn validate(&self) -> Result<(), ValidationError> {
62 if let Some(ref val) = self.iban {
63 let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
64 if !pattern.is_match(val) {
65 return Err(ValidationError::new(
66 1005,
67 "iban does not match the required pattern".to_string(),
68 ));
69 }
70 }
71 if let Some(ref val) = self.othr {
72 val.validate()?
73 }
74 Ok(())
75 }
76}
77
78#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
80pub struct AccountSchemeName1Choice {
81 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
82 pub cd: Option<String>,
83 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
84 pub prtry: Option<String>,
85}
86
87impl AccountSchemeName1Choice {
88 pub fn validate(&self) -> Result<(), ValidationError> {
89 if let Some(ref val) = self.cd {
90 if val.chars().count() < 1 {
91 return Err(ValidationError::new(
92 1001,
93 "cd is shorter than the minimum length of 1".to_string(),
94 ));
95 }
96 if val.chars().count() > 4 {
97 return Err(ValidationError::new(
98 1002,
99 "cd exceeds the maximum length of 4".to_string(),
100 ));
101 }
102 }
103 if let Some(ref val) = self.prtry {
104 if val.chars().count() < 1 {
105 return Err(ValidationError::new(
106 1001,
107 "prtry is shorter than the minimum length of 1".to_string(),
108 ));
109 }
110 if val.chars().count() > 35 {
111 return Err(ValidationError::new(
112 1002,
113 "prtry exceeds the maximum length of 35".to_string(),
114 ));
115 }
116 }
117 Ok(())
118 }
119}
120
121#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
123pub struct AccountSchemeName1Choice1 {
124 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
125 pub cd: Option<String>,
126 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
127 pub prtry: Option<String>,
128}
129
130impl AccountSchemeName1Choice1 {
131 pub fn validate(&self) -> Result<(), ValidationError> {
132 if let Some(ref val) = self.cd {
133 if val.chars().count() < 1 {
134 return Err(ValidationError::new(
135 1001,
136 "cd is shorter than the minimum length of 1".to_string(),
137 ));
138 }
139 if val.chars().count() > 4 {
140 return Err(ValidationError::new(
141 1002,
142 "cd exceeds the maximum length of 4".to_string(),
143 ));
144 }
145 }
146 if let Some(ref val) = self.prtry {
147 if val.chars().count() < 1 {
148 return Err(ValidationError::new(
149 1001,
150 "prtry is shorter than the minimum length of 1".to_string(),
151 ));
152 }
153 if val.chars().count() > 35 {
154 return Err(ValidationError::new(
155 1002,
156 "prtry exceeds the maximum length of 35".to_string(),
157 ));
158 }
159 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
160 if !pattern.is_match(val) {
161 return Err(ValidationError::new(
162 1005,
163 "prtry does not match the required pattern".to_string(),
164 ));
165 }
166 }
167 Ok(())
168 }
169}
170
171#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
173pub struct ActiveOrHistoricCurrencyAndAmount {
174 #[serde(rename = "@Ccy")]
175 pub ccy: String,
176 #[serde(rename = "$value")]
177 pub value: f64,
178}
179
180impl ActiveOrHistoricCurrencyAndAmount {
181 pub fn validate(&self) -> Result<(), ValidationError> {
182 Ok(())
183 }
184}
185
186#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
188pub struct AmendmentInformationDetails131 {
189 #[serde(rename = "OrgnlMndtId", skip_serializing_if = "Option::is_none")]
190 pub orgnl_mndt_id: Option<String>,
191 #[serde(rename = "OrgnlCdtrSchmeId", skip_serializing_if = "Option::is_none")]
192 pub orgnl_cdtr_schme_id: Option<PartyIdentification1351>,
193 #[serde(rename = "OrgnlCdtrAgt", skip_serializing_if = "Option::is_none")]
194 pub orgnl_cdtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
195 #[serde(rename = "OrgnlCdtrAgtAcct", skip_serializing_if = "Option::is_none")]
196 pub orgnl_cdtr_agt_acct: Option<CashAccount382>,
197 #[serde(rename = "OrgnlDbtr", skip_serializing_if = "Option::is_none")]
198 pub orgnl_dbtr: Option<PartyIdentification1351>,
199 #[serde(rename = "OrgnlDbtrAcct", skip_serializing_if = "Option::is_none")]
200 pub orgnl_dbtr_acct: Option<CashAccount382>,
201 #[serde(rename = "OrgnlDbtrAgt", skip_serializing_if = "Option::is_none")]
202 pub orgnl_dbtr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
203 #[serde(rename = "OrgnlDbtrAgtAcct", skip_serializing_if = "Option::is_none")]
204 pub orgnl_dbtr_agt_acct: Option<CashAccount382>,
205 #[serde(rename = "OrgnlFnlColltnDt", skip_serializing_if = "Option::is_none")]
206 pub orgnl_fnl_colltn_dt: Option<String>,
207 #[serde(rename = "OrgnlFrqcy", skip_serializing_if = "Option::is_none")]
208 pub orgnl_frqcy: Option<Frequency36Choice>,
209 #[serde(rename = "OrgnlRsn", skip_serializing_if = "Option::is_none")]
210 pub orgnl_rsn: Option<MandateSetupReason1Choice1>,
211 #[serde(rename = "OrgnlTrckgDays", skip_serializing_if = "Option::is_none")]
212 pub orgnl_trckg_days: Option<String>,
213}
214
215impl AmendmentInformationDetails131 {
216 pub fn validate(&self) -> Result<(), ValidationError> {
217 if let Some(ref val) = self.orgnl_mndt_id {
218 if val.chars().count() < 1 {
219 return Err(ValidationError::new(
220 1001,
221 "orgnl_mndt_id is shorter than the minimum length of 1".to_string(),
222 ));
223 }
224 if val.chars().count() > 35 {
225 return Err(ValidationError::new(
226 1002,
227 "orgnl_mndt_id exceeds the maximum length of 35".to_string(),
228 ));
229 }
230 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
231 if !pattern.is_match(val) {
232 return Err(ValidationError::new(
233 1005,
234 "orgnl_mndt_id does not match the required pattern".to_string(),
235 ));
236 }
237 }
238 if let Some(ref val) = self.orgnl_cdtr_schme_id {
239 val.validate()?
240 }
241 if let Some(ref val) = self.orgnl_cdtr_agt {
242 val.validate()?
243 }
244 if let Some(ref val) = self.orgnl_cdtr_agt_acct {
245 val.validate()?
246 }
247 if let Some(ref val) = self.orgnl_dbtr {
248 val.validate()?
249 }
250 if let Some(ref val) = self.orgnl_dbtr_acct {
251 val.validate()?
252 }
253 if let Some(ref val) = self.orgnl_dbtr_agt {
254 val.validate()?
255 }
256 if let Some(ref val) = self.orgnl_dbtr_agt_acct {
257 val.validate()?
258 }
259 if let Some(ref val) = self.orgnl_frqcy {
260 val.validate()?
261 }
262 if let Some(ref val) = self.orgnl_rsn {
263 val.validate()?
264 }
265 if let Some(ref val) = self.orgnl_trckg_days {
266 let pattern = Regex::new("[0-9]{2}").unwrap();
267 if !pattern.is_match(val) {
268 return Err(ValidationError::new(
269 1005,
270 "orgnl_trckg_days does not match the required pattern".to_string(),
271 ));
272 }
273 }
274 Ok(())
275 }
276}
277
278#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
280pub struct BranchAndFinancialInstitutionIdentification61 {
281 #[serde(rename = "FinInstnId")]
282 pub fin_instn_id: FinancialInstitutionIdentification181,
283}
284
285impl BranchAndFinancialInstitutionIdentification61 {
286 pub fn validate(&self) -> Result<(), ValidationError> {
287 self.fin_instn_id.validate()?;
288 Ok(())
289 }
290}
291
292#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
294pub struct BranchAndFinancialInstitutionIdentification62 {
295 #[serde(rename = "FinInstnId")]
296 pub fin_instn_id: FinancialInstitutionIdentification182,
297}
298
299impl BranchAndFinancialInstitutionIdentification62 {
300 pub fn validate(&self) -> Result<(), ValidationError> {
301 self.fin_instn_id.validate()?;
302 Ok(())
303 }
304}
305
306#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
308pub struct BranchAndFinancialInstitutionIdentification63 {
309 #[serde(rename = "FinInstnId")]
310 pub fin_instn_id: FinancialInstitutionIdentification183,
311}
312
313impl BranchAndFinancialInstitutionIdentification63 {
314 pub fn validate(&self) -> Result<(), ValidationError> {
315 self.fin_instn_id.validate()?;
316 Ok(())
317 }
318}
319
320#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
322pub struct CBPRAmount {
323 #[serde(rename = "@Ccy")]
324 pub ccy: String,
325 #[serde(rename = "$value")]
326 pub value: f64,
327}
328
329impl CBPRAmount {
330 pub fn validate(&self) -> Result<(), ValidationError> {
331 Ok(())
332 }
333}
334
335#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
337pub struct CashAccount381 {
338 #[serde(rename = "Id")]
339 pub id: AccountIdentification4Choice1,
340 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
341 pub tp: Option<CashAccountType2Choice1>,
342 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
343 pub ccy: Option<String>,
344 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
345 pub nm: Option<String>,
346 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
347 pub prxy: Option<ProxyAccountIdentification11>,
348}
349
350impl CashAccount381 {
351 pub fn validate(&self) -> Result<(), ValidationError> {
352 self.id.validate()?;
353 if let Some(ref val) = self.tp {
354 val.validate()?
355 }
356 if let Some(ref val) = self.ccy {
357 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
358 if !pattern.is_match(val) {
359 return Err(ValidationError::new(
360 1005,
361 "ccy does not match the required pattern".to_string(),
362 ));
363 }
364 }
365 if let Some(ref val) = self.nm {
366 if val.chars().count() < 1 {
367 return Err(ValidationError::new(
368 1001,
369 "nm is shorter than the minimum length of 1".to_string(),
370 ));
371 }
372 if val.chars().count() > 70 {
373 return Err(ValidationError::new(
374 1002,
375 "nm exceeds the maximum length of 70".to_string(),
376 ));
377 }
378 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
379 if !pattern.is_match(val) {
380 return Err(ValidationError::new(
381 1005,
382 "nm does not match the required pattern".to_string(),
383 ));
384 }
385 }
386 if let Some(ref val) = self.prxy {
387 val.validate()?
388 }
389 Ok(())
390 }
391}
392
393#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
395pub struct CashAccount382 {
396 #[serde(rename = "Id")]
397 pub id: AccountIdentification4Choice2,
398 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
399 pub tp: Option<CashAccountType2Choice1>,
400 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
401 pub ccy: Option<String>,
402 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
403 pub nm: Option<String>,
404 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
405 pub prxy: Option<ProxyAccountIdentification12>,
406}
407
408impl CashAccount382 {
409 pub fn validate(&self) -> Result<(), ValidationError> {
410 self.id.validate()?;
411 if let Some(ref val) = self.tp {
412 val.validate()?
413 }
414 if let Some(ref val) = self.ccy {
415 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
416 if !pattern.is_match(val) {
417 return Err(ValidationError::new(
418 1005,
419 "ccy does not match the required pattern".to_string(),
420 ));
421 }
422 }
423 if let Some(ref val) = self.nm {
424 if val.chars().count() < 1 {
425 return Err(ValidationError::new(
426 1001,
427 "nm is shorter than the minimum length of 1".to_string(),
428 ));
429 }
430 if val.chars().count() > 70 {
431 return Err(ValidationError::new(
432 1002,
433 "nm exceeds the maximum length of 70".to_string(),
434 ));
435 }
436 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
437 if !pattern.is_match(val) {
438 return Err(ValidationError::new(
439 1005,
440 "nm does not match the required pattern".to_string(),
441 ));
442 }
443 }
444 if let Some(ref val) = self.prxy {
445 val.validate()?
446 }
447 Ok(())
448 }
449}
450
451#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
453pub struct CashAccount383 {
454 #[serde(rename = "Id")]
455 pub id: AccountIdentification4Choice1,
456 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
457 pub tp: Option<CashAccountType2Choice1>,
458 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
459 pub ccy: Option<String>,
460 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
461 pub nm: Option<String>,
462 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
463 pub prxy: Option<ProxyAccountIdentification12>,
464}
465
466impl CashAccount383 {
467 pub fn validate(&self) -> Result<(), ValidationError> {
468 self.id.validate()?;
469 if let Some(ref val) = self.tp {
470 val.validate()?
471 }
472 if let Some(ref val) = self.ccy {
473 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
474 if !pattern.is_match(val) {
475 return Err(ValidationError::new(
476 1005,
477 "ccy does not match the required pattern".to_string(),
478 ));
479 }
480 }
481 if let Some(ref val) = self.nm {
482 if val.chars().count() < 1 {
483 return Err(ValidationError::new(
484 1001,
485 "nm is shorter than the minimum length of 1".to_string(),
486 ));
487 }
488 if val.chars().count() > 70 {
489 return Err(ValidationError::new(
490 1002,
491 "nm exceeds the maximum length of 70".to_string(),
492 ));
493 }
494 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
495 if !pattern.is_match(val) {
496 return Err(ValidationError::new(
497 1005,
498 "nm does not match the required pattern".to_string(),
499 ));
500 }
501 }
502 if let Some(ref val) = self.prxy {
503 val.validate()?
504 }
505 Ok(())
506 }
507}
508
509#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
511pub struct CashAccountType2Choice1 {
512 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
513 pub cd: Option<String>,
514 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
515 pub prtry: Option<String>,
516}
517
518impl CashAccountType2Choice1 {
519 pub fn validate(&self) -> Result<(), ValidationError> {
520 if let Some(ref val) = self.cd {
521 if val.chars().count() < 1 {
522 return Err(ValidationError::new(
523 1001,
524 "cd is shorter than the minimum length of 1".to_string(),
525 ));
526 }
527 if val.chars().count() > 4 {
528 return Err(ValidationError::new(
529 1002,
530 "cd exceeds the maximum length of 4".to_string(),
531 ));
532 }
533 }
534 if let Some(ref val) = self.prtry {
535 if val.chars().count() < 1 {
536 return Err(ValidationError::new(
537 1001,
538 "prtry is shorter than the minimum length of 1".to_string(),
539 ));
540 }
541 if val.chars().count() > 35 {
542 return Err(ValidationError::new(
543 1002,
544 "prtry exceeds the maximum length of 35".to_string(),
545 ));
546 }
547 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
548 if !pattern.is_match(val) {
549 return Err(ValidationError::new(
550 1005,
551 "prtry does not match the required pattern".to_string(),
552 ));
553 }
554 }
555 Ok(())
556 }
557}
558
559#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
561pub struct CategoryPurpose1Choice1 {
562 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
563 pub cd: Option<String>,
564 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
565 pub prtry: Option<String>,
566}
567
568impl CategoryPurpose1Choice1 {
569 pub fn validate(&self) -> Result<(), ValidationError> {
570 if let Some(ref val) = self.cd {
571 if val.chars().count() < 1 {
572 return Err(ValidationError::new(
573 1001,
574 "cd is shorter than the minimum length of 1".to_string(),
575 ));
576 }
577 if val.chars().count() > 4 {
578 return Err(ValidationError::new(
579 1002,
580 "cd exceeds the maximum length of 4".to_string(),
581 ));
582 }
583 }
584 if let Some(ref val) = self.prtry {
585 if val.chars().count() < 1 {
586 return Err(ValidationError::new(
587 1001,
588 "prtry is shorter than the minimum length of 1".to_string(),
589 ));
590 }
591 if val.chars().count() > 35 {
592 return Err(ValidationError::new(
593 1002,
594 "prtry exceeds the maximum length of 35".to_string(),
595 ));
596 }
597 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
598 if !pattern.is_match(val) {
599 return Err(ValidationError::new(
600 1005,
601 "prtry does not match the required pattern".to_string(),
602 ));
603 }
604 }
605 Ok(())
606 }
607}
608
609#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
611pub enum ChargeBearerType1Code1 {
612 #[default]
613 #[serde(rename = "DEBT")]
614 CodeDEBT,
615 #[serde(rename = "CRED")]
616 CodeCRED,
617 #[serde(rename = "SHAR")]
618 CodeSHAR,
619}
620
621impl ChargeBearerType1Code1 {
622 pub fn validate(&self) -> Result<(), ValidationError> {
623 Ok(())
624 }
625}
626
627#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
629pub struct Charges71 {
630 #[serde(rename = "Amt")]
631 pub amt: CBPRAmount,
632 #[serde(rename = "Agt")]
633 pub agt: BranchAndFinancialInstitutionIdentification61,
634}
635
636impl Charges71 {
637 pub fn validate(&self) -> Result<(), ValidationError> {
638 self.amt.validate()?;
639 self.agt.validate()?;
640 Ok(())
641 }
642}
643
644#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
646pub enum ClearingChannel2Code {
647 #[default]
648 #[serde(rename = "RTGS")]
649 CodeRTGS,
650 #[serde(rename = "RTNS")]
651 CodeRTNS,
652 #[serde(rename = "MPNS")]
653 CodeMPNS,
654 #[serde(rename = "BOOK")]
655 CodeBOOK,
656}
657
658impl ClearingChannel2Code {
659 pub fn validate(&self) -> Result<(), ValidationError> {
660 Ok(())
661 }
662}
663
664#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
666pub struct ClearingSystemIdentification2Choice1 {
667 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
668 pub cd: Option<String>,
669}
670
671impl ClearingSystemIdentification2Choice1 {
672 pub fn validate(&self) -> Result<(), ValidationError> {
673 if let Some(ref val) = self.cd {
674 if val.chars().count() < 1 {
675 return Err(ValidationError::new(
676 1001,
677 "cd is shorter than the minimum length of 1".to_string(),
678 ));
679 }
680 if val.chars().count() > 5 {
681 return Err(ValidationError::new(
682 1002,
683 "cd exceeds the maximum length of 5".to_string(),
684 ));
685 }
686 }
687 Ok(())
688 }
689}
690
691#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
693pub struct ClearingSystemMemberIdentification21 {
694 #[serde(rename = "ClrSysId")]
695 pub clr_sys_id: ClearingSystemIdentification2Choice1,
696 #[serde(rename = "MmbId")]
697 pub mmb_id: String,
698}
699
700impl ClearingSystemMemberIdentification21 {
701 pub fn validate(&self) -> Result<(), ValidationError> {
702 self.clr_sys_id.validate()?;
703 if self.mmb_id.chars().count() < 1 {
704 return Err(ValidationError::new(
705 1001,
706 "mmb_id is shorter than the minimum length of 1".to_string(),
707 ));
708 }
709 if self.mmb_id.chars().count() > 28 {
710 return Err(ValidationError::new(
711 1002,
712 "mmb_id exceeds the maximum length of 28".to_string(),
713 ));
714 }
715 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
716 if !pattern.is_match(&self.mmb_id) {
717 return Err(ValidationError::new(
718 1005,
719 "mmb_id does not match the required pattern".to_string(),
720 ));
721 }
722 Ok(())
723 }
724}
725
726#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
728pub enum CreditDebitCode {
729 #[default]
730 #[serde(rename = "CRDT")]
731 CodeCRDT,
732 #[serde(rename = "DBIT")]
733 CodeDBIT,
734}
735
736impl CreditDebitCode {
737 pub fn validate(&self) -> Result<(), ValidationError> {
738 Ok(())
739 }
740}
741
742#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
748pub struct CreditorReferenceInformation21 {
749 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
750 pub tp: Option<CreditorReferenceType21>,
751 #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
752 pub ref_attr: Option<String>,
753}
754
755impl CreditorReferenceInformation21 {
756 pub fn validate(&self) -> Result<(), ValidationError> {
757 if let Some(ref val) = self.tp {
758 val.validate()?
759 }
760 if let Some(ref val) = self.ref_attr {
761 if val.chars().count() < 1 {
762 return Err(ValidationError::new(
763 1001,
764 "ref_attr is shorter than the minimum length of 1".to_string(),
765 ));
766 }
767 if val.chars().count() > 35 {
768 return Err(ValidationError::new(
769 1002,
770 "ref_attr exceeds the maximum length of 35".to_string(),
771 ));
772 }
773 let pattern = Regex::new(
774 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
775 )
776 .unwrap();
777 if !pattern.is_match(val) {
778 return Err(ValidationError::new(
779 1005,
780 "ref_attr does not match the required pattern".to_string(),
781 ));
782 }
783 }
784 Ok(())
785 }
786}
787
788#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
790pub struct CreditorReferenceType1Choice {
791 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
792 pub cd: Option<DocumentType3Code>,
793 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
794 pub prtry: Option<String>,
795}
796
797impl CreditorReferenceType1Choice {
798 pub fn validate(&self) -> Result<(), ValidationError> {
799 if let Some(ref val) = self.cd {
800 val.validate()?
801 }
802 if let Some(ref val) = self.prtry {
803 if val.chars().count() < 1 {
804 return Err(ValidationError::new(
805 1001,
806 "prtry is shorter than the minimum length of 1".to_string(),
807 ));
808 }
809 if val.chars().count() > 35 {
810 return Err(ValidationError::new(
811 1002,
812 "prtry exceeds the maximum length of 35".to_string(),
813 ));
814 }
815 }
816 Ok(())
817 }
818}
819
820#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
822pub struct CreditorReferenceType21 {
823 #[serde(rename = "CdOrPrtry")]
824 pub cd_or_prtry: CreditorReferenceType1Choice,
825 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
826 pub issr: Option<String>,
827}
828
829impl CreditorReferenceType21 {
830 pub fn validate(&self) -> Result<(), ValidationError> {
831 self.cd_or_prtry.validate()?;
832 if let Some(ref val) = self.issr {
833 if val.chars().count() < 1 {
834 return Err(ValidationError::new(
835 1001,
836 "issr is shorter than the minimum length of 1".to_string(),
837 ));
838 }
839 if val.chars().count() > 35 {
840 return Err(ValidationError::new(
841 1002,
842 "issr exceeds the maximum length of 35".to_string(),
843 ));
844 }
845 let pattern = Regex::new(
846 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
847 )
848 .unwrap();
849 if !pattern.is_match(val) {
850 return Err(ValidationError::new(
851 1005,
852 "issr does not match the required pattern".to_string(),
853 ));
854 }
855 }
856 Ok(())
857 }
858}
859
860#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
862pub struct DateAndPlaceOfBirth1 {
863 #[serde(rename = "BirthDt")]
864 pub birth_dt: String,
865 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
866 pub prvc_of_birth: Option<String>,
867 #[serde(rename = "CityOfBirth")]
868 pub city_of_birth: String,
869 #[serde(rename = "CtryOfBirth")]
870 pub ctry_of_birth: String,
871}
872
873impl DateAndPlaceOfBirth1 {
874 pub fn validate(&self) -> Result<(), ValidationError> {
875 if let Some(ref val) = self.prvc_of_birth {
876 if val.chars().count() < 1 {
877 return Err(ValidationError::new(
878 1001,
879 "prvc_of_birth is shorter than the minimum length of 1".to_string(),
880 ));
881 }
882 if val.chars().count() > 35 {
883 return Err(ValidationError::new(
884 1002,
885 "prvc_of_birth exceeds the maximum length of 35".to_string(),
886 ));
887 }
888 }
889 if self.city_of_birth.chars().count() < 1 {
890 return Err(ValidationError::new(
891 1001,
892 "city_of_birth is shorter than the minimum length of 1".to_string(),
893 ));
894 }
895 if self.city_of_birth.chars().count() > 35 {
896 return Err(ValidationError::new(
897 1002,
898 "city_of_birth exceeds the maximum length of 35".to_string(),
899 ));
900 }
901 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
902 if !pattern.is_match(&self.ctry_of_birth) {
903 return Err(ValidationError::new(
904 1005,
905 "ctry_of_birth does not match the required pattern".to_string(),
906 ));
907 }
908 Ok(())
909 }
910}
911
912#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
914pub struct DateAndPlaceOfBirth11 {
915 #[serde(rename = "BirthDt")]
916 pub birth_dt: String,
917 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
918 pub prvc_of_birth: Option<String>,
919 #[serde(rename = "CityOfBirth")]
920 pub city_of_birth: String,
921 #[serde(rename = "CtryOfBirth")]
922 pub ctry_of_birth: String,
923}
924
925impl DateAndPlaceOfBirth11 {
926 pub fn validate(&self) -> Result<(), ValidationError> {
927 if let Some(ref val) = self.prvc_of_birth {
928 if val.chars().count() < 1 {
929 return Err(ValidationError::new(
930 1001,
931 "prvc_of_birth is shorter than the minimum length of 1".to_string(),
932 ));
933 }
934 if val.chars().count() > 35 {
935 return Err(ValidationError::new(
936 1002,
937 "prvc_of_birth exceeds the maximum length of 35".to_string(),
938 ));
939 }
940 let pattern = Regex::new(
941 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
942 )
943 .unwrap();
944 if !pattern.is_match(val) {
945 return Err(ValidationError::new(
946 1005,
947 "prvc_of_birth does not match the required pattern".to_string(),
948 ));
949 }
950 }
951 if self.city_of_birth.chars().count() < 1 {
952 return Err(ValidationError::new(
953 1001,
954 "city_of_birth is shorter than the minimum length of 1".to_string(),
955 ));
956 }
957 if self.city_of_birth.chars().count() > 35 {
958 return Err(ValidationError::new(
959 1002,
960 "city_of_birth exceeds the maximum length of 35".to_string(),
961 ));
962 }
963 let pattern =
964 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
965 .unwrap();
966 if !pattern.is_match(&self.city_of_birth) {
967 return Err(ValidationError::new(
968 1005,
969 "city_of_birth does not match the required pattern".to_string(),
970 ));
971 }
972 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
973 if !pattern.is_match(&self.ctry_of_birth) {
974 return Err(ValidationError::new(
975 1005,
976 "ctry_of_birth does not match the required pattern".to_string(),
977 ));
978 }
979 Ok(())
980 }
981}
982
983#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
985pub struct DatePeriod2 {
986 #[serde(rename = "FrDt")]
987 pub fr_dt: String,
988 #[serde(rename = "ToDt")]
989 pub to_dt: String,
990}
991
992impl DatePeriod2 {
993 pub fn validate(&self) -> Result<(), ValidationError> {
994 Ok(())
995 }
996}
997
998#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1000pub struct DirectDebitTransaction101 {
1001 #[serde(rename = "MndtRltdInf", skip_serializing_if = "Option::is_none")]
1002 pub mndt_rltd_inf: Option<MandateRelatedInformation141>,
1003 #[serde(rename = "CdtrSchmeId", skip_serializing_if = "Option::is_none")]
1004 pub cdtr_schme_id: Option<PartyIdentification1352>,
1005 #[serde(rename = "PreNtfctnId", skip_serializing_if = "Option::is_none")]
1006 pub pre_ntfctn_id: Option<String>,
1007 #[serde(rename = "PreNtfctnDt", skip_serializing_if = "Option::is_none")]
1008 pub pre_ntfctn_dt: Option<String>,
1009}
1010
1011impl DirectDebitTransaction101 {
1012 pub fn validate(&self) -> Result<(), ValidationError> {
1013 if let Some(ref val) = self.mndt_rltd_inf {
1014 val.validate()?
1015 }
1016 if let Some(ref val) = self.cdtr_schme_id {
1017 val.validate()?
1018 }
1019 if let Some(ref val) = self.pre_ntfctn_id {
1020 if val.chars().count() < 1 {
1021 return Err(ValidationError::new(
1022 1001,
1023 "pre_ntfctn_id is shorter than the minimum length of 1".to_string(),
1024 ));
1025 }
1026 if val.chars().count() > 35 {
1027 return Err(ValidationError::new(
1028 1002,
1029 "pre_ntfctn_id exceeds the maximum length of 35".to_string(),
1030 ));
1031 }
1032 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1033 if !pattern.is_match(val) {
1034 return Err(ValidationError::new(
1035 1005,
1036 "pre_ntfctn_id does not match the required pattern".to_string(),
1037 ));
1038 }
1039 }
1040 Ok(())
1041 }
1042}
1043
1044#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1046pub struct DirectDebitTransactionInformation241 {
1047 #[serde(rename = "PmtId")]
1048 pub pmt_id: PaymentIdentification71,
1049 #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
1050 pub pmt_tp_inf: Option<PaymentTypeInformation271>,
1051 #[serde(rename = "IntrBkSttlmAmt")]
1052 pub intr_bk_sttlm_amt: CBPRAmount,
1053 #[serde(rename = "IntrBkSttlmDt")]
1054 pub intr_bk_sttlm_dt: String,
1055 #[serde(rename = "SttlmPrty", skip_serializing_if = "Option::is_none")]
1056 pub sttlm_prty: Option<Priority3Code>,
1057 #[serde(rename = "SttlmTmIndctn", skip_serializing_if = "Option::is_none")]
1058 pub sttlm_tm_indctn: Option<SettlementDateTimeIndication11>,
1059 #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
1060 pub instd_amt: Option<CBPRAmount>,
1061 #[serde(rename = "XchgRate", skip_serializing_if = "Option::is_none")]
1062 pub xchg_rate: Option<f64>,
1063 #[serde(rename = "ChrgBr")]
1064 pub chrg_br: ChargeBearerType1Code1,
1065 #[serde(rename = "ChrgsInf", skip_serializing_if = "Option::is_none")]
1066 pub chrgs_inf: Option<Vec<Charges71>>,
1067 #[serde(rename = "ReqdColltnDt")]
1068 pub reqd_colltn_dt: String,
1069 #[serde(rename = "DrctDbtTx", skip_serializing_if = "Option::is_none")]
1070 pub drct_dbt_tx: Option<DirectDebitTransaction101>,
1071 #[serde(rename = "Cdtr")]
1072 pub cdtr: PartyIdentification1351,
1073 #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
1074 pub cdtr_acct: Option<CashAccount382>,
1075 #[serde(rename = "CdtrAgt")]
1076 pub cdtr_agt: BranchAndFinancialInstitutionIdentification61,
1077 #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
1078 pub cdtr_agt_acct: Option<CashAccount382>,
1079 #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
1080 pub ultmt_cdtr: Option<PartyIdentification1353>,
1081 #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
1082 pub initg_pty: Option<PartyIdentification1353>,
1083 #[serde(rename = "InstgAgt")]
1084 pub instg_agt: BranchAndFinancialInstitutionIdentification62,
1085 #[serde(rename = "InstdAgt")]
1086 pub instd_agt: BranchAndFinancialInstitutionIdentification62,
1087 #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
1088 pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification63>,
1089 #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
1090 pub intrmy_agt1_acct: Option<CashAccount382>,
1091 #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
1092 pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification61>,
1093 #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
1094 pub intrmy_agt2_acct: Option<CashAccount382>,
1095 #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
1096 pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification61>,
1097 #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
1098 pub intrmy_agt3_acct: Option<CashAccount383>,
1099 #[serde(rename = "Dbtr")]
1100 pub dbtr: PartyIdentification1354,
1101 #[serde(rename = "DbtrAcct")]
1102 pub dbtr_acct: CashAccount382,
1103 #[serde(rename = "DbtrAgt")]
1104 pub dbtr_agt: BranchAndFinancialInstitutionIdentification61,
1105 #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
1106 pub dbtr_agt_acct: Option<CashAccount383>,
1107 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
1108 pub ultmt_dbtr: Option<PartyIdentification1353>,
1109 #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
1110 pub purp: Option<Purpose2Choice1>,
1111 #[serde(rename = "RgltryRptg", skip_serializing_if = "Option::is_none")]
1112 pub rgltry_rptg: Option<Vec<RegulatoryReporting31>>,
1113 #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
1114 pub rltd_rmt_inf: Option<Vec<RemittanceLocation71>>,
1115 #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
1116 pub rmt_inf: Option<RemittanceInformation161>,
1117}
1118
1119impl DirectDebitTransactionInformation241 {
1120 pub fn validate(&self) -> Result<(), ValidationError> {
1121 self.pmt_id.validate()?;
1122 if let Some(ref val) = self.pmt_tp_inf {
1123 val.validate()?
1124 }
1125 self.intr_bk_sttlm_amt.validate()?;
1126 if let Some(ref val) = self.sttlm_prty {
1127 val.validate()?
1128 }
1129 if let Some(ref val) = self.sttlm_tm_indctn {
1130 val.validate()?
1131 }
1132 if let Some(ref val) = self.instd_amt {
1133 val.validate()?
1134 }
1135 self.chrg_br.validate()?;
1136 if let Some(ref vec) = self.chrgs_inf {
1137 for item in vec {
1138 item.validate()?
1139 }
1140 }
1141 if let Some(ref val) = self.drct_dbt_tx {
1142 val.validate()?
1143 }
1144 self.cdtr.validate()?;
1145 if let Some(ref val) = self.cdtr_acct {
1146 val.validate()?
1147 }
1148 self.cdtr_agt.validate()?;
1149 if let Some(ref val) = self.cdtr_agt_acct {
1150 val.validate()?
1151 }
1152 if let Some(ref val) = self.ultmt_cdtr {
1153 val.validate()?
1154 }
1155 if let Some(ref val) = self.initg_pty {
1156 val.validate()?
1157 }
1158 self.instg_agt.validate()?;
1159 self.instd_agt.validate()?;
1160 if let Some(ref val) = self.intrmy_agt1 {
1161 val.validate()?
1162 }
1163 if let Some(ref val) = self.intrmy_agt1_acct {
1164 val.validate()?
1165 }
1166 if let Some(ref val) = self.intrmy_agt2 {
1167 val.validate()?
1168 }
1169 if let Some(ref val) = self.intrmy_agt2_acct {
1170 val.validate()?
1171 }
1172 if let Some(ref val) = self.intrmy_agt3 {
1173 val.validate()?
1174 }
1175 if let Some(ref val) = self.intrmy_agt3_acct {
1176 val.validate()?
1177 }
1178 self.dbtr.validate()?;
1179 self.dbtr_acct.validate()?;
1180 self.dbtr_agt.validate()?;
1181 if let Some(ref val) = self.dbtr_agt_acct {
1182 val.validate()?
1183 }
1184 if let Some(ref val) = self.ultmt_dbtr {
1185 val.validate()?
1186 }
1187 if let Some(ref val) = self.purp {
1188 val.validate()?
1189 }
1190 if let Some(ref vec) = self.rgltry_rptg {
1191 for item in vec {
1192 item.validate()?
1193 }
1194 }
1195 if let Some(ref vec) = self.rltd_rmt_inf {
1196 for item in vec {
1197 item.validate()?
1198 }
1199 }
1200 if let Some(ref val) = self.rmt_inf {
1201 val.validate()?
1202 }
1203 Ok(())
1204 }
1205}
1206
1207#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1209pub struct DiscountAmountAndType1 {
1210 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1211 pub tp: Option<DiscountAmountType1Choice>,
1212 #[serde(rename = "Amt")]
1213 pub amt: ActiveOrHistoricCurrencyAndAmount,
1214}
1215
1216impl DiscountAmountAndType1 {
1217 pub fn validate(&self) -> Result<(), ValidationError> {
1218 if let Some(ref val) = self.tp {
1219 val.validate()?
1220 }
1221 self.amt.validate()?;
1222 Ok(())
1223 }
1224}
1225
1226#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1228pub struct DiscountAmountAndType11 {
1229 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1230 pub tp: Option<DiscountAmountType1Choice1>,
1231 #[serde(rename = "Amt")]
1232 pub amt: ActiveOrHistoricCurrencyAndAmount,
1233}
1234
1235impl DiscountAmountAndType11 {
1236 pub fn validate(&self) -> Result<(), ValidationError> {
1237 if let Some(ref val) = self.tp {
1238 val.validate()?
1239 }
1240 self.amt.validate()?;
1241 Ok(())
1242 }
1243}
1244
1245#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1247pub struct DiscountAmountType1Choice {
1248 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1249 pub cd: Option<String>,
1250 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1251 pub prtry: Option<String>,
1252}
1253
1254impl DiscountAmountType1Choice {
1255 pub fn validate(&self) -> Result<(), ValidationError> {
1256 if let Some(ref val) = self.cd {
1257 if val.chars().count() < 1 {
1258 return Err(ValidationError::new(
1259 1001,
1260 "cd is shorter than the minimum length of 1".to_string(),
1261 ));
1262 }
1263 if val.chars().count() > 4 {
1264 return Err(ValidationError::new(
1265 1002,
1266 "cd exceeds the maximum length of 4".to_string(),
1267 ));
1268 }
1269 }
1270 if let Some(ref val) = self.prtry {
1271 if val.chars().count() < 1 {
1272 return Err(ValidationError::new(
1273 1001,
1274 "prtry is shorter than the minimum length of 1".to_string(),
1275 ));
1276 }
1277 if val.chars().count() > 35 {
1278 return Err(ValidationError::new(
1279 1002,
1280 "prtry exceeds the maximum length of 35".to_string(),
1281 ));
1282 }
1283 }
1284 Ok(())
1285 }
1286}
1287
1288#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1290pub struct DiscountAmountType1Choice1 {
1291 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1292 pub cd: Option<String>,
1293 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1294 pub prtry: Option<String>,
1295}
1296
1297impl DiscountAmountType1Choice1 {
1298 pub fn validate(&self) -> Result<(), ValidationError> {
1299 if let Some(ref val) = self.cd {
1300 if val.chars().count() < 1 {
1301 return Err(ValidationError::new(
1302 1001,
1303 "cd is shorter than the minimum length of 1".to_string(),
1304 ));
1305 }
1306 if val.chars().count() > 4 {
1307 return Err(ValidationError::new(
1308 1002,
1309 "cd exceeds the maximum length of 4".to_string(),
1310 ));
1311 }
1312 }
1313 if let Some(ref val) = self.prtry {
1314 if val.chars().count() < 1 {
1315 return Err(ValidationError::new(
1316 1001,
1317 "prtry is shorter than the minimum length of 1".to_string(),
1318 ));
1319 }
1320 if val.chars().count() > 35 {
1321 return Err(ValidationError::new(
1322 1002,
1323 "prtry exceeds the maximum length of 35".to_string(),
1324 ));
1325 }
1326 let pattern = Regex::new(
1327 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1328 )
1329 .unwrap();
1330 if !pattern.is_match(val) {
1331 return Err(ValidationError::new(
1332 1005,
1333 "prtry does not match the required pattern".to_string(),
1334 ));
1335 }
1336 }
1337 Ok(())
1338 }
1339}
1340
1341#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1343pub struct DocumentAdjustment1 {
1344 #[serde(rename = "Amt")]
1345 pub amt: ActiveOrHistoricCurrencyAndAmount,
1346 #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1347 pub cdt_dbt_ind: Option<CreditDebitCode>,
1348 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1349 pub rsn: Option<String>,
1350 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1351 pub addtl_inf: Option<String>,
1352}
1353
1354impl DocumentAdjustment1 {
1355 pub fn validate(&self) -> Result<(), ValidationError> {
1356 self.amt.validate()?;
1357 if let Some(ref val) = self.cdt_dbt_ind {
1358 val.validate()?
1359 }
1360 if let Some(ref val) = self.rsn {
1361 if val.chars().count() < 1 {
1362 return Err(ValidationError::new(
1363 1001,
1364 "rsn is shorter than the minimum length of 1".to_string(),
1365 ));
1366 }
1367 if val.chars().count() > 4 {
1368 return Err(ValidationError::new(
1369 1002,
1370 "rsn exceeds the maximum length of 4".to_string(),
1371 ));
1372 }
1373 }
1374 if let Some(ref val) = self.addtl_inf {
1375 if val.chars().count() < 1 {
1376 return Err(ValidationError::new(
1377 1001,
1378 "addtl_inf is shorter than the minimum length of 1".to_string(),
1379 ));
1380 }
1381 if val.chars().count() > 140 {
1382 return Err(ValidationError::new(
1383 1002,
1384 "addtl_inf exceeds the maximum length of 140".to_string(),
1385 ));
1386 }
1387 }
1388 Ok(())
1389 }
1390}
1391
1392#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1394pub struct DocumentAdjustment11 {
1395 #[serde(rename = "Amt")]
1396 pub amt: ActiveOrHistoricCurrencyAndAmount,
1397 #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1398 pub cdt_dbt_ind: Option<CreditDebitCode>,
1399 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1400 pub rsn: Option<String>,
1401 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1402 pub addtl_inf: Option<String>,
1403}
1404
1405impl DocumentAdjustment11 {
1406 pub fn validate(&self) -> Result<(), ValidationError> {
1407 self.amt.validate()?;
1408 if let Some(ref val) = self.cdt_dbt_ind {
1409 val.validate()?
1410 }
1411 if let Some(ref val) = self.rsn {
1412 if val.chars().count() < 1 {
1413 return Err(ValidationError::new(
1414 1001,
1415 "rsn is shorter than the minimum length of 1".to_string(),
1416 ));
1417 }
1418 if val.chars().count() > 4 {
1419 return Err(ValidationError::new(
1420 1002,
1421 "rsn exceeds the maximum length of 4".to_string(),
1422 ));
1423 }
1424 let pattern = Regex::new(
1425 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1426 )
1427 .unwrap();
1428 if !pattern.is_match(val) {
1429 return Err(ValidationError::new(
1430 1005,
1431 "rsn does not match the required pattern".to_string(),
1432 ));
1433 }
1434 }
1435 if let Some(ref val) = self.addtl_inf {
1436 if val.chars().count() < 1 {
1437 return Err(ValidationError::new(
1438 1001,
1439 "addtl_inf is shorter than the minimum length of 1".to_string(),
1440 ));
1441 }
1442 if val.chars().count() > 140 {
1443 return Err(ValidationError::new(
1444 1002,
1445 "addtl_inf exceeds the maximum length of 140".to_string(),
1446 ));
1447 }
1448 let pattern = Regex::new(
1449 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1450 )
1451 .unwrap();
1452 if !pattern.is_match(val) {
1453 return Err(ValidationError::new(
1454 1005,
1455 "addtl_inf does not match the required pattern".to_string(),
1456 ));
1457 }
1458 }
1459 Ok(())
1460 }
1461}
1462
1463#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1465pub struct DocumentLineIdentification11 {
1466 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1467 pub tp: Option<DocumentLineType11>,
1468 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
1469 pub nb: Option<String>,
1470 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
1471 pub rltd_dt: Option<String>,
1472}
1473
1474impl DocumentLineIdentification11 {
1475 pub fn validate(&self) -> Result<(), ValidationError> {
1476 if let Some(ref val) = self.tp {
1477 val.validate()?
1478 }
1479 if let Some(ref val) = self.nb {
1480 if val.chars().count() < 1 {
1481 return Err(ValidationError::new(
1482 1001,
1483 "nb is shorter than the minimum length of 1".to_string(),
1484 ));
1485 }
1486 if val.chars().count() > 35 {
1487 return Err(ValidationError::new(
1488 1002,
1489 "nb exceeds the maximum length of 35".to_string(),
1490 ));
1491 }
1492 let pattern = Regex::new(
1493 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1494 )
1495 .unwrap();
1496 if !pattern.is_match(val) {
1497 return Err(ValidationError::new(
1498 1005,
1499 "nb does not match the required pattern".to_string(),
1500 ));
1501 }
1502 }
1503 Ok(())
1504 }
1505}
1506
1507#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1509pub struct DocumentLineInformation11 {
1510 #[serde(rename = "Id")]
1511 pub id: Vec<DocumentLineIdentification11>,
1512 #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
1513 pub desc: Option<String>,
1514 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
1515 pub amt: Option<RemittanceAmount31>,
1516}
1517
1518impl DocumentLineInformation11 {
1519 pub fn validate(&self) -> Result<(), ValidationError> {
1520 for item in &self.id {
1521 item.validate()?
1522 }
1523 if let Some(ref val) = self.desc {
1524 if val.chars().count() < 1 {
1525 return Err(ValidationError::new(
1526 1001,
1527 "desc is shorter than the minimum length of 1".to_string(),
1528 ));
1529 }
1530 if val.chars().count() > 35 {
1531 return Err(ValidationError::new(
1532 1002,
1533 "desc exceeds the maximum length of 35".to_string(),
1534 ));
1535 }
1536 let pattern = Regex::new(
1537 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1538 )
1539 .unwrap();
1540 if !pattern.is_match(val) {
1541 return Err(ValidationError::new(
1542 1005,
1543 "desc does not match the required pattern".to_string(),
1544 ));
1545 }
1546 }
1547 if let Some(ref val) = self.amt {
1548 val.validate()?
1549 }
1550 Ok(())
1551 }
1552}
1553
1554#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1556pub struct DocumentLineType1Choice1 {
1557 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1558 pub cd: Option<String>,
1559 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1560 pub prtry: Option<String>,
1561}
1562
1563impl DocumentLineType1Choice1 {
1564 pub fn validate(&self) -> Result<(), ValidationError> {
1565 if let Some(ref val) = self.cd {
1566 if val.chars().count() < 1 {
1567 return Err(ValidationError::new(
1568 1001,
1569 "cd is shorter than the minimum length of 1".to_string(),
1570 ));
1571 }
1572 if val.chars().count() > 4 {
1573 return Err(ValidationError::new(
1574 1002,
1575 "cd exceeds the maximum length of 4".to_string(),
1576 ));
1577 }
1578 }
1579 if let Some(ref val) = self.prtry {
1580 if val.chars().count() < 1 {
1581 return Err(ValidationError::new(
1582 1001,
1583 "prtry is shorter than the minimum length of 1".to_string(),
1584 ));
1585 }
1586 if val.chars().count() > 35 {
1587 return Err(ValidationError::new(
1588 1002,
1589 "prtry exceeds the maximum length of 35".to_string(),
1590 ));
1591 }
1592 let pattern = Regex::new(
1593 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1594 )
1595 .unwrap();
1596 if !pattern.is_match(val) {
1597 return Err(ValidationError::new(
1598 1005,
1599 "prtry does not match the required pattern".to_string(),
1600 ));
1601 }
1602 }
1603 Ok(())
1604 }
1605}
1606
1607#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1609pub struct DocumentLineType11 {
1610 #[serde(rename = "CdOrPrtry")]
1611 pub cd_or_prtry: DocumentLineType1Choice1,
1612 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1613 pub issr: Option<String>,
1614}
1615
1616impl DocumentLineType11 {
1617 pub fn validate(&self) -> Result<(), ValidationError> {
1618 self.cd_or_prtry.validate()?;
1619 if let Some(ref val) = self.issr {
1620 if val.chars().count() < 1 {
1621 return Err(ValidationError::new(
1622 1001,
1623 "issr is shorter than the minimum length of 1".to_string(),
1624 ));
1625 }
1626 if val.chars().count() > 35 {
1627 return Err(ValidationError::new(
1628 1002,
1629 "issr exceeds the maximum length of 35".to_string(),
1630 ));
1631 }
1632 let pattern = Regex::new(
1633 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1634 )
1635 .unwrap();
1636 if !pattern.is_match(val) {
1637 return Err(ValidationError::new(
1638 1005,
1639 "issr does not match the required pattern".to_string(),
1640 ));
1641 }
1642 }
1643 Ok(())
1644 }
1645}
1646
1647#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1649pub enum DocumentType3Code {
1650 #[default]
1651 #[serde(rename = "RADM")]
1652 CodeRADM,
1653 #[serde(rename = "RPIN")]
1654 CodeRPIN,
1655 #[serde(rename = "FXDR")]
1656 CodeFXDR,
1657 #[serde(rename = "DISP")]
1658 CodeDISP,
1659 #[serde(rename = "PUOR")]
1660 CodePUOR,
1661 #[serde(rename = "SCOR")]
1662 CodeSCOR,
1663}
1664
1665impl DocumentType3Code {
1666 pub fn validate(&self) -> Result<(), ValidationError> {
1667 Ok(())
1668 }
1669}
1670
1671#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1673pub enum DocumentType6Code {
1674 #[default]
1675 #[serde(rename = "MSIN")]
1676 CodeMSIN,
1677 #[serde(rename = "CNFA")]
1678 CodeCNFA,
1679 #[serde(rename = "DNFA")]
1680 CodeDNFA,
1681 #[serde(rename = "CINV")]
1682 CodeCINV,
1683 #[serde(rename = "CREN")]
1684 CodeCREN,
1685 #[serde(rename = "DEBN")]
1686 CodeDEBN,
1687 #[serde(rename = "HIRI")]
1688 CodeHIRI,
1689 #[serde(rename = "SBIN")]
1690 CodeSBIN,
1691 #[serde(rename = "CMCN")]
1692 CodeCMCN,
1693 #[serde(rename = "SOAC")]
1694 CodeSOAC,
1695 #[serde(rename = "DISP")]
1696 CodeDISP,
1697 #[serde(rename = "BOLD")]
1698 CodeBOLD,
1699 #[serde(rename = "VCHR")]
1700 CodeVCHR,
1701 #[serde(rename = "AROI")]
1702 CodeAROI,
1703 #[serde(rename = "TSUT")]
1704 CodeTSUT,
1705 #[serde(rename = "PUOR")]
1706 CodePUOR,
1707}
1708
1709impl DocumentType6Code {
1710 pub fn validate(&self) -> Result<(), ValidationError> {
1711 Ok(())
1712 }
1713}
1714
1715#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1717pub struct FIToFICustomerDirectDebitV08 {
1718 #[serde(rename = "GrpHdr")]
1719 pub grp_hdr: GroupHeader941,
1720 #[serde(rename = "DrctDbtTxInf")]
1721 pub drct_dbt_tx_inf: DirectDebitTransactionInformation241,
1722}
1723
1724impl FIToFICustomerDirectDebitV08 {
1725 pub fn validate(&self) -> Result<(), ValidationError> {
1726 self.grp_hdr.validate()?;
1727 self.drct_dbt_tx_inf.validate()?;
1728 Ok(())
1729 }
1730}
1731
1732#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1734pub struct FinancialInstitutionIdentification181 {
1735 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1736 pub bicfi: Option<String>,
1737 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1738 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
1739 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1740 pub lei: Option<String>,
1741 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1742 pub nm: Option<String>,
1743 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1744 pub pstl_adr: Option<PostalAddress241>,
1745}
1746
1747impl FinancialInstitutionIdentification181 {
1748 pub fn validate(&self) -> Result<(), ValidationError> {
1749 if let Some(ref val) = self.bicfi {
1750 let pattern =
1751 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1752 if !pattern.is_match(val) {
1753 return Err(ValidationError::new(
1754 1005,
1755 "bicfi does not match the required pattern".to_string(),
1756 ));
1757 }
1758 }
1759 if let Some(ref val) = self.clr_sys_mmb_id {
1760 val.validate()?
1761 }
1762 if let Some(ref val) = self.lei {
1763 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1764 if !pattern.is_match(val) {
1765 return Err(ValidationError::new(
1766 1005,
1767 "lei does not match the required pattern".to_string(),
1768 ));
1769 }
1770 }
1771 if let Some(ref val) = self.nm {
1772 if val.chars().count() < 1 {
1773 return Err(ValidationError::new(
1774 1001,
1775 "nm is shorter than the minimum length of 1".to_string(),
1776 ));
1777 }
1778 if val.chars().count() > 140 {
1779 return Err(ValidationError::new(
1780 1002,
1781 "nm exceeds the maximum length of 140".to_string(),
1782 ));
1783 }
1784 let pattern = Regex::new(
1785 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1786 )
1787 .unwrap();
1788 if !pattern.is_match(val) {
1789 return Err(ValidationError::new(
1790 1005,
1791 "nm does not match the required pattern".to_string(),
1792 ));
1793 }
1794 }
1795 if let Some(ref val) = self.pstl_adr {
1796 val.validate()?
1797 }
1798 Ok(())
1799 }
1800}
1801
1802#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1804pub struct FinancialInstitutionIdentification182 {
1805 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1806 pub bicfi: Option<String>,
1807 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1808 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
1809 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1810 pub lei: Option<String>,
1811}
1812
1813impl FinancialInstitutionIdentification182 {
1814 pub fn validate(&self) -> Result<(), ValidationError> {
1815 if let Some(ref val) = self.bicfi {
1816 let pattern =
1817 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1818 if !pattern.is_match(val) {
1819 return Err(ValidationError::new(
1820 1005,
1821 "bicfi does not match the required pattern".to_string(),
1822 ));
1823 }
1824 }
1825 if let Some(ref val) = self.clr_sys_mmb_id {
1826 val.validate()?
1827 }
1828 if let Some(ref val) = self.lei {
1829 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1830 if !pattern.is_match(val) {
1831 return Err(ValidationError::new(
1832 1005,
1833 "lei does not match the required pattern".to_string(),
1834 ));
1835 }
1836 }
1837 Ok(())
1838 }
1839}
1840
1841#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1843pub struct FinancialInstitutionIdentification183 {
1844 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1845 pub bicfi: Option<String>,
1846 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1847 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
1848 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1849 pub lei: Option<String>,
1850 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1851 pub nm: Option<String>,
1852 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1853 pub pstl_adr: Option<PostalAddress244>,
1854}
1855
1856impl FinancialInstitutionIdentification183 {
1857 pub fn validate(&self) -> Result<(), ValidationError> {
1858 if let Some(ref val) = self.bicfi {
1859 let pattern =
1860 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1861 if !pattern.is_match(val) {
1862 return Err(ValidationError::new(
1863 1005,
1864 "bicfi does not match the required pattern".to_string(),
1865 ));
1866 }
1867 }
1868 if let Some(ref val) = self.clr_sys_mmb_id {
1869 val.validate()?
1870 }
1871 if let Some(ref val) = self.lei {
1872 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1873 if !pattern.is_match(val) {
1874 return Err(ValidationError::new(
1875 1005,
1876 "lei does not match the required pattern".to_string(),
1877 ));
1878 }
1879 }
1880 if let Some(ref val) = self.nm {
1881 if val.chars().count() < 1 {
1882 return Err(ValidationError::new(
1883 1001,
1884 "nm is shorter than the minimum length of 1".to_string(),
1885 ));
1886 }
1887 if val.chars().count() > 140 {
1888 return Err(ValidationError::new(
1889 1002,
1890 "nm exceeds the maximum length of 140".to_string(),
1891 ));
1892 }
1893 let pattern = Regex::new(
1894 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1895 )
1896 .unwrap();
1897 if !pattern.is_match(val) {
1898 return Err(ValidationError::new(
1899 1005,
1900 "nm does not match the required pattern".to_string(),
1901 ));
1902 }
1903 }
1904 if let Some(ref val) = self.pstl_adr {
1905 val.validate()?
1906 }
1907 Ok(())
1908 }
1909}
1910
1911#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1913pub struct Frequency36Choice {
1914 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1915 pub tp: Option<Frequency6Code>,
1916 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
1917 pub prd: Option<FrequencyPeriod1>,
1918 #[serde(rename = "PtInTm", skip_serializing_if = "Option::is_none")]
1919 pub pt_in_tm: Option<FrequencyAndMoment1>,
1920}
1921
1922impl Frequency36Choice {
1923 pub fn validate(&self) -> Result<(), ValidationError> {
1924 if let Some(ref val) = self.tp {
1925 val.validate()?
1926 }
1927 if let Some(ref val) = self.prd {
1928 val.validate()?
1929 }
1930 if let Some(ref val) = self.pt_in_tm {
1931 val.validate()?
1932 }
1933 Ok(())
1934 }
1935}
1936
1937#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1939pub enum Frequency6Code {
1940 #[default]
1941 #[serde(rename = "YEAR")]
1942 CodeYEAR,
1943 #[serde(rename = "MNTH")]
1944 CodeMNTH,
1945 #[serde(rename = "QURT")]
1946 CodeQURT,
1947 #[serde(rename = "MIAN")]
1948 CodeMIAN,
1949 #[serde(rename = "WEEK")]
1950 CodeWEEK,
1951 #[serde(rename = "DAIL")]
1952 CodeDAIL,
1953 #[serde(rename = "ADHO")]
1954 CodeADHO,
1955 #[serde(rename = "INDA")]
1956 CodeINDA,
1957 #[serde(rename = "FRTN")]
1958 CodeFRTN,
1959}
1960
1961impl Frequency6Code {
1962 pub fn validate(&self) -> Result<(), ValidationError> {
1963 Ok(())
1964 }
1965}
1966
1967#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1969pub struct FrequencyAndMoment1 {
1970 #[serde(rename = "Tp")]
1971 pub tp: Frequency6Code,
1972 #[serde(rename = "PtInTm")]
1973 pub pt_in_tm: String,
1974}
1975
1976impl FrequencyAndMoment1 {
1977 pub fn validate(&self) -> Result<(), ValidationError> {
1978 self.tp.validate()?;
1979 let pattern = Regex::new("[0-9]{2}").unwrap();
1980 if !pattern.is_match(&self.pt_in_tm) {
1981 return Err(ValidationError::new(
1982 1005,
1983 "pt_in_tm does not match the required pattern".to_string(),
1984 ));
1985 }
1986 Ok(())
1987 }
1988}
1989
1990#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1992pub struct FrequencyPeriod1 {
1993 #[serde(rename = "Tp")]
1994 pub tp: Frequency6Code,
1995 #[serde(rename = "CntPerPrd")]
1996 pub cnt_per_prd: f64,
1997}
1998
1999impl FrequencyPeriod1 {
2000 pub fn validate(&self) -> Result<(), ValidationError> {
2001 self.tp.validate()?;
2002 Ok(())
2003 }
2004}
2005
2006#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2008pub struct Garnishment31 {
2009 #[serde(rename = "Tp")]
2010 pub tp: GarnishmentType11,
2011 #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
2012 pub grnshee: Option<PartyIdentification1356>,
2013 #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
2014 pub grnshmt_admstr: Option<PartyIdentification1357>,
2015 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
2016 pub ref_nb: Option<String>,
2017 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
2018 pub dt: Option<String>,
2019 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
2020 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
2021 #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
2022 pub fmly_mdcl_insrnc_ind: Option<bool>,
2023 #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
2024 pub mplyee_termntn_ind: Option<bool>,
2025}
2026
2027impl Garnishment31 {
2028 pub fn validate(&self) -> Result<(), ValidationError> {
2029 self.tp.validate()?;
2030 if let Some(ref val) = self.grnshee {
2031 val.validate()?
2032 }
2033 if let Some(ref val) = self.grnshmt_admstr {
2034 val.validate()?
2035 }
2036 if let Some(ref val) = self.ref_nb {
2037 if val.chars().count() < 1 {
2038 return Err(ValidationError::new(
2039 1001,
2040 "ref_nb is shorter than the minimum length of 1".to_string(),
2041 ));
2042 }
2043 if val.chars().count() > 140 {
2044 return Err(ValidationError::new(
2045 1002,
2046 "ref_nb exceeds the maximum length of 140".to_string(),
2047 ));
2048 }
2049 let pattern = Regex::new(
2050 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2051 )
2052 .unwrap();
2053 if !pattern.is_match(val) {
2054 return Err(ValidationError::new(
2055 1005,
2056 "ref_nb does not match the required pattern".to_string(),
2057 ));
2058 }
2059 }
2060 if let Some(ref val) = self.rmtd_amt {
2061 val.validate()?
2062 }
2063 Ok(())
2064 }
2065}
2066
2067#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2069pub struct GarnishmentType1Choice {
2070 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2071 pub cd: Option<String>,
2072 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2073 pub prtry: Option<String>,
2074}
2075
2076impl GarnishmentType1Choice {
2077 pub fn validate(&self) -> Result<(), ValidationError> {
2078 if let Some(ref val) = self.cd {
2079 if val.chars().count() < 1 {
2080 return Err(ValidationError::new(
2081 1001,
2082 "cd is shorter than the minimum length of 1".to_string(),
2083 ));
2084 }
2085 if val.chars().count() > 4 {
2086 return Err(ValidationError::new(
2087 1002,
2088 "cd exceeds the maximum length of 4".to_string(),
2089 ));
2090 }
2091 }
2092 if let Some(ref val) = self.prtry {
2093 if val.chars().count() < 1 {
2094 return Err(ValidationError::new(
2095 1001,
2096 "prtry is shorter than the minimum length of 1".to_string(),
2097 ));
2098 }
2099 if val.chars().count() > 35 {
2100 return Err(ValidationError::new(
2101 1002,
2102 "prtry exceeds the maximum length of 35".to_string(),
2103 ));
2104 }
2105 }
2106 Ok(())
2107 }
2108}
2109
2110#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2112pub struct GarnishmentType11 {
2113 #[serde(rename = "CdOrPrtry")]
2114 pub cd_or_prtry: GarnishmentType1Choice,
2115 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2116 pub issr: Option<String>,
2117}
2118
2119impl GarnishmentType11 {
2120 pub fn validate(&self) -> Result<(), ValidationError> {
2121 self.cd_or_prtry.validate()?;
2122 if let Some(ref val) = self.issr {
2123 if val.chars().count() < 1 {
2124 return Err(ValidationError::new(
2125 1001,
2126 "issr is shorter than the minimum length of 1".to_string(),
2127 ));
2128 }
2129 if val.chars().count() > 35 {
2130 return Err(ValidationError::new(
2131 1002,
2132 "issr exceeds the maximum length of 35".to_string(),
2133 ));
2134 }
2135 let pattern = Regex::new(
2136 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2137 )
2138 .unwrap();
2139 if !pattern.is_match(val) {
2140 return Err(ValidationError::new(
2141 1005,
2142 "issr does not match the required pattern".to_string(),
2143 ));
2144 }
2145 }
2146 Ok(())
2147 }
2148}
2149
2150#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2152pub struct GenericAccountIdentification11 {
2153 #[serde(rename = "Id")]
2154 pub id: String,
2155 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2156 pub schme_nm: Option<AccountSchemeName1Choice>,
2157 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2158 pub issr: Option<String>,
2159}
2160
2161impl GenericAccountIdentification11 {
2162 pub fn validate(&self) -> Result<(), ValidationError> {
2163 if self.id.chars().count() < 1 {
2164 return Err(ValidationError::new(
2165 1001,
2166 "id is shorter than the minimum length of 1".to_string(),
2167 ));
2168 }
2169 if self.id.chars().count() > 34 {
2170 return Err(ValidationError::new(
2171 1002,
2172 "id exceeds the maximum length of 34".to_string(),
2173 ));
2174 }
2175 let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
2176 if !pattern.is_match(&self.id) {
2177 return Err(ValidationError::new(
2178 1005,
2179 "id does not match the required pattern".to_string(),
2180 ));
2181 }
2182 if let Some(ref val) = self.schme_nm {
2183 val.validate()?
2184 }
2185 if let Some(ref val) = self.issr {
2186 if val.chars().count() < 1 {
2187 return Err(ValidationError::new(
2188 1001,
2189 "issr is shorter than the minimum length of 1".to_string(),
2190 ));
2191 }
2192 if val.chars().count() > 35 {
2193 return Err(ValidationError::new(
2194 1002,
2195 "issr exceeds the maximum length of 35".to_string(),
2196 ));
2197 }
2198 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2199 if !pattern.is_match(val) {
2200 return Err(ValidationError::new(
2201 1005,
2202 "issr does not match the required pattern".to_string(),
2203 ));
2204 }
2205 }
2206 Ok(())
2207 }
2208}
2209
2210#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2212pub struct GenericAccountIdentification12 {
2213 #[serde(rename = "Id")]
2214 pub id: String,
2215 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2216 pub schme_nm: Option<AccountSchemeName1Choice1>,
2217 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2218 pub issr: Option<String>,
2219}
2220
2221impl GenericAccountIdentification12 {
2222 pub fn validate(&self) -> Result<(), ValidationError> {
2223 if self.id.chars().count() < 1 {
2224 return Err(ValidationError::new(
2225 1001,
2226 "id is shorter than the minimum length of 1".to_string(),
2227 ));
2228 }
2229 if self.id.chars().count() > 34 {
2230 return Err(ValidationError::new(
2231 1002,
2232 "id exceeds the maximum length of 34".to_string(),
2233 ));
2234 }
2235 let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
2236 if !pattern.is_match(&self.id) {
2237 return Err(ValidationError::new(
2238 1005,
2239 "id does not match the required pattern".to_string(),
2240 ));
2241 }
2242 if let Some(ref val) = self.schme_nm {
2243 val.validate()?
2244 }
2245 if let Some(ref val) = self.issr {
2246 if val.chars().count() < 1 {
2247 return Err(ValidationError::new(
2248 1001,
2249 "issr is shorter than the minimum length of 1".to_string(),
2250 ));
2251 }
2252 if val.chars().count() > 35 {
2253 return Err(ValidationError::new(
2254 1002,
2255 "issr exceeds the maximum length of 35".to_string(),
2256 ));
2257 }
2258 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2259 if !pattern.is_match(val) {
2260 return Err(ValidationError::new(
2261 1005,
2262 "issr does not match the required pattern".to_string(),
2263 ));
2264 }
2265 }
2266 Ok(())
2267 }
2268}
2269
2270#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2272pub struct GenericOrganisationIdentification11 {
2273 #[serde(rename = "Id")]
2274 pub id: String,
2275 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2276 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
2277 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2278 pub issr: Option<String>,
2279}
2280
2281impl GenericOrganisationIdentification11 {
2282 pub fn validate(&self) -> Result<(), ValidationError> {
2283 if self.id.chars().count() < 1 {
2284 return Err(ValidationError::new(
2285 1001,
2286 "id is shorter than the minimum length of 1".to_string(),
2287 ));
2288 }
2289 if self.id.chars().count() > 35 {
2290 return Err(ValidationError::new(
2291 1002,
2292 "id exceeds the maximum length of 35".to_string(),
2293 ));
2294 }
2295 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2296 if !pattern.is_match(&self.id) {
2297 return Err(ValidationError::new(
2298 1005,
2299 "id does not match the required pattern".to_string(),
2300 ));
2301 }
2302 if let Some(ref val) = self.schme_nm {
2303 val.validate()?
2304 }
2305 if let Some(ref val) = self.issr {
2306 if val.chars().count() < 1 {
2307 return Err(ValidationError::new(
2308 1001,
2309 "issr is shorter than the minimum length of 1".to_string(),
2310 ));
2311 }
2312 if val.chars().count() > 35 {
2313 return Err(ValidationError::new(
2314 1002,
2315 "issr exceeds the maximum length of 35".to_string(),
2316 ));
2317 }
2318 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2319 if !pattern.is_match(val) {
2320 return Err(ValidationError::new(
2321 1005,
2322 "issr does not match the required pattern".to_string(),
2323 ));
2324 }
2325 }
2326 Ok(())
2327 }
2328}
2329
2330#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2332pub struct GenericOrganisationIdentification12 {
2333 #[serde(rename = "Id")]
2334 pub id: String,
2335 #[serde(rename = "SchmeNm")]
2336 pub schme_nm: OrganisationIdentificationSchemeName1Choice2,
2337 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2338 pub issr: Option<String>,
2339}
2340
2341impl GenericOrganisationIdentification12 {
2342 pub fn validate(&self) -> Result<(), ValidationError> {
2343 if self.id.chars().count() < 1 {
2344 return Err(ValidationError::new(
2345 1001,
2346 "id is shorter than the minimum length of 1".to_string(),
2347 ));
2348 }
2349 if self.id.chars().count() > 35 {
2350 return Err(ValidationError::new(
2351 1002,
2352 "id exceeds the maximum length of 35".to_string(),
2353 ));
2354 }
2355 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2356 if !pattern.is_match(&self.id) {
2357 return Err(ValidationError::new(
2358 1005,
2359 "id does not match the required pattern".to_string(),
2360 ));
2361 }
2362 self.schme_nm.validate()?;
2363 if let Some(ref val) = self.issr {
2364 if val.chars().count() < 1 {
2365 return Err(ValidationError::new(
2366 1001,
2367 "issr is shorter than the minimum length of 1".to_string(),
2368 ));
2369 }
2370 if val.chars().count() > 35 {
2371 return Err(ValidationError::new(
2372 1002,
2373 "issr exceeds the maximum length of 35".to_string(),
2374 ));
2375 }
2376 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2377 if !pattern.is_match(val) {
2378 return Err(ValidationError::new(
2379 1005,
2380 "issr does not match the required pattern".to_string(),
2381 ));
2382 }
2383 }
2384 Ok(())
2385 }
2386}
2387
2388#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2390pub struct GenericOrganisationIdentification13 {
2391 #[serde(rename = "Id")]
2392 pub id: String,
2393 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2394 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice3>,
2395 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2396 pub issr: Option<String>,
2397}
2398
2399impl GenericOrganisationIdentification13 {
2400 pub fn validate(&self) -> Result<(), ValidationError> {
2401 if self.id.chars().count() < 1 {
2402 return Err(ValidationError::new(
2403 1001,
2404 "id is shorter than the minimum length of 1".to_string(),
2405 ));
2406 }
2407 if self.id.chars().count() > 35 {
2408 return Err(ValidationError::new(
2409 1002,
2410 "id exceeds the maximum length of 35".to_string(),
2411 ));
2412 }
2413 let pattern =
2414 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
2415 .unwrap();
2416 if !pattern.is_match(&self.id) {
2417 return Err(ValidationError::new(
2418 1005,
2419 "id does not match the required pattern".to_string(),
2420 ));
2421 }
2422 if let Some(ref val) = self.schme_nm {
2423 val.validate()?
2424 }
2425 if let Some(ref val) = self.issr {
2426 if val.chars().count() < 1 {
2427 return Err(ValidationError::new(
2428 1001,
2429 "issr is shorter than the minimum length of 1".to_string(),
2430 ));
2431 }
2432 if val.chars().count() > 35 {
2433 return Err(ValidationError::new(
2434 1002,
2435 "issr exceeds the maximum length of 35".to_string(),
2436 ));
2437 }
2438 let pattern = Regex::new(
2439 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2440 )
2441 .unwrap();
2442 if !pattern.is_match(val) {
2443 return Err(ValidationError::new(
2444 1005,
2445 "issr does not match the required pattern".to_string(),
2446 ));
2447 }
2448 }
2449 Ok(())
2450 }
2451}
2452
2453#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2455pub struct GenericPersonIdentification11 {
2456 #[serde(rename = "Id")]
2457 pub id: String,
2458 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2459 pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
2460 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2461 pub issr: Option<String>,
2462}
2463
2464impl GenericPersonIdentification11 {
2465 pub fn validate(&self) -> Result<(), ValidationError> {
2466 if self.id.chars().count() < 1 {
2467 return Err(ValidationError::new(
2468 1001,
2469 "id is shorter than the minimum length of 1".to_string(),
2470 ));
2471 }
2472 if self.id.chars().count() > 35 {
2473 return Err(ValidationError::new(
2474 1002,
2475 "id exceeds the maximum length of 35".to_string(),
2476 ));
2477 }
2478 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2479 if !pattern.is_match(&self.id) {
2480 return Err(ValidationError::new(
2481 1005,
2482 "id does not match the required pattern".to_string(),
2483 ));
2484 }
2485 if let Some(ref val) = self.schme_nm {
2486 val.validate()?
2487 }
2488 if let Some(ref val) = self.issr {
2489 if val.chars().count() < 1 {
2490 return Err(ValidationError::new(
2491 1001,
2492 "issr is shorter than the minimum length of 1".to_string(),
2493 ));
2494 }
2495 if val.chars().count() > 35 {
2496 return Err(ValidationError::new(
2497 1002,
2498 "issr exceeds the maximum length of 35".to_string(),
2499 ));
2500 }
2501 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2502 if !pattern.is_match(val) {
2503 return Err(ValidationError::new(
2504 1005,
2505 "issr does not match the required pattern".to_string(),
2506 ));
2507 }
2508 }
2509 Ok(())
2510 }
2511}
2512
2513#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2515pub struct GenericPersonIdentification12 {
2516 #[serde(rename = "Id")]
2517 pub id: String,
2518 #[serde(rename = "SchmeNm")]
2519 pub schme_nm: PersonIdentificationSchemeName1Choice2,
2520 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2521 pub issr: Option<String>,
2522}
2523
2524impl GenericPersonIdentification12 {
2525 pub fn validate(&self) -> Result<(), ValidationError> {
2526 if self.id.chars().count() < 1 {
2527 return Err(ValidationError::new(
2528 1001,
2529 "id is shorter than the minimum length of 1".to_string(),
2530 ));
2531 }
2532 if self.id.chars().count() > 35 {
2533 return Err(ValidationError::new(
2534 1002,
2535 "id exceeds the maximum length of 35".to_string(),
2536 ));
2537 }
2538 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2539 if !pattern.is_match(&self.id) {
2540 return Err(ValidationError::new(
2541 1005,
2542 "id does not match the required pattern".to_string(),
2543 ));
2544 }
2545 self.schme_nm.validate()?;
2546 if let Some(ref val) = self.issr {
2547 if val.chars().count() < 1 {
2548 return Err(ValidationError::new(
2549 1001,
2550 "issr is shorter than the minimum length of 1".to_string(),
2551 ));
2552 }
2553 if val.chars().count() > 35 {
2554 return Err(ValidationError::new(
2555 1002,
2556 "issr exceeds the maximum length of 35".to_string(),
2557 ));
2558 }
2559 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2560 if !pattern.is_match(val) {
2561 return Err(ValidationError::new(
2562 1005,
2563 "issr does not match the required pattern".to_string(),
2564 ));
2565 }
2566 }
2567 Ok(())
2568 }
2569}
2570
2571#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2573pub struct GenericPersonIdentification13 {
2574 #[serde(rename = "Id")]
2575 pub id: String,
2576 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
2577 pub schme_nm: Option<PersonIdentificationSchemeName1Choice3>,
2578 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
2579 pub issr: Option<String>,
2580}
2581
2582impl GenericPersonIdentification13 {
2583 pub fn validate(&self) -> Result<(), ValidationError> {
2584 if self.id.chars().count() < 1 {
2585 return Err(ValidationError::new(
2586 1001,
2587 "id is shorter than the minimum length of 1".to_string(),
2588 ));
2589 }
2590 if self.id.chars().count() > 35 {
2591 return Err(ValidationError::new(
2592 1002,
2593 "id exceeds the maximum length of 35".to_string(),
2594 ));
2595 }
2596 let pattern =
2597 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
2598 .unwrap();
2599 if !pattern.is_match(&self.id) {
2600 return Err(ValidationError::new(
2601 1005,
2602 "id does not match the required pattern".to_string(),
2603 ));
2604 }
2605 if let Some(ref val) = self.schme_nm {
2606 val.validate()?
2607 }
2608 if let Some(ref val) = self.issr {
2609 if val.chars().count() < 1 {
2610 return Err(ValidationError::new(
2611 1001,
2612 "issr is shorter than the minimum length of 1".to_string(),
2613 ));
2614 }
2615 if val.chars().count() > 35 {
2616 return Err(ValidationError::new(
2617 1002,
2618 "issr exceeds the maximum length of 35".to_string(),
2619 ));
2620 }
2621 let pattern = Regex::new(
2622 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
2623 )
2624 .unwrap();
2625 if !pattern.is_match(val) {
2626 return Err(ValidationError::new(
2627 1005,
2628 "issr does not match the required pattern".to_string(),
2629 ));
2630 }
2631 }
2632 Ok(())
2633 }
2634}
2635
2636#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2638pub struct GroupHeader941 {
2639 #[serde(rename = "MsgId")]
2640 pub msg_id: String,
2641 #[serde(rename = "CreDtTm")]
2642 pub cre_dt_tm: String,
2643 #[serde(rename = "NbOfTxs")]
2644 pub nb_of_txs: Max15NumericTextfixed,
2645 #[serde(rename = "SttlmInf")]
2646 pub sttlm_inf: SettlementInstruction81,
2647}
2648
2649impl GroupHeader941 {
2650 pub fn validate(&self) -> Result<(), ValidationError> {
2651 if self.msg_id.chars().count() < 1 {
2652 return Err(ValidationError::new(
2653 1001,
2654 "msg_id is shorter than the minimum length of 1".to_string(),
2655 ));
2656 }
2657 if self.msg_id.chars().count() > 35 {
2658 return Err(ValidationError::new(
2659 1002,
2660 "msg_id exceeds the maximum length of 35".to_string(),
2661 ));
2662 }
2663 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2664 if !pattern.is_match(&self.msg_id) {
2665 return Err(ValidationError::new(
2666 1005,
2667 "msg_id does not match the required pattern".to_string(),
2668 ));
2669 }
2670 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
2671 if !pattern.is_match(&self.cre_dt_tm) {
2672 return Err(ValidationError::new(
2673 1005,
2674 "cre_dt_tm does not match the required pattern".to_string(),
2675 ));
2676 }
2677 self.nb_of_txs.validate()?;
2678 self.sttlm_inf.validate()?;
2679 Ok(())
2680 }
2681}
2682
2683#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2685pub struct LocalInstrument2Choice1 {
2686 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2687 pub cd: Option<String>,
2688 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2689 pub prtry: Option<String>,
2690}
2691
2692impl LocalInstrument2Choice1 {
2693 pub fn validate(&self) -> Result<(), ValidationError> {
2694 if let Some(ref val) = self.cd {
2695 if val.chars().count() < 1 {
2696 return Err(ValidationError::new(
2697 1001,
2698 "cd is shorter than the minimum length of 1".to_string(),
2699 ));
2700 }
2701 if val.chars().count() > 35 {
2702 return Err(ValidationError::new(
2703 1002,
2704 "cd exceeds the maximum length of 35".to_string(),
2705 ));
2706 }
2707 }
2708 if let Some(ref val) = self.prtry {
2709 if val.chars().count() < 1 {
2710 return Err(ValidationError::new(
2711 1001,
2712 "prtry is shorter than the minimum length of 1".to_string(),
2713 ));
2714 }
2715 if val.chars().count() > 35 {
2716 return Err(ValidationError::new(
2717 1002,
2718 "prtry exceeds the maximum length of 35".to_string(),
2719 ));
2720 }
2721 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2722 if !pattern.is_match(val) {
2723 return Err(ValidationError::new(
2724 1005,
2725 "prtry does not match the required pattern".to_string(),
2726 ));
2727 }
2728 }
2729 Ok(())
2730 }
2731}
2732
2733#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2735pub struct MandateRelatedInformation141 {
2736 #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
2737 pub mndt_id: Option<String>,
2738 #[serde(rename = "DtOfSgntr", skip_serializing_if = "Option::is_none")]
2739 pub dt_of_sgntr: Option<String>,
2740 #[serde(rename = "AmdmntInd", skip_serializing_if = "Option::is_none")]
2741 pub amdmnt_ind: Option<bool>,
2742 #[serde(rename = "AmdmntInfDtls", skip_serializing_if = "Option::is_none")]
2743 pub amdmnt_inf_dtls: Option<AmendmentInformationDetails131>,
2744 #[serde(rename = "ElctrncSgntr", skip_serializing_if = "Option::is_none")]
2745 pub elctrnc_sgntr: Option<String>,
2746 #[serde(rename = "FrstColltnDt", skip_serializing_if = "Option::is_none")]
2747 pub frst_colltn_dt: Option<String>,
2748 #[serde(rename = "FnlColltnDt", skip_serializing_if = "Option::is_none")]
2749 pub fnl_colltn_dt: Option<String>,
2750 #[serde(rename = "Frqcy", skip_serializing_if = "Option::is_none")]
2751 pub frqcy: Option<Frequency36Choice>,
2752 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
2753 pub rsn: Option<MandateSetupReason1Choice1>,
2754 #[serde(rename = "TrckgDays", skip_serializing_if = "Option::is_none")]
2755 pub trckg_days: Option<String>,
2756}
2757
2758impl MandateRelatedInformation141 {
2759 pub fn validate(&self) -> Result<(), ValidationError> {
2760 if let Some(ref val) = self.mndt_id {
2761 if val.chars().count() < 1 {
2762 return Err(ValidationError::new(
2763 1001,
2764 "mndt_id is shorter than the minimum length of 1".to_string(),
2765 ));
2766 }
2767 if val.chars().count() > 35 {
2768 return Err(ValidationError::new(
2769 1002,
2770 "mndt_id exceeds the maximum length of 35".to_string(),
2771 ));
2772 }
2773 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2774 if !pattern.is_match(val) {
2775 return Err(ValidationError::new(
2776 1005,
2777 "mndt_id does not match the required pattern".to_string(),
2778 ));
2779 }
2780 }
2781 if let Some(ref val) = self.amdmnt_inf_dtls {
2782 val.validate()?
2783 }
2784 if let Some(ref val) = self.elctrnc_sgntr {
2785 if val.chars().count() < 1 {
2786 return Err(ValidationError::new(
2787 1001,
2788 "elctrnc_sgntr is shorter than the minimum length of 1".to_string(),
2789 ));
2790 }
2791 if val.chars().count() > 1025 {
2792 return Err(ValidationError::new(
2793 1002,
2794 "elctrnc_sgntr exceeds the maximum length of 1025".to_string(),
2795 ));
2796 }
2797 }
2798 if let Some(ref val) = self.frqcy {
2799 val.validate()?
2800 }
2801 if let Some(ref val) = self.rsn {
2802 val.validate()?
2803 }
2804 if let Some(ref val) = self.trckg_days {
2805 let pattern = Regex::new("[0-9]{2}").unwrap();
2806 if !pattern.is_match(val) {
2807 return Err(ValidationError::new(
2808 1005,
2809 "trckg_days does not match the required pattern".to_string(),
2810 ));
2811 }
2812 }
2813 Ok(())
2814 }
2815}
2816
2817#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2819pub struct MandateSetupReason1Choice1 {
2820 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2821 pub cd: Option<String>,
2822 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2823 pub prtry: Option<String>,
2824}
2825
2826impl MandateSetupReason1Choice1 {
2827 pub fn validate(&self) -> Result<(), ValidationError> {
2828 if let Some(ref val) = self.cd {
2829 if val.chars().count() < 1 {
2830 return Err(ValidationError::new(
2831 1001,
2832 "cd is shorter than the minimum length of 1".to_string(),
2833 ));
2834 }
2835 if val.chars().count() > 4 {
2836 return Err(ValidationError::new(
2837 1002,
2838 "cd exceeds the maximum length of 4".to_string(),
2839 ));
2840 }
2841 }
2842 if let Some(ref val) = self.prtry {
2843 if val.chars().count() < 1 {
2844 return Err(ValidationError::new(
2845 1001,
2846 "prtry is shorter than the minimum length of 1".to_string(),
2847 ));
2848 }
2849 if val.chars().count() > 70 {
2850 return Err(ValidationError::new(
2851 1002,
2852 "prtry exceeds the maximum length of 70".to_string(),
2853 ));
2854 }
2855 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
2856 if !pattern.is_match(val) {
2857 return Err(ValidationError::new(
2858 1005,
2859 "prtry does not match the required pattern".to_string(),
2860 ));
2861 }
2862 }
2863 Ok(())
2864 }
2865}
2866
2867#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2869pub enum Max15NumericTextfixed {
2870 #[default]
2871 #[serde(rename = "1")]
2872 Code1,
2873}
2874
2875impl Max15NumericTextfixed {
2876 pub fn validate(&self) -> Result<(), ValidationError> {
2877 Ok(())
2878 }
2879}
2880
2881#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2883pub struct NameAndAddress161 {
2884 #[serde(rename = "Nm")]
2885 pub nm: String,
2886 #[serde(rename = "Adr")]
2887 pub adr: PostalAddress241,
2888}
2889
2890impl NameAndAddress161 {
2891 pub fn validate(&self) -> Result<(), ValidationError> {
2892 if self.nm.chars().count() < 1 {
2893 return Err(ValidationError::new(
2894 1001,
2895 "nm is shorter than the minimum length of 1".to_string(),
2896 ));
2897 }
2898 if self.nm.chars().count() > 140 {
2899 return Err(ValidationError::new(
2900 1002,
2901 "nm exceeds the maximum length of 140".to_string(),
2902 ));
2903 }
2904 let pattern =
2905 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
2906 .unwrap();
2907 if !pattern.is_match(&self.nm) {
2908 return Err(ValidationError::new(
2909 1005,
2910 "nm does not match the required pattern".to_string(),
2911 ));
2912 }
2913 self.adr.validate()?;
2914 Ok(())
2915 }
2916}
2917
2918#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2920pub struct OrganisationIdentification291 {
2921 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2922 pub any_bic: Option<String>,
2923 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2924 pub lei: Option<String>,
2925 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2926 pub othr: Option<Vec<GenericOrganisationIdentification11>>,
2927}
2928
2929impl OrganisationIdentification291 {
2930 pub fn validate(&self) -> Result<(), ValidationError> {
2931 if let Some(ref val) = self.any_bic {
2932 let pattern =
2933 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2934 if !pattern.is_match(val) {
2935 return Err(ValidationError::new(
2936 1005,
2937 "any_bic does not match the required pattern".to_string(),
2938 ));
2939 }
2940 }
2941 if let Some(ref val) = self.lei {
2942 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2943 if !pattern.is_match(val) {
2944 return Err(ValidationError::new(
2945 1005,
2946 "lei does not match the required pattern".to_string(),
2947 ));
2948 }
2949 }
2950 if let Some(ref vec) = self.othr {
2951 for item in vec {
2952 item.validate()?
2953 }
2954 }
2955 Ok(())
2956 }
2957}
2958
2959#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2961pub struct OrganisationIdentification292 {
2962 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2963 pub any_bic: Option<String>,
2964 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2965 pub lei: Option<String>,
2966 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2967 pub othr: Option<Vec<GenericOrganisationIdentification12>>,
2968}
2969
2970impl OrganisationIdentification292 {
2971 pub fn validate(&self) -> Result<(), ValidationError> {
2972 if let Some(ref val) = self.any_bic {
2973 let pattern =
2974 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2975 if !pattern.is_match(val) {
2976 return Err(ValidationError::new(
2977 1005,
2978 "any_bic does not match the required pattern".to_string(),
2979 ));
2980 }
2981 }
2982 if let Some(ref val) = self.lei {
2983 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2984 if !pattern.is_match(val) {
2985 return Err(ValidationError::new(
2986 1005,
2987 "lei does not match the required pattern".to_string(),
2988 ));
2989 }
2990 }
2991 if let Some(ref vec) = self.othr {
2992 for item in vec {
2993 item.validate()?
2994 }
2995 }
2996 Ok(())
2997 }
2998}
2999
3000#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3002pub struct OrganisationIdentification293 {
3003 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
3004 pub any_bic: Option<String>,
3005 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
3006 pub lei: Option<String>,
3007 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3008 pub othr: Option<Vec<GenericOrganisationIdentification13>>,
3009}
3010
3011impl OrganisationIdentification293 {
3012 pub fn validate(&self) -> Result<(), ValidationError> {
3013 if let Some(ref val) = self.any_bic {
3014 let pattern =
3015 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
3016 if !pattern.is_match(val) {
3017 return Err(ValidationError::new(
3018 1005,
3019 "any_bic does not match the required pattern".to_string(),
3020 ));
3021 }
3022 }
3023 if let Some(ref val) = self.lei {
3024 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
3025 if !pattern.is_match(val) {
3026 return Err(ValidationError::new(
3027 1005,
3028 "lei does not match the required pattern".to_string(),
3029 ));
3030 }
3031 }
3032 if let Some(ref vec) = self.othr {
3033 for item in vec {
3034 item.validate()?
3035 }
3036 }
3037 Ok(())
3038 }
3039}
3040
3041#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3043pub struct OrganisationIdentificationSchemeName1Choice1 {
3044 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3045 pub cd: Option<String>,
3046 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3047 pub prtry: Option<String>,
3048}
3049
3050impl OrganisationIdentificationSchemeName1Choice1 {
3051 pub fn validate(&self) -> Result<(), ValidationError> {
3052 if let Some(ref val) = self.cd {
3053 if val.chars().count() < 1 {
3054 return Err(ValidationError::new(
3055 1001,
3056 "cd is shorter than the minimum length of 1".to_string(),
3057 ));
3058 }
3059 if val.chars().count() > 4 {
3060 return Err(ValidationError::new(
3061 1002,
3062 "cd exceeds the maximum length of 4".to_string(),
3063 ));
3064 }
3065 }
3066 if let Some(ref val) = self.prtry {
3067 if val.chars().count() < 1 {
3068 return Err(ValidationError::new(
3069 1001,
3070 "prtry is shorter than the minimum length of 1".to_string(),
3071 ));
3072 }
3073 if val.chars().count() > 35 {
3074 return Err(ValidationError::new(
3075 1002,
3076 "prtry exceeds the maximum length of 35".to_string(),
3077 ));
3078 }
3079 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3080 if !pattern.is_match(val) {
3081 return Err(ValidationError::new(
3082 1005,
3083 "prtry does not match the required pattern".to_string(),
3084 ));
3085 }
3086 }
3087 Ok(())
3088 }
3089}
3090
3091#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3093pub struct OrganisationIdentificationSchemeName1Choice2 {
3094 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3095 pub cd: Option<String>,
3096}
3097
3098impl OrganisationIdentificationSchemeName1Choice2 {
3099 pub fn validate(&self) -> Result<(), ValidationError> {
3100 if let Some(ref val) = self.cd {
3101 if val.chars().count() < 1 {
3102 return Err(ValidationError::new(
3103 1001,
3104 "cd is shorter than the minimum length of 1".to_string(),
3105 ));
3106 }
3107 if val.chars().count() > 4 {
3108 return Err(ValidationError::new(
3109 1002,
3110 "cd exceeds the maximum length of 4".to_string(),
3111 ));
3112 }
3113 }
3114 Ok(())
3115 }
3116}
3117
3118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3120pub struct OrganisationIdentificationSchemeName1Choice3 {
3121 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3122 pub cd: Option<String>,
3123 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3124 pub prtry: Option<String>,
3125}
3126
3127impl OrganisationIdentificationSchemeName1Choice3 {
3128 pub fn validate(&self) -> Result<(), ValidationError> {
3129 if let Some(ref val) = self.cd {
3130 if val.chars().count() < 1 {
3131 return Err(ValidationError::new(
3132 1001,
3133 "cd is shorter than the minimum length of 1".to_string(),
3134 ));
3135 }
3136 if val.chars().count() > 4 {
3137 return Err(ValidationError::new(
3138 1002,
3139 "cd exceeds the maximum length of 4".to_string(),
3140 ));
3141 }
3142 }
3143 if let Some(ref val) = self.prtry {
3144 if val.chars().count() < 1 {
3145 return Err(ValidationError::new(
3146 1001,
3147 "prtry is shorter than the minimum length of 1".to_string(),
3148 ));
3149 }
3150 if val.chars().count() > 35 {
3151 return Err(ValidationError::new(
3152 1002,
3153 "prtry exceeds the maximum length of 35".to_string(),
3154 ));
3155 }
3156 let pattern = Regex::new(
3157 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3158 )
3159 .unwrap();
3160 if !pattern.is_match(val) {
3161 return Err(ValidationError::new(
3162 1005,
3163 "prtry does not match the required pattern".to_string(),
3164 ));
3165 }
3166 }
3167 Ok(())
3168 }
3169}
3170
3171#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3173pub struct Party38Choice1 {
3174 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
3175 pub org_id: Option<OrganisationIdentification291>,
3176 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
3177 pub prvt_id: Option<PersonIdentification131>,
3178}
3179
3180impl Party38Choice1 {
3181 pub fn validate(&self) -> Result<(), ValidationError> {
3182 if let Some(ref val) = self.org_id {
3183 val.validate()?
3184 }
3185 if let Some(ref val) = self.prvt_id {
3186 val.validate()?
3187 }
3188 Ok(())
3189 }
3190}
3191
3192#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3194pub struct Party38Choice2 {
3195 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
3196 pub org_id: Option<OrganisationIdentification291>,
3197 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
3198 pub prvt_id: Option<PersonIdentification132>,
3199}
3200
3201impl Party38Choice2 {
3202 pub fn validate(&self) -> Result<(), ValidationError> {
3203 if let Some(ref val) = self.org_id {
3204 val.validate()?
3205 }
3206 if let Some(ref val) = self.prvt_id {
3207 val.validate()?
3208 }
3209 Ok(())
3210 }
3211}
3212
3213#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3215pub struct Party38Choice3 {
3216 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
3217 pub org_id: Option<OrganisationIdentification292>,
3218 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
3219 pub prvt_id: Option<PersonIdentification133>,
3220}
3221
3222impl Party38Choice3 {
3223 pub fn validate(&self) -> Result<(), ValidationError> {
3224 if let Some(ref val) = self.org_id {
3225 val.validate()?
3226 }
3227 if let Some(ref val) = self.prvt_id {
3228 val.validate()?
3229 }
3230 Ok(())
3231 }
3232}
3233
3234#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3236pub struct Party38Choice4 {
3237 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
3238 pub org_id: Option<OrganisationIdentification293>,
3239 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
3240 pub prvt_id: Option<PersonIdentification134>,
3241}
3242
3243impl Party38Choice4 {
3244 pub fn validate(&self) -> Result<(), ValidationError> {
3245 if let Some(ref val) = self.org_id {
3246 val.validate()?
3247 }
3248 if let Some(ref val) = self.prvt_id {
3249 val.validate()?
3250 }
3251 Ok(())
3252 }
3253}
3254
3255#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3257pub struct Party38Choice5 {
3258 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
3259 pub org_id: Option<OrganisationIdentification293>,
3260 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
3261 pub prvt_id: Option<PersonIdentification135>,
3262}
3263
3264impl Party38Choice5 {
3265 pub fn validate(&self) -> Result<(), ValidationError> {
3266 if let Some(ref val) = self.org_id {
3267 val.validate()?
3268 }
3269 if let Some(ref val) = self.prvt_id {
3270 val.validate()?
3271 }
3272 Ok(())
3273 }
3274}
3275
3276#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3278pub struct PartyIdentification1351 {
3279 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3280 pub nm: Option<String>,
3281 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3282 pub pstl_adr: Option<PostalAddress241>,
3283 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3284 pub id: Option<Party38Choice1>,
3285 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3286 pub ctry_of_res: Option<String>,
3287}
3288
3289impl PartyIdentification1351 {
3290 pub fn validate(&self) -> Result<(), ValidationError> {
3291 if let Some(ref val) = self.nm {
3292 if val.chars().count() < 1 {
3293 return Err(ValidationError::new(
3294 1001,
3295 "nm is shorter than the minimum length of 1".to_string(),
3296 ));
3297 }
3298 if val.chars().count() > 140 {
3299 return Err(ValidationError::new(
3300 1002,
3301 "nm exceeds the maximum length of 140".to_string(),
3302 ));
3303 }
3304 let pattern = Regex::new(
3305 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3306 )
3307 .unwrap();
3308 if !pattern.is_match(val) {
3309 return Err(ValidationError::new(
3310 1005,
3311 "nm does not match the required pattern".to_string(),
3312 ));
3313 }
3314 }
3315 if let Some(ref val) = self.pstl_adr {
3316 val.validate()?
3317 }
3318 if let Some(ref val) = self.id {
3319 val.validate()?
3320 }
3321 if let Some(ref val) = self.ctry_of_res {
3322 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3323 if !pattern.is_match(val) {
3324 return Err(ValidationError::new(
3325 1005,
3326 "ctry_of_res does not match the required pattern".to_string(),
3327 ));
3328 }
3329 }
3330 Ok(())
3331 }
3332}
3333
3334#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3336pub struct PartyIdentification1352 {
3337 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3338 pub nm: Option<String>,
3339 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3340 pub pstl_adr: Option<PostalAddress242>,
3341 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3342 pub id: Option<Party38Choice2>,
3343 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3344 pub ctry_of_res: Option<String>,
3345}
3346
3347impl PartyIdentification1352 {
3348 pub fn validate(&self) -> Result<(), ValidationError> {
3349 if let Some(ref val) = self.nm {
3350 if val.chars().count() < 1 {
3351 return Err(ValidationError::new(
3352 1001,
3353 "nm is shorter than the minimum length of 1".to_string(),
3354 ));
3355 }
3356 if val.chars().count() > 140 {
3357 return Err(ValidationError::new(
3358 1002,
3359 "nm exceeds the maximum length of 140".to_string(),
3360 ));
3361 }
3362 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3363 if !pattern.is_match(val) {
3364 return Err(ValidationError::new(
3365 1005,
3366 "nm does not match the required pattern".to_string(),
3367 ));
3368 }
3369 }
3370 if let Some(ref val) = self.pstl_adr {
3371 val.validate()?
3372 }
3373 if let Some(ref val) = self.id {
3374 val.validate()?
3375 }
3376 if let Some(ref val) = self.ctry_of_res {
3377 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3378 if !pattern.is_match(val) {
3379 return Err(ValidationError::new(
3380 1005,
3381 "ctry_of_res does not match the required pattern".to_string(),
3382 ));
3383 }
3384 }
3385 Ok(())
3386 }
3387}
3388
3389#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3391pub struct PartyIdentification1353 {
3392 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3393 pub nm: Option<String>,
3394 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3395 pub pstl_adr: Option<PostalAddress243>,
3396 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3397 pub id: Option<Party38Choice1>,
3398 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3399 pub ctry_of_res: Option<String>,
3400}
3401
3402impl PartyIdentification1353 {
3403 pub fn validate(&self) -> Result<(), ValidationError> {
3404 if let Some(ref val) = self.nm {
3405 if val.chars().count() < 1 {
3406 return Err(ValidationError::new(
3407 1001,
3408 "nm is shorter than the minimum length of 1".to_string(),
3409 ));
3410 }
3411 if val.chars().count() > 140 {
3412 return Err(ValidationError::new(
3413 1002,
3414 "nm exceeds the maximum length of 140".to_string(),
3415 ));
3416 }
3417 let pattern = Regex::new(
3418 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3419 )
3420 .unwrap();
3421 if !pattern.is_match(val) {
3422 return Err(ValidationError::new(
3423 1005,
3424 "nm does not match the required pattern".to_string(),
3425 ));
3426 }
3427 }
3428 if let Some(ref val) = self.pstl_adr {
3429 val.validate()?
3430 }
3431 if let Some(ref val) = self.id {
3432 val.validate()?
3433 }
3434 if let Some(ref val) = self.ctry_of_res {
3435 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3436 if !pattern.is_match(val) {
3437 return Err(ValidationError::new(
3438 1005,
3439 "ctry_of_res does not match the required pattern".to_string(),
3440 ));
3441 }
3442 }
3443 Ok(())
3444 }
3445}
3446
3447#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3449pub struct PartyIdentification1354 {
3450 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3451 pub nm: Option<String>,
3452 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3453 pub pstl_adr: Option<PostalAddress241>,
3454 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3455 pub id: Option<Party38Choice3>,
3456 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3457 pub ctry_of_res: Option<String>,
3458}
3459
3460impl PartyIdentification1354 {
3461 pub fn validate(&self) -> Result<(), ValidationError> {
3462 if let Some(ref val) = self.nm {
3463 if val.chars().count() < 1 {
3464 return Err(ValidationError::new(
3465 1001,
3466 "nm is shorter than the minimum length of 1".to_string(),
3467 ));
3468 }
3469 if val.chars().count() > 140 {
3470 return Err(ValidationError::new(
3471 1002,
3472 "nm exceeds the maximum length of 140".to_string(),
3473 ));
3474 }
3475 let pattern = Regex::new(
3476 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3477 )
3478 .unwrap();
3479 if !pattern.is_match(val) {
3480 return Err(ValidationError::new(
3481 1005,
3482 "nm does not match the required pattern".to_string(),
3483 ));
3484 }
3485 }
3486 if let Some(ref val) = self.pstl_adr {
3487 val.validate()?
3488 }
3489 if let Some(ref val) = self.id {
3490 val.validate()?
3491 }
3492 if let Some(ref val) = self.ctry_of_res {
3493 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3494 if !pattern.is_match(val) {
3495 return Err(ValidationError::new(
3496 1005,
3497 "ctry_of_res does not match the required pattern".to_string(),
3498 ));
3499 }
3500 }
3501 Ok(())
3502 }
3503}
3504
3505#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3507pub struct PartyIdentification1355 {
3508 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3509 pub nm: Option<String>,
3510 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3511 pub pstl_adr: Option<PostalAddress243>,
3512 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3513 pub id: Option<Party38Choice4>,
3514 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3515 pub ctry_of_res: Option<String>,
3516}
3517
3518impl PartyIdentification1355 {
3519 pub fn validate(&self) -> Result<(), ValidationError> {
3520 if let Some(ref val) = self.nm {
3521 if val.chars().count() < 1 {
3522 return Err(ValidationError::new(
3523 1001,
3524 "nm is shorter than the minimum length of 1".to_string(),
3525 ));
3526 }
3527 if val.chars().count() > 140 {
3528 return Err(ValidationError::new(
3529 1002,
3530 "nm exceeds the maximum length of 140".to_string(),
3531 ));
3532 }
3533 let pattern = Regex::new(
3534 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3535 )
3536 .unwrap();
3537 if !pattern.is_match(val) {
3538 return Err(ValidationError::new(
3539 1005,
3540 "nm does not match the required pattern".to_string(),
3541 ));
3542 }
3543 }
3544 if let Some(ref val) = self.pstl_adr {
3545 val.validate()?
3546 }
3547 if let Some(ref val) = self.id {
3548 val.validate()?
3549 }
3550 if let Some(ref val) = self.ctry_of_res {
3551 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3552 if !pattern.is_match(val) {
3553 return Err(ValidationError::new(
3554 1005,
3555 "ctry_of_res does not match the required pattern".to_string(),
3556 ));
3557 }
3558 }
3559 Ok(())
3560 }
3561}
3562
3563#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3565pub struct PartyIdentification1356 {
3566 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3567 pub nm: Option<String>,
3568 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3569 pub pstl_adr: Option<PostalAddress245>,
3570 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3571 pub id: Option<Party38Choice5>,
3572 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3573 pub ctry_of_res: Option<String>,
3574}
3575
3576impl PartyIdentification1356 {
3577 pub fn validate(&self) -> Result<(), ValidationError> {
3578 if let Some(ref val) = self.nm {
3579 if val.chars().count() < 1 {
3580 return Err(ValidationError::new(
3581 1001,
3582 "nm is shorter than the minimum length of 1".to_string(),
3583 ));
3584 }
3585 if val.chars().count() > 140 {
3586 return Err(ValidationError::new(
3587 1002,
3588 "nm exceeds the maximum length of 140".to_string(),
3589 ));
3590 }
3591 let pattern = Regex::new(
3592 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3593 )
3594 .unwrap();
3595 if !pattern.is_match(val) {
3596 return Err(ValidationError::new(
3597 1005,
3598 "nm does not match the required pattern".to_string(),
3599 ));
3600 }
3601 }
3602 if let Some(ref val) = self.pstl_adr {
3603 val.validate()?
3604 }
3605 if let Some(ref val) = self.id {
3606 val.validate()?
3607 }
3608 if let Some(ref val) = self.ctry_of_res {
3609 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3610 if !pattern.is_match(val) {
3611 return Err(ValidationError::new(
3612 1005,
3613 "ctry_of_res does not match the required pattern".to_string(),
3614 ));
3615 }
3616 }
3617 Ok(())
3618 }
3619}
3620
3621#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3623pub struct PartyIdentification1357 {
3624 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3625 pub nm: Option<String>,
3626 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3627 pub pstl_adr: Option<PostalAddress245>,
3628 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
3629 pub id: Option<Party38Choice4>,
3630 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
3631 pub ctry_of_res: Option<String>,
3632}
3633
3634impl PartyIdentification1357 {
3635 pub fn validate(&self) -> Result<(), ValidationError> {
3636 if let Some(ref val) = self.nm {
3637 if val.chars().count() < 1 {
3638 return Err(ValidationError::new(
3639 1001,
3640 "nm is shorter than the minimum length of 1".to_string(),
3641 ));
3642 }
3643 if val.chars().count() > 140 {
3644 return Err(ValidationError::new(
3645 1002,
3646 "nm exceeds the maximum length of 140".to_string(),
3647 ));
3648 }
3649 let pattern = Regex::new(
3650 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
3651 )
3652 .unwrap();
3653 if !pattern.is_match(val) {
3654 return Err(ValidationError::new(
3655 1005,
3656 "nm does not match the required pattern".to_string(),
3657 ));
3658 }
3659 }
3660 if let Some(ref val) = self.pstl_adr {
3661 val.validate()?
3662 }
3663 if let Some(ref val) = self.id {
3664 val.validate()?
3665 }
3666 if let Some(ref val) = self.ctry_of_res {
3667 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3668 if !pattern.is_match(val) {
3669 return Err(ValidationError::new(
3670 1005,
3671 "ctry_of_res does not match the required pattern".to_string(),
3672 ));
3673 }
3674 }
3675 Ok(())
3676 }
3677}
3678
3679#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3681pub struct PaymentIdentification71 {
3682 #[serde(rename = "InstrId")]
3683 pub instr_id: String,
3684 #[serde(rename = "EndToEndId")]
3685 pub end_to_end_id: String,
3686 #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
3687 pub tx_id: Option<String>,
3688 #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
3689 pub uetr: Option<String>,
3690 #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
3691 pub clr_sys_ref: Option<String>,
3692}
3693
3694impl PaymentIdentification71 {
3695 pub fn validate(&self) -> Result<(), ValidationError> {
3696 if self.instr_id.chars().count() < 1 {
3697 return Err(ValidationError::new(
3698 1001,
3699 "instr_id is shorter than the minimum length of 1".to_string(),
3700 ));
3701 }
3702 if self.instr_id.chars().count() > 16 {
3703 return Err(ValidationError::new(
3704 1002,
3705 "instr_id exceeds the maximum length of 16".to_string(),
3706 ));
3707 }
3708 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3709 if !pattern.is_match(&self.instr_id) {
3710 return Err(ValidationError::new(
3711 1005,
3712 "instr_id does not match the required pattern".to_string(),
3713 ));
3714 }
3715 if self.end_to_end_id.chars().count() < 1 {
3716 return Err(ValidationError::new(
3717 1001,
3718 "end_to_end_id is shorter than the minimum length of 1".to_string(),
3719 ));
3720 }
3721 if self.end_to_end_id.chars().count() > 35 {
3722 return Err(ValidationError::new(
3723 1002,
3724 "end_to_end_id exceeds the maximum length of 35".to_string(),
3725 ));
3726 }
3727 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3728 if !pattern.is_match(&self.end_to_end_id) {
3729 return Err(ValidationError::new(
3730 1005,
3731 "end_to_end_id does not match the required pattern".to_string(),
3732 ));
3733 }
3734 if let Some(ref val) = self.tx_id {
3735 if val.chars().count() < 1 {
3736 return Err(ValidationError::new(
3737 1001,
3738 "tx_id is shorter than the minimum length of 1".to_string(),
3739 ));
3740 }
3741 if val.chars().count() > 35 {
3742 return Err(ValidationError::new(
3743 1002,
3744 "tx_id exceeds the maximum length of 35".to_string(),
3745 ));
3746 }
3747 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3748 if !pattern.is_match(val) {
3749 return Err(ValidationError::new(
3750 1005,
3751 "tx_id does not match the required pattern".to_string(),
3752 ));
3753 }
3754 }
3755 if let Some(ref val) = self.uetr {
3756 let pattern =
3757 Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
3758 .unwrap();
3759 if !pattern.is_match(val) {
3760 return Err(ValidationError::new(
3761 1005,
3762 "uetr does not match the required pattern".to_string(),
3763 ));
3764 }
3765 }
3766 if let Some(ref val) = self.clr_sys_ref {
3767 if val.chars().count() < 1 {
3768 return Err(ValidationError::new(
3769 1001,
3770 "clr_sys_ref is shorter than the minimum length of 1".to_string(),
3771 ));
3772 }
3773 if val.chars().count() > 35 {
3774 return Err(ValidationError::new(
3775 1002,
3776 "clr_sys_ref exceeds the maximum length of 35".to_string(),
3777 ));
3778 }
3779 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3780 if !pattern.is_match(val) {
3781 return Err(ValidationError::new(
3782 1005,
3783 "clr_sys_ref does not match the required pattern".to_string(),
3784 ));
3785 }
3786 }
3787 Ok(())
3788 }
3789}
3790
3791#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3794pub struct PaymentTypeInformation271 {
3795 #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
3796 pub instr_prty: Option<Priority2Code>,
3797 #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
3798 pub clr_chanl: Option<ClearingChannel2Code>,
3799 #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
3800 pub svc_lvl: Option<Vec<ServiceLevel8Choice1>>,
3801 #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
3802 pub lcl_instrm: Option<LocalInstrument2Choice1>,
3803 #[serde(rename = "SeqTp", skip_serializing_if = "Option::is_none")]
3804 pub seq_tp: Option<SequenceType3Code>,
3805 #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
3806 pub ctgy_purp: Option<CategoryPurpose1Choice1>,
3807}
3808
3809impl PaymentTypeInformation271 {
3810 pub fn validate(&self) -> Result<(), ValidationError> {
3811 if let Some(ref val) = self.instr_prty {
3812 val.validate()?
3813 }
3814 if let Some(ref val) = self.clr_chanl {
3815 val.validate()?
3816 }
3817 if let Some(ref vec) = self.svc_lvl {
3818 for item in vec {
3819 item.validate()?
3820 }
3821 }
3822 if let Some(ref val) = self.lcl_instrm {
3823 val.validate()?
3824 }
3825 if let Some(ref val) = self.seq_tp {
3826 val.validate()?
3827 }
3828 if let Some(ref val) = self.ctgy_purp {
3829 val.validate()?
3830 }
3831 Ok(())
3832 }
3833}
3834
3835#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3837pub struct PersonIdentification131 {
3838 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3839 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3840 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3841 pub othr: Option<Vec<GenericPersonIdentification11>>,
3842}
3843
3844impl PersonIdentification131 {
3845 pub fn validate(&self) -> Result<(), ValidationError> {
3846 if let Some(ref val) = self.dt_and_plc_of_birth {
3847 val.validate()?
3848 }
3849 if let Some(ref vec) = self.othr {
3850 for item in vec {
3851 item.validate()?
3852 }
3853 }
3854 Ok(())
3855 }
3856}
3857
3858#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3860pub struct PersonIdentification132 {
3861 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3862 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
3863 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3864 pub othr: Option<Vec<GenericPersonIdentification11>>,
3865}
3866
3867impl PersonIdentification132 {
3868 pub fn validate(&self) -> Result<(), ValidationError> {
3869 if let Some(ref val) = self.dt_and_plc_of_birth {
3870 val.validate()?
3871 }
3872 if let Some(ref vec) = self.othr {
3873 for item in vec {
3874 item.validate()?
3875 }
3876 }
3877 Ok(())
3878 }
3879}
3880
3881#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3883pub struct PersonIdentification133 {
3884 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3885 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3886 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3887 pub othr: Option<Vec<GenericPersonIdentification12>>,
3888}
3889
3890impl PersonIdentification133 {
3891 pub fn validate(&self) -> Result<(), ValidationError> {
3892 if let Some(ref val) = self.dt_and_plc_of_birth {
3893 val.validate()?
3894 }
3895 if let Some(ref vec) = self.othr {
3896 for item in vec {
3897 item.validate()?
3898 }
3899 }
3900 Ok(())
3901 }
3902}
3903
3904#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3906pub struct PersonIdentification134 {
3907 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3908 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
3909 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3910 pub othr: Option<Vec<GenericPersonIdentification13>>,
3911}
3912
3913impl PersonIdentification134 {
3914 pub fn validate(&self) -> Result<(), ValidationError> {
3915 if let Some(ref val) = self.dt_and_plc_of_birth {
3916 val.validate()?
3917 }
3918 if let Some(ref vec) = self.othr {
3919 for item in vec {
3920 item.validate()?
3921 }
3922 }
3923 Ok(())
3924 }
3925}
3926
3927#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3929pub struct PersonIdentification135 {
3930 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
3931 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
3932 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
3933 pub othr: Option<Vec<GenericPersonIdentification13>>,
3934}
3935
3936impl PersonIdentification135 {
3937 pub fn validate(&self) -> Result<(), ValidationError> {
3938 if let Some(ref val) = self.dt_and_plc_of_birth {
3939 val.validate()?
3940 }
3941 if let Some(ref vec) = self.othr {
3942 for item in vec {
3943 item.validate()?
3944 }
3945 }
3946 Ok(())
3947 }
3948}
3949
3950#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3952pub struct PersonIdentificationSchemeName1Choice1 {
3953 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3954 pub cd: Option<String>,
3955 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3956 pub prtry: Option<String>,
3957}
3958
3959impl PersonIdentificationSchemeName1Choice1 {
3960 pub fn validate(&self) -> Result<(), ValidationError> {
3961 if let Some(ref val) = self.cd {
3962 if val.chars().count() < 1 {
3963 return Err(ValidationError::new(
3964 1001,
3965 "cd is shorter than the minimum length of 1".to_string(),
3966 ));
3967 }
3968 if val.chars().count() > 4 {
3969 return Err(ValidationError::new(
3970 1002,
3971 "cd exceeds the maximum length of 4".to_string(),
3972 ));
3973 }
3974 }
3975 if let Some(ref val) = self.prtry {
3976 if val.chars().count() < 1 {
3977 return Err(ValidationError::new(
3978 1001,
3979 "prtry is shorter than the minimum length of 1".to_string(),
3980 ));
3981 }
3982 if val.chars().count() > 35 {
3983 return Err(ValidationError::new(
3984 1002,
3985 "prtry exceeds the maximum length of 35".to_string(),
3986 ));
3987 }
3988 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
3989 if !pattern.is_match(val) {
3990 return Err(ValidationError::new(
3991 1005,
3992 "prtry does not match the required pattern".to_string(),
3993 ));
3994 }
3995 }
3996 Ok(())
3997 }
3998}
3999
4000#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4002pub struct PersonIdentificationSchemeName1Choice2 {
4003 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4004 pub cd: Option<String>,
4005}
4006
4007impl PersonIdentificationSchemeName1Choice2 {
4008 pub fn validate(&self) -> Result<(), ValidationError> {
4009 if let Some(ref val) = self.cd {
4010 if val.chars().count() < 1 {
4011 return Err(ValidationError::new(
4012 1001,
4013 "cd is shorter than the minimum length of 1".to_string(),
4014 ));
4015 }
4016 if val.chars().count() > 4 {
4017 return Err(ValidationError::new(
4018 1002,
4019 "cd exceeds the maximum length of 4".to_string(),
4020 ));
4021 }
4022 }
4023 Ok(())
4024 }
4025}
4026
4027#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4029pub struct PersonIdentificationSchemeName1Choice3 {
4030 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
4031 pub cd: Option<String>,
4032 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
4033 pub prtry: Option<String>,
4034}
4035
4036impl PersonIdentificationSchemeName1Choice3 {
4037 pub fn validate(&self) -> Result<(), ValidationError> {
4038 if let Some(ref val) = self.cd {
4039 if val.chars().count() < 1 {
4040 return Err(ValidationError::new(
4041 1001,
4042 "cd is shorter than the minimum length of 1".to_string(),
4043 ));
4044 }
4045 if val.chars().count() > 4 {
4046 return Err(ValidationError::new(
4047 1002,
4048 "cd exceeds the maximum length of 4".to_string(),
4049 ));
4050 }
4051 }
4052 if let Some(ref val) = self.prtry {
4053 if val.chars().count() < 1 {
4054 return Err(ValidationError::new(
4055 1001,
4056 "prtry is shorter than the minimum length of 1".to_string(),
4057 ));
4058 }
4059 if val.chars().count() > 35 {
4060 return Err(ValidationError::new(
4061 1002,
4062 "prtry exceeds the maximum length of 35".to_string(),
4063 ));
4064 }
4065 let pattern = Regex::new(
4066 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4067 )
4068 .unwrap();
4069 if !pattern.is_match(val) {
4070 return Err(ValidationError::new(
4071 1005,
4072 "prtry does not match the required pattern".to_string(),
4073 ));
4074 }
4075 }
4076 Ok(())
4077 }
4078}
4079
4080#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4082pub struct PostalAddress241 {
4083 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
4084 pub dept: Option<String>,
4085 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
4086 pub sub_dept: Option<String>,
4087 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
4088 pub strt_nm: Option<String>,
4089 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
4090 pub bldg_nb: Option<String>,
4091 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
4092 pub bldg_nm: Option<String>,
4093 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
4094 pub flr: Option<String>,
4095 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
4096 pub pst_bx: Option<String>,
4097 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
4098 pub room: Option<String>,
4099 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
4100 pub pst_cd: Option<String>,
4101 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
4102 pub twn_nm: Option<String>,
4103 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
4104 pub twn_lctn_nm: Option<String>,
4105 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
4106 pub dstrct_nm: Option<String>,
4107 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
4108 pub ctry_sub_dvsn: Option<String>,
4109 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
4110 pub ctry: Option<String>,
4111 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
4112 pub adr_line: Option<Vec<String>>,
4113}
4114
4115impl PostalAddress241 {
4116 pub fn validate(&self) -> Result<(), ValidationError> {
4117 if let Some(ref val) = self.dept {
4118 if val.chars().count() < 1 {
4119 return Err(ValidationError::new(
4120 1001,
4121 "dept is shorter than the minimum length of 1".to_string(),
4122 ));
4123 }
4124 if val.chars().count() > 70 {
4125 return Err(ValidationError::new(
4126 1002,
4127 "dept exceeds the maximum length of 70".to_string(),
4128 ));
4129 }
4130 let pattern = Regex::new(
4131 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4132 )
4133 .unwrap();
4134 if !pattern.is_match(val) {
4135 return Err(ValidationError::new(
4136 1005,
4137 "dept does not match the required pattern".to_string(),
4138 ));
4139 }
4140 }
4141 if let Some(ref val) = self.sub_dept {
4142 if val.chars().count() < 1 {
4143 return Err(ValidationError::new(
4144 1001,
4145 "sub_dept is shorter than the minimum length of 1".to_string(),
4146 ));
4147 }
4148 if val.chars().count() > 70 {
4149 return Err(ValidationError::new(
4150 1002,
4151 "sub_dept exceeds the maximum length of 70".to_string(),
4152 ));
4153 }
4154 let pattern = Regex::new(
4155 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4156 )
4157 .unwrap();
4158 if !pattern.is_match(val) {
4159 return Err(ValidationError::new(
4160 1005,
4161 "sub_dept does not match the required pattern".to_string(),
4162 ));
4163 }
4164 }
4165 if let Some(ref val) = self.strt_nm {
4166 if val.chars().count() < 1 {
4167 return Err(ValidationError::new(
4168 1001,
4169 "strt_nm is shorter than the minimum length of 1".to_string(),
4170 ));
4171 }
4172 if val.chars().count() > 70 {
4173 return Err(ValidationError::new(
4174 1002,
4175 "strt_nm exceeds the maximum length of 70".to_string(),
4176 ));
4177 }
4178 let pattern = Regex::new(
4179 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4180 )
4181 .unwrap();
4182 if !pattern.is_match(val) {
4183 return Err(ValidationError::new(
4184 1005,
4185 "strt_nm does not match the required pattern".to_string(),
4186 ));
4187 }
4188 }
4189 if let Some(ref val) = self.bldg_nb {
4190 if val.chars().count() < 1 {
4191 return Err(ValidationError::new(
4192 1001,
4193 "bldg_nb is shorter than the minimum length of 1".to_string(),
4194 ));
4195 }
4196 if val.chars().count() > 16 {
4197 return Err(ValidationError::new(
4198 1002,
4199 "bldg_nb exceeds the maximum length of 16".to_string(),
4200 ));
4201 }
4202 let pattern = Regex::new(
4203 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4204 )
4205 .unwrap();
4206 if !pattern.is_match(val) {
4207 return Err(ValidationError::new(
4208 1005,
4209 "bldg_nb does not match the required pattern".to_string(),
4210 ));
4211 }
4212 }
4213 if let Some(ref val) = self.bldg_nm {
4214 if val.chars().count() < 1 {
4215 return Err(ValidationError::new(
4216 1001,
4217 "bldg_nm is shorter than the minimum length of 1".to_string(),
4218 ));
4219 }
4220 if val.chars().count() > 35 {
4221 return Err(ValidationError::new(
4222 1002,
4223 "bldg_nm exceeds the maximum length of 35".to_string(),
4224 ));
4225 }
4226 let pattern = Regex::new(
4227 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4228 )
4229 .unwrap();
4230 if !pattern.is_match(val) {
4231 return Err(ValidationError::new(
4232 1005,
4233 "bldg_nm does not match the required pattern".to_string(),
4234 ));
4235 }
4236 }
4237 if let Some(ref val) = self.flr {
4238 if val.chars().count() < 1 {
4239 return Err(ValidationError::new(
4240 1001,
4241 "flr is shorter than the minimum length of 1".to_string(),
4242 ));
4243 }
4244 if val.chars().count() > 70 {
4245 return Err(ValidationError::new(
4246 1002,
4247 "flr exceeds the maximum length of 70".to_string(),
4248 ));
4249 }
4250 let pattern = Regex::new(
4251 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4252 )
4253 .unwrap();
4254 if !pattern.is_match(val) {
4255 return Err(ValidationError::new(
4256 1005,
4257 "flr does not match the required pattern".to_string(),
4258 ));
4259 }
4260 }
4261 if let Some(ref val) = self.pst_bx {
4262 if val.chars().count() < 1 {
4263 return Err(ValidationError::new(
4264 1001,
4265 "pst_bx is shorter than the minimum length of 1".to_string(),
4266 ));
4267 }
4268 if val.chars().count() > 16 {
4269 return Err(ValidationError::new(
4270 1002,
4271 "pst_bx exceeds the maximum length of 16".to_string(),
4272 ));
4273 }
4274 let pattern = Regex::new(
4275 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4276 )
4277 .unwrap();
4278 if !pattern.is_match(val) {
4279 return Err(ValidationError::new(
4280 1005,
4281 "pst_bx does not match the required pattern".to_string(),
4282 ));
4283 }
4284 }
4285 if let Some(ref val) = self.room {
4286 if val.chars().count() < 1 {
4287 return Err(ValidationError::new(
4288 1001,
4289 "room is shorter than the minimum length of 1".to_string(),
4290 ));
4291 }
4292 if val.chars().count() > 70 {
4293 return Err(ValidationError::new(
4294 1002,
4295 "room exceeds the maximum length of 70".to_string(),
4296 ));
4297 }
4298 let pattern = Regex::new(
4299 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4300 )
4301 .unwrap();
4302 if !pattern.is_match(val) {
4303 return Err(ValidationError::new(
4304 1005,
4305 "room does not match the required pattern".to_string(),
4306 ));
4307 }
4308 }
4309 if let Some(ref val) = self.pst_cd {
4310 if val.chars().count() < 1 {
4311 return Err(ValidationError::new(
4312 1001,
4313 "pst_cd is shorter than the minimum length of 1".to_string(),
4314 ));
4315 }
4316 if val.chars().count() > 16 {
4317 return Err(ValidationError::new(
4318 1002,
4319 "pst_cd exceeds the maximum length of 16".to_string(),
4320 ));
4321 }
4322 let pattern = Regex::new(
4323 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4324 )
4325 .unwrap();
4326 if !pattern.is_match(val) {
4327 return Err(ValidationError::new(
4328 1005,
4329 "pst_cd does not match the required pattern".to_string(),
4330 ));
4331 }
4332 }
4333 if let Some(ref val) = self.twn_nm {
4334 if val.chars().count() < 1 {
4335 return Err(ValidationError::new(
4336 1001,
4337 "twn_nm is shorter than the minimum length of 1".to_string(),
4338 ));
4339 }
4340 if val.chars().count() > 35 {
4341 return Err(ValidationError::new(
4342 1002,
4343 "twn_nm exceeds the maximum length of 35".to_string(),
4344 ));
4345 }
4346 let pattern = Regex::new(
4347 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4348 )
4349 .unwrap();
4350 if !pattern.is_match(val) {
4351 return Err(ValidationError::new(
4352 1005,
4353 "twn_nm does not match the required pattern".to_string(),
4354 ));
4355 }
4356 }
4357 if let Some(ref val) = self.twn_lctn_nm {
4358 if val.chars().count() < 1 {
4359 return Err(ValidationError::new(
4360 1001,
4361 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
4362 ));
4363 }
4364 if val.chars().count() > 35 {
4365 return Err(ValidationError::new(
4366 1002,
4367 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
4368 ));
4369 }
4370 let pattern = Regex::new(
4371 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4372 )
4373 .unwrap();
4374 if !pattern.is_match(val) {
4375 return Err(ValidationError::new(
4376 1005,
4377 "twn_lctn_nm does not match the required pattern".to_string(),
4378 ));
4379 }
4380 }
4381 if let Some(ref val) = self.dstrct_nm {
4382 if val.chars().count() < 1 {
4383 return Err(ValidationError::new(
4384 1001,
4385 "dstrct_nm is shorter than the minimum length of 1".to_string(),
4386 ));
4387 }
4388 if val.chars().count() > 35 {
4389 return Err(ValidationError::new(
4390 1002,
4391 "dstrct_nm exceeds the maximum length of 35".to_string(),
4392 ));
4393 }
4394 let pattern = Regex::new(
4395 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4396 )
4397 .unwrap();
4398 if !pattern.is_match(val) {
4399 return Err(ValidationError::new(
4400 1005,
4401 "dstrct_nm does not match the required pattern".to_string(),
4402 ));
4403 }
4404 }
4405 if let Some(ref val) = self.ctry_sub_dvsn {
4406 if val.chars().count() < 1 {
4407 return Err(ValidationError::new(
4408 1001,
4409 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
4410 ));
4411 }
4412 if val.chars().count() > 35 {
4413 return Err(ValidationError::new(
4414 1002,
4415 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
4416 ));
4417 }
4418 let pattern = Regex::new(
4419 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4420 )
4421 .unwrap();
4422 if !pattern.is_match(val) {
4423 return Err(ValidationError::new(
4424 1005,
4425 "ctry_sub_dvsn does not match the required pattern".to_string(),
4426 ));
4427 }
4428 }
4429 if let Some(ref val) = self.ctry {
4430 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
4431 if !pattern.is_match(val) {
4432 return Err(ValidationError::new(
4433 1005,
4434 "ctry does not match the required pattern".to_string(),
4435 ));
4436 }
4437 }
4438 if let Some(ref vec) = self.adr_line {
4439 for item in vec {
4440 if item.chars().count() < 1 {
4441 return Err(ValidationError::new(
4442 1001,
4443 "adr_line is shorter than the minimum length of 1".to_string(),
4444 ));
4445 }
4446 if item.chars().count() > 70 {
4447 return Err(ValidationError::new(
4448 1002,
4449 "adr_line exceeds the maximum length of 70".to_string(),
4450 ));
4451 }
4452 let pattern = Regex::new(
4453 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4454 )
4455 .unwrap();
4456 if !pattern.is_match(&item) {
4457 return Err(ValidationError::new(
4458 1005,
4459 "adr_line does not match the required pattern".to_string(),
4460 ));
4461 }
4462 }
4463 }
4464 Ok(())
4465 }
4466}
4467
4468#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4470pub struct PostalAddress242 {
4471 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
4472 pub dept: Option<String>,
4473 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
4474 pub sub_dept: Option<String>,
4475 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
4476 pub strt_nm: Option<String>,
4477 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
4478 pub bldg_nb: Option<String>,
4479 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
4480 pub bldg_nm: Option<String>,
4481 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
4482 pub flr: Option<String>,
4483 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
4484 pub pst_bx: Option<String>,
4485 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
4486 pub room: Option<String>,
4487 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
4488 pub pst_cd: Option<String>,
4489 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
4490 pub twn_nm: Option<String>,
4491 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
4492 pub twn_lctn_nm: Option<String>,
4493 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
4494 pub dstrct_nm: Option<String>,
4495 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
4496 pub ctry_sub_dvsn: Option<String>,
4497 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
4498 pub ctry: Option<String>,
4499 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
4500 pub adr_line: Option<Vec<String>>,
4501}
4502
4503impl PostalAddress242 {
4504 pub fn validate(&self) -> Result<(), ValidationError> {
4505 if let Some(ref val) = self.dept {
4506 if val.chars().count() < 1 {
4507 return Err(ValidationError::new(
4508 1001,
4509 "dept is shorter than the minimum length of 1".to_string(),
4510 ));
4511 }
4512 if val.chars().count() > 70 {
4513 return Err(ValidationError::new(
4514 1002,
4515 "dept exceeds the maximum length of 70".to_string(),
4516 ));
4517 }
4518 }
4519 if let Some(ref val) = self.sub_dept {
4520 if val.chars().count() < 1 {
4521 return Err(ValidationError::new(
4522 1001,
4523 "sub_dept is shorter than the minimum length of 1".to_string(),
4524 ));
4525 }
4526 if val.chars().count() > 70 {
4527 return Err(ValidationError::new(
4528 1002,
4529 "sub_dept exceeds the maximum length of 70".to_string(),
4530 ));
4531 }
4532 }
4533 if let Some(ref val) = self.strt_nm {
4534 if val.chars().count() < 1 {
4535 return Err(ValidationError::new(
4536 1001,
4537 "strt_nm is shorter than the minimum length of 1".to_string(),
4538 ));
4539 }
4540 if val.chars().count() > 70 {
4541 return Err(ValidationError::new(
4542 1002,
4543 "strt_nm exceeds the maximum length of 70".to_string(),
4544 ));
4545 }
4546 }
4547 if let Some(ref val) = self.bldg_nb {
4548 if val.chars().count() < 1 {
4549 return Err(ValidationError::new(
4550 1001,
4551 "bldg_nb is shorter than the minimum length of 1".to_string(),
4552 ));
4553 }
4554 if val.chars().count() > 16 {
4555 return Err(ValidationError::new(
4556 1002,
4557 "bldg_nb exceeds the maximum length of 16".to_string(),
4558 ));
4559 }
4560 }
4561 if let Some(ref val) = self.bldg_nm {
4562 if val.chars().count() < 1 {
4563 return Err(ValidationError::new(
4564 1001,
4565 "bldg_nm is shorter than the minimum length of 1".to_string(),
4566 ));
4567 }
4568 if val.chars().count() > 35 {
4569 return Err(ValidationError::new(
4570 1002,
4571 "bldg_nm exceeds the maximum length of 35".to_string(),
4572 ));
4573 }
4574 }
4575 if let Some(ref val) = self.flr {
4576 if val.chars().count() < 1 {
4577 return Err(ValidationError::new(
4578 1001,
4579 "flr is shorter than the minimum length of 1".to_string(),
4580 ));
4581 }
4582 if val.chars().count() > 70 {
4583 return Err(ValidationError::new(
4584 1002,
4585 "flr exceeds the maximum length of 70".to_string(),
4586 ));
4587 }
4588 }
4589 if let Some(ref val) = self.pst_bx {
4590 if val.chars().count() < 1 {
4591 return Err(ValidationError::new(
4592 1001,
4593 "pst_bx is shorter than the minimum length of 1".to_string(),
4594 ));
4595 }
4596 if val.chars().count() > 16 {
4597 return Err(ValidationError::new(
4598 1002,
4599 "pst_bx exceeds the maximum length of 16".to_string(),
4600 ));
4601 }
4602 }
4603 if let Some(ref val) = self.room {
4604 if val.chars().count() < 1 {
4605 return Err(ValidationError::new(
4606 1001,
4607 "room is shorter than the minimum length of 1".to_string(),
4608 ));
4609 }
4610 if val.chars().count() > 70 {
4611 return Err(ValidationError::new(
4612 1002,
4613 "room exceeds the maximum length of 70".to_string(),
4614 ));
4615 }
4616 }
4617 if let Some(ref val) = self.pst_cd {
4618 if val.chars().count() < 1 {
4619 return Err(ValidationError::new(
4620 1001,
4621 "pst_cd is shorter than the minimum length of 1".to_string(),
4622 ));
4623 }
4624 if val.chars().count() > 16 {
4625 return Err(ValidationError::new(
4626 1002,
4627 "pst_cd exceeds the maximum length of 16".to_string(),
4628 ));
4629 }
4630 }
4631 if let Some(ref val) = self.twn_nm {
4632 if val.chars().count() < 1 {
4633 return Err(ValidationError::new(
4634 1001,
4635 "twn_nm is shorter than the minimum length of 1".to_string(),
4636 ));
4637 }
4638 if val.chars().count() > 35 {
4639 return Err(ValidationError::new(
4640 1002,
4641 "twn_nm exceeds the maximum length of 35".to_string(),
4642 ));
4643 }
4644 }
4645 if let Some(ref val) = self.twn_lctn_nm {
4646 if val.chars().count() < 1 {
4647 return Err(ValidationError::new(
4648 1001,
4649 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
4650 ));
4651 }
4652 if val.chars().count() > 35 {
4653 return Err(ValidationError::new(
4654 1002,
4655 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
4656 ));
4657 }
4658 }
4659 if let Some(ref val) = self.dstrct_nm {
4660 if val.chars().count() < 1 {
4661 return Err(ValidationError::new(
4662 1001,
4663 "dstrct_nm is shorter than the minimum length of 1".to_string(),
4664 ));
4665 }
4666 if val.chars().count() > 35 {
4667 return Err(ValidationError::new(
4668 1002,
4669 "dstrct_nm exceeds the maximum length of 35".to_string(),
4670 ));
4671 }
4672 }
4673 if let Some(ref val) = self.ctry_sub_dvsn {
4674 if val.chars().count() < 1 {
4675 return Err(ValidationError::new(
4676 1001,
4677 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
4678 ));
4679 }
4680 if val.chars().count() > 35 {
4681 return Err(ValidationError::new(
4682 1002,
4683 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
4684 ));
4685 }
4686 }
4687 if let Some(ref val) = self.ctry {
4688 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
4689 if !pattern.is_match(val) {
4690 return Err(ValidationError::new(
4691 1005,
4692 "ctry does not match the required pattern".to_string(),
4693 ));
4694 }
4695 }
4696 if let Some(ref vec) = self.adr_line {
4697 for item in vec {
4698 if item.chars().count() < 1 {
4699 return Err(ValidationError::new(
4700 1001,
4701 "adr_line is shorter than the minimum length of 1".to_string(),
4702 ));
4703 }
4704 if item.chars().count() > 70 {
4705 return Err(ValidationError::new(
4706 1002,
4707 "adr_line exceeds the maximum length of 70".to_string(),
4708 ));
4709 }
4710 }
4711 }
4712 Ok(())
4713 }
4714}
4715
4716#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4718pub struct PostalAddress243 {
4719 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
4720 pub dept: Option<String>,
4721 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
4722 pub sub_dept: Option<String>,
4723 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
4724 pub strt_nm: Option<String>,
4725 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
4726 pub bldg_nb: Option<String>,
4727 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
4728 pub bldg_nm: Option<String>,
4729 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
4730 pub flr: Option<String>,
4731 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
4732 pub pst_bx: Option<String>,
4733 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
4734 pub room: Option<String>,
4735 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
4736 pub pst_cd: Option<String>,
4737 #[serde(rename = "TwnNm")]
4738 pub twn_nm: String,
4739 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
4740 pub twn_lctn_nm: Option<String>,
4741 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
4742 pub dstrct_nm: Option<String>,
4743 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
4744 pub ctry_sub_dvsn: Option<String>,
4745 #[serde(rename = "Ctry")]
4746 pub ctry: String,
4747 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
4748 pub adr_line: Option<Vec<String>>,
4749}
4750
4751impl PostalAddress243 {
4752 pub fn validate(&self) -> Result<(), ValidationError> {
4753 if let Some(ref val) = self.dept {
4754 if val.chars().count() < 1 {
4755 return Err(ValidationError::new(
4756 1001,
4757 "dept is shorter than the minimum length of 1".to_string(),
4758 ));
4759 }
4760 if val.chars().count() > 70 {
4761 return Err(ValidationError::new(
4762 1002,
4763 "dept exceeds the maximum length of 70".to_string(),
4764 ));
4765 }
4766 let pattern = Regex::new(
4767 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4768 )
4769 .unwrap();
4770 if !pattern.is_match(val) {
4771 return Err(ValidationError::new(
4772 1005,
4773 "dept does not match the required pattern".to_string(),
4774 ));
4775 }
4776 }
4777 if let Some(ref val) = self.sub_dept {
4778 if val.chars().count() < 1 {
4779 return Err(ValidationError::new(
4780 1001,
4781 "sub_dept is shorter than the minimum length of 1".to_string(),
4782 ));
4783 }
4784 if val.chars().count() > 70 {
4785 return Err(ValidationError::new(
4786 1002,
4787 "sub_dept exceeds the maximum length of 70".to_string(),
4788 ));
4789 }
4790 let pattern = Regex::new(
4791 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4792 )
4793 .unwrap();
4794 if !pattern.is_match(val) {
4795 return Err(ValidationError::new(
4796 1005,
4797 "sub_dept does not match the required pattern".to_string(),
4798 ));
4799 }
4800 }
4801 if let Some(ref val) = self.strt_nm {
4802 if val.chars().count() < 1 {
4803 return Err(ValidationError::new(
4804 1001,
4805 "strt_nm is shorter than the minimum length of 1".to_string(),
4806 ));
4807 }
4808 if val.chars().count() > 70 {
4809 return Err(ValidationError::new(
4810 1002,
4811 "strt_nm exceeds the maximum length of 70".to_string(),
4812 ));
4813 }
4814 let pattern = Regex::new(
4815 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4816 )
4817 .unwrap();
4818 if !pattern.is_match(val) {
4819 return Err(ValidationError::new(
4820 1005,
4821 "strt_nm does not match the required pattern".to_string(),
4822 ));
4823 }
4824 }
4825 if let Some(ref val) = self.bldg_nb {
4826 if val.chars().count() < 1 {
4827 return Err(ValidationError::new(
4828 1001,
4829 "bldg_nb is shorter than the minimum length of 1".to_string(),
4830 ));
4831 }
4832 if val.chars().count() > 16 {
4833 return Err(ValidationError::new(
4834 1002,
4835 "bldg_nb exceeds the maximum length of 16".to_string(),
4836 ));
4837 }
4838 let pattern = Regex::new(
4839 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4840 )
4841 .unwrap();
4842 if !pattern.is_match(val) {
4843 return Err(ValidationError::new(
4844 1005,
4845 "bldg_nb does not match the required pattern".to_string(),
4846 ));
4847 }
4848 }
4849 if let Some(ref val) = self.bldg_nm {
4850 if val.chars().count() < 1 {
4851 return Err(ValidationError::new(
4852 1001,
4853 "bldg_nm is shorter than the minimum length of 1".to_string(),
4854 ));
4855 }
4856 if val.chars().count() > 35 {
4857 return Err(ValidationError::new(
4858 1002,
4859 "bldg_nm exceeds the maximum length of 35".to_string(),
4860 ));
4861 }
4862 let pattern = Regex::new(
4863 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4864 )
4865 .unwrap();
4866 if !pattern.is_match(val) {
4867 return Err(ValidationError::new(
4868 1005,
4869 "bldg_nm does not match the required pattern".to_string(),
4870 ));
4871 }
4872 }
4873 if let Some(ref val) = self.flr {
4874 if val.chars().count() < 1 {
4875 return Err(ValidationError::new(
4876 1001,
4877 "flr is shorter than the minimum length of 1".to_string(),
4878 ));
4879 }
4880 if val.chars().count() > 70 {
4881 return Err(ValidationError::new(
4882 1002,
4883 "flr exceeds the maximum length of 70".to_string(),
4884 ));
4885 }
4886 let pattern = Regex::new(
4887 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4888 )
4889 .unwrap();
4890 if !pattern.is_match(val) {
4891 return Err(ValidationError::new(
4892 1005,
4893 "flr does not match the required pattern".to_string(),
4894 ));
4895 }
4896 }
4897 if let Some(ref val) = self.pst_bx {
4898 if val.chars().count() < 1 {
4899 return Err(ValidationError::new(
4900 1001,
4901 "pst_bx is shorter than the minimum length of 1".to_string(),
4902 ));
4903 }
4904 if val.chars().count() > 16 {
4905 return Err(ValidationError::new(
4906 1002,
4907 "pst_bx exceeds the maximum length of 16".to_string(),
4908 ));
4909 }
4910 let pattern = Regex::new(
4911 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4912 )
4913 .unwrap();
4914 if !pattern.is_match(val) {
4915 return Err(ValidationError::new(
4916 1005,
4917 "pst_bx does not match the required pattern".to_string(),
4918 ));
4919 }
4920 }
4921 if let Some(ref val) = self.room {
4922 if val.chars().count() < 1 {
4923 return Err(ValidationError::new(
4924 1001,
4925 "room is shorter than the minimum length of 1".to_string(),
4926 ));
4927 }
4928 if val.chars().count() > 70 {
4929 return Err(ValidationError::new(
4930 1002,
4931 "room exceeds the maximum length of 70".to_string(),
4932 ));
4933 }
4934 let pattern = Regex::new(
4935 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4936 )
4937 .unwrap();
4938 if !pattern.is_match(val) {
4939 return Err(ValidationError::new(
4940 1005,
4941 "room does not match the required pattern".to_string(),
4942 ));
4943 }
4944 }
4945 if let Some(ref val) = self.pst_cd {
4946 if val.chars().count() < 1 {
4947 return Err(ValidationError::new(
4948 1001,
4949 "pst_cd is shorter than the minimum length of 1".to_string(),
4950 ));
4951 }
4952 if val.chars().count() > 16 {
4953 return Err(ValidationError::new(
4954 1002,
4955 "pst_cd exceeds the maximum length of 16".to_string(),
4956 ));
4957 }
4958 let pattern = Regex::new(
4959 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
4960 )
4961 .unwrap();
4962 if !pattern.is_match(val) {
4963 return Err(ValidationError::new(
4964 1005,
4965 "pst_cd does not match the required pattern".to_string(),
4966 ));
4967 }
4968 }
4969 if self.twn_nm.chars().count() < 1 {
4970 return Err(ValidationError::new(
4971 1001,
4972 "twn_nm is shorter than the minimum length of 1".to_string(),
4973 ));
4974 }
4975 if self.twn_nm.chars().count() > 35 {
4976 return Err(ValidationError::new(
4977 1002,
4978 "twn_nm exceeds the maximum length of 35".to_string(),
4979 ));
4980 }
4981 let pattern =
4982 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
4983 .unwrap();
4984 if !pattern.is_match(&self.twn_nm) {
4985 return Err(ValidationError::new(
4986 1005,
4987 "twn_nm does not match the required pattern".to_string(),
4988 ));
4989 }
4990 if let Some(ref val) = self.twn_lctn_nm {
4991 if val.chars().count() < 1 {
4992 return Err(ValidationError::new(
4993 1001,
4994 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
4995 ));
4996 }
4997 if val.chars().count() > 35 {
4998 return Err(ValidationError::new(
4999 1002,
5000 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
5001 ));
5002 }
5003 let pattern = Regex::new(
5004 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5005 )
5006 .unwrap();
5007 if !pattern.is_match(val) {
5008 return Err(ValidationError::new(
5009 1005,
5010 "twn_lctn_nm does not match the required pattern".to_string(),
5011 ));
5012 }
5013 }
5014 if let Some(ref val) = self.dstrct_nm {
5015 if val.chars().count() < 1 {
5016 return Err(ValidationError::new(
5017 1001,
5018 "dstrct_nm is shorter than the minimum length of 1".to_string(),
5019 ));
5020 }
5021 if val.chars().count() > 35 {
5022 return Err(ValidationError::new(
5023 1002,
5024 "dstrct_nm exceeds the maximum length of 35".to_string(),
5025 ));
5026 }
5027 let pattern = Regex::new(
5028 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5029 )
5030 .unwrap();
5031 if !pattern.is_match(val) {
5032 return Err(ValidationError::new(
5033 1005,
5034 "dstrct_nm does not match the required pattern".to_string(),
5035 ));
5036 }
5037 }
5038 if let Some(ref val) = self.ctry_sub_dvsn {
5039 if val.chars().count() < 1 {
5040 return Err(ValidationError::new(
5041 1001,
5042 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
5043 ));
5044 }
5045 if val.chars().count() > 35 {
5046 return Err(ValidationError::new(
5047 1002,
5048 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
5049 ));
5050 }
5051 let pattern = Regex::new(
5052 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5053 )
5054 .unwrap();
5055 if !pattern.is_match(val) {
5056 return Err(ValidationError::new(
5057 1005,
5058 "ctry_sub_dvsn does not match the required pattern".to_string(),
5059 ));
5060 }
5061 }
5062 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5063 if !pattern.is_match(&self.ctry) {
5064 return Err(ValidationError::new(
5065 1005,
5066 "ctry does not match the required pattern".to_string(),
5067 ));
5068 }
5069 if let Some(ref vec) = self.adr_line {
5070 for item in vec {
5071 if item.chars().count() < 1 {
5072 return Err(ValidationError::new(
5073 1001,
5074 "adr_line is shorter than the minimum length of 1".to_string(),
5075 ));
5076 }
5077 if item.chars().count() > 70 {
5078 return Err(ValidationError::new(
5079 1002,
5080 "adr_line exceeds the maximum length of 70".to_string(),
5081 ));
5082 }
5083 let pattern = Regex::new(
5084 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5085 )
5086 .unwrap();
5087 if !pattern.is_match(&item) {
5088 return Err(ValidationError::new(
5089 1005,
5090 "adr_line does not match the required pattern".to_string(),
5091 ));
5092 }
5093 }
5094 }
5095 Ok(())
5096 }
5097}
5098
5099#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5101pub struct PostalAddress244 {
5102 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
5103 pub dept: Option<String>,
5104 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
5105 pub sub_dept: Option<String>,
5106 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
5107 pub strt_nm: Option<String>,
5108 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
5109 pub bldg_nb: Option<String>,
5110 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
5111 pub bldg_nm: Option<String>,
5112 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
5113 pub flr: Option<String>,
5114 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
5115 pub pst_bx: Option<String>,
5116 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
5117 pub room: Option<String>,
5118 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
5119 pub pst_cd: Option<String>,
5120 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
5121 pub twn_nm: Option<String>,
5122 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
5123 pub twn_lctn_nm: Option<String>,
5124 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
5125 pub dstrct_nm: Option<String>,
5126 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
5127 pub ctry_sub_dvsn: Option<String>,
5128 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
5129 pub ctry: Option<String>,
5130 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
5131 pub adr_line: Option<Vec<String>>,
5132}
5133
5134impl PostalAddress244 {
5135 pub fn validate(&self) -> Result<(), ValidationError> {
5136 if let Some(ref val) = self.dept {
5137 if val.chars().count() < 1 {
5138 return Err(ValidationError::new(
5139 1001,
5140 "dept is shorter than the minimum length of 1".to_string(),
5141 ));
5142 }
5143 if val.chars().count() > 35 {
5144 return Err(ValidationError::new(
5145 1002,
5146 "dept exceeds the maximum length of 35".to_string(),
5147 ));
5148 }
5149 let pattern = Regex::new(
5150 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5151 )
5152 .unwrap();
5153 if !pattern.is_match(val) {
5154 return Err(ValidationError::new(
5155 1005,
5156 "dept does not match the required pattern".to_string(),
5157 ));
5158 }
5159 }
5160 if let Some(ref val) = self.sub_dept {
5161 if val.chars().count() < 1 {
5162 return Err(ValidationError::new(
5163 1001,
5164 "sub_dept is shorter than the minimum length of 1".to_string(),
5165 ));
5166 }
5167 if val.chars().count() > 35 {
5168 return Err(ValidationError::new(
5169 1002,
5170 "sub_dept exceeds the maximum length of 35".to_string(),
5171 ));
5172 }
5173 let pattern = Regex::new(
5174 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5175 )
5176 .unwrap();
5177 if !pattern.is_match(val) {
5178 return Err(ValidationError::new(
5179 1005,
5180 "sub_dept does not match the required pattern".to_string(),
5181 ));
5182 }
5183 }
5184 if let Some(ref val) = self.strt_nm {
5185 if val.chars().count() < 1 {
5186 return Err(ValidationError::new(
5187 1001,
5188 "strt_nm is shorter than the minimum length of 1".to_string(),
5189 ));
5190 }
5191 if val.chars().count() > 35 {
5192 return Err(ValidationError::new(
5193 1002,
5194 "strt_nm exceeds the maximum length of 35".to_string(),
5195 ));
5196 }
5197 let pattern = Regex::new(
5198 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5199 )
5200 .unwrap();
5201 if !pattern.is_match(val) {
5202 return Err(ValidationError::new(
5203 1005,
5204 "strt_nm does not match the required pattern".to_string(),
5205 ));
5206 }
5207 }
5208 if let Some(ref val) = self.bldg_nb {
5209 if val.chars().count() < 1 {
5210 return Err(ValidationError::new(
5211 1001,
5212 "bldg_nb is shorter than the minimum length of 1".to_string(),
5213 ));
5214 }
5215 if val.chars().count() > 16 {
5216 return Err(ValidationError::new(
5217 1002,
5218 "bldg_nb exceeds the maximum length of 16".to_string(),
5219 ));
5220 }
5221 let pattern = Regex::new(
5222 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5223 )
5224 .unwrap();
5225 if !pattern.is_match(val) {
5226 return Err(ValidationError::new(
5227 1005,
5228 "bldg_nb does not match the required pattern".to_string(),
5229 ));
5230 }
5231 }
5232 if let Some(ref val) = self.bldg_nm {
5233 if val.chars().count() < 1 {
5234 return Err(ValidationError::new(
5235 1001,
5236 "bldg_nm is shorter than the minimum length of 1".to_string(),
5237 ));
5238 }
5239 if val.chars().count() > 35 {
5240 return Err(ValidationError::new(
5241 1002,
5242 "bldg_nm exceeds the maximum length of 35".to_string(),
5243 ));
5244 }
5245 let pattern = Regex::new(
5246 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5247 )
5248 .unwrap();
5249 if !pattern.is_match(val) {
5250 return Err(ValidationError::new(
5251 1005,
5252 "bldg_nm does not match the required pattern".to_string(),
5253 ));
5254 }
5255 }
5256 if let Some(ref val) = self.flr {
5257 if val.chars().count() < 1 {
5258 return Err(ValidationError::new(
5259 1001,
5260 "flr is shorter than the minimum length of 1".to_string(),
5261 ));
5262 }
5263 if val.chars().count() > 35 {
5264 return Err(ValidationError::new(
5265 1002,
5266 "flr exceeds the maximum length of 35".to_string(),
5267 ));
5268 }
5269 let pattern = Regex::new(
5270 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5271 )
5272 .unwrap();
5273 if !pattern.is_match(val) {
5274 return Err(ValidationError::new(
5275 1005,
5276 "flr does not match the required pattern".to_string(),
5277 ));
5278 }
5279 }
5280 if let Some(ref val) = self.pst_bx {
5281 if val.chars().count() < 1 {
5282 return Err(ValidationError::new(
5283 1001,
5284 "pst_bx is shorter than the minimum length of 1".to_string(),
5285 ));
5286 }
5287 if val.chars().count() > 16 {
5288 return Err(ValidationError::new(
5289 1002,
5290 "pst_bx exceeds the maximum length of 16".to_string(),
5291 ));
5292 }
5293 let pattern = Regex::new(
5294 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5295 )
5296 .unwrap();
5297 if !pattern.is_match(val) {
5298 return Err(ValidationError::new(
5299 1005,
5300 "pst_bx does not match the required pattern".to_string(),
5301 ));
5302 }
5303 }
5304 if let Some(ref val) = self.room {
5305 if val.chars().count() < 1 {
5306 return Err(ValidationError::new(
5307 1001,
5308 "room is shorter than the minimum length of 1".to_string(),
5309 ));
5310 }
5311 if val.chars().count() > 35 {
5312 return Err(ValidationError::new(
5313 1002,
5314 "room exceeds the maximum length of 35".to_string(),
5315 ));
5316 }
5317 let pattern = Regex::new(
5318 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5319 )
5320 .unwrap();
5321 if !pattern.is_match(val) {
5322 return Err(ValidationError::new(
5323 1005,
5324 "room does not match the required pattern".to_string(),
5325 ));
5326 }
5327 }
5328 if let Some(ref val) = self.pst_cd {
5329 if val.chars().count() < 1 {
5330 return Err(ValidationError::new(
5331 1001,
5332 "pst_cd is shorter than the minimum length of 1".to_string(),
5333 ));
5334 }
5335 if val.chars().count() > 16 {
5336 return Err(ValidationError::new(
5337 1002,
5338 "pst_cd exceeds the maximum length of 16".to_string(),
5339 ));
5340 }
5341 let pattern = Regex::new(
5342 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5343 )
5344 .unwrap();
5345 if !pattern.is_match(val) {
5346 return Err(ValidationError::new(
5347 1005,
5348 "pst_cd does not match the required pattern".to_string(),
5349 ));
5350 }
5351 }
5352 if let Some(ref val) = self.twn_nm {
5353 if val.chars().count() < 1 {
5354 return Err(ValidationError::new(
5355 1001,
5356 "twn_nm is shorter than the minimum length of 1".to_string(),
5357 ));
5358 }
5359 if val.chars().count() > 35 {
5360 return Err(ValidationError::new(
5361 1002,
5362 "twn_nm exceeds the maximum length of 35".to_string(),
5363 ));
5364 }
5365 let pattern = Regex::new(
5366 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5367 )
5368 .unwrap();
5369 if !pattern.is_match(val) {
5370 return Err(ValidationError::new(
5371 1005,
5372 "twn_nm does not match the required pattern".to_string(),
5373 ));
5374 }
5375 }
5376 if let Some(ref val) = self.twn_lctn_nm {
5377 if val.chars().count() < 1 {
5378 return Err(ValidationError::new(
5379 1001,
5380 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
5381 ));
5382 }
5383 if val.chars().count() > 35 {
5384 return Err(ValidationError::new(
5385 1002,
5386 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
5387 ));
5388 }
5389 let pattern = Regex::new(
5390 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5391 )
5392 .unwrap();
5393 if !pattern.is_match(val) {
5394 return Err(ValidationError::new(
5395 1005,
5396 "twn_lctn_nm does not match the required pattern".to_string(),
5397 ));
5398 }
5399 }
5400 if let Some(ref val) = self.dstrct_nm {
5401 if val.chars().count() < 1 {
5402 return Err(ValidationError::new(
5403 1001,
5404 "dstrct_nm is shorter than the minimum length of 1".to_string(),
5405 ));
5406 }
5407 if val.chars().count() > 35 {
5408 return Err(ValidationError::new(
5409 1002,
5410 "dstrct_nm exceeds the maximum length of 35".to_string(),
5411 ));
5412 }
5413 let pattern = Regex::new(
5414 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5415 )
5416 .unwrap();
5417 if !pattern.is_match(val) {
5418 return Err(ValidationError::new(
5419 1005,
5420 "dstrct_nm does not match the required pattern".to_string(),
5421 ));
5422 }
5423 }
5424 if let Some(ref val) = self.ctry_sub_dvsn {
5425 if val.chars().count() < 1 {
5426 return Err(ValidationError::new(
5427 1001,
5428 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
5429 ));
5430 }
5431 if val.chars().count() > 35 {
5432 return Err(ValidationError::new(
5433 1002,
5434 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
5435 ));
5436 }
5437 let pattern = Regex::new(
5438 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5439 )
5440 .unwrap();
5441 if !pattern.is_match(val) {
5442 return Err(ValidationError::new(
5443 1005,
5444 "ctry_sub_dvsn does not match the required pattern".to_string(),
5445 ));
5446 }
5447 }
5448 if let Some(ref val) = self.ctry {
5449 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5450 if !pattern.is_match(val) {
5451 return Err(ValidationError::new(
5452 1005,
5453 "ctry does not match the required pattern".to_string(),
5454 ));
5455 }
5456 }
5457 if let Some(ref vec) = self.adr_line {
5458 for item in vec {
5459 if item.chars().count() < 1 {
5460 return Err(ValidationError::new(
5461 1001,
5462 "adr_line is shorter than the minimum length of 1".to_string(),
5463 ));
5464 }
5465 if item.chars().count() > 70 {
5466 return Err(ValidationError::new(
5467 1002,
5468 "adr_line exceeds the maximum length of 70".to_string(),
5469 ));
5470 }
5471 let pattern = Regex::new(
5472 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5473 )
5474 .unwrap();
5475 if !pattern.is_match(&item) {
5476 return Err(ValidationError::new(
5477 1005,
5478 "adr_line does not match the required pattern".to_string(),
5479 ));
5480 }
5481 }
5482 }
5483 Ok(())
5484 }
5485}
5486
5487#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5489pub struct PostalAddress245 {
5490 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
5491 pub dept: Option<String>,
5492 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
5493 pub sub_dept: Option<String>,
5494 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
5495 pub strt_nm: Option<String>,
5496 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
5497 pub bldg_nb: Option<String>,
5498 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
5499 pub bldg_nm: Option<String>,
5500 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
5501 pub flr: Option<String>,
5502 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
5503 pub pst_bx: Option<String>,
5504 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
5505 pub room: Option<String>,
5506 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
5507 pub pst_cd: Option<String>,
5508 #[serde(rename = "TwnNm")]
5509 pub twn_nm: String,
5510 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
5511 pub twn_lctn_nm: Option<String>,
5512 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
5513 pub dstrct_nm: Option<String>,
5514 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
5515 pub ctry_sub_dvsn: Option<String>,
5516 #[serde(rename = "Ctry")]
5517 pub ctry: String,
5518 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
5519 pub adr_line: Option<Vec<String>>,
5520}
5521
5522impl PostalAddress245 {
5523 pub fn validate(&self) -> Result<(), ValidationError> {
5524 if let Some(ref val) = self.dept {
5525 if val.chars().count() < 1 {
5526 return Err(ValidationError::new(
5527 1001,
5528 "dept is shorter than the minimum length of 1".to_string(),
5529 ));
5530 }
5531 if val.chars().count() > 70 {
5532 return Err(ValidationError::new(
5533 1002,
5534 "dept exceeds the maximum length of 70".to_string(),
5535 ));
5536 }
5537 let pattern = Regex::new(
5538 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5539 )
5540 .unwrap();
5541 if !pattern.is_match(val) {
5542 return Err(ValidationError::new(
5543 1005,
5544 "dept does not match the required pattern".to_string(),
5545 ));
5546 }
5547 }
5548 if let Some(ref val) = self.sub_dept {
5549 if val.chars().count() < 1 {
5550 return Err(ValidationError::new(
5551 1001,
5552 "sub_dept is shorter than the minimum length of 1".to_string(),
5553 ));
5554 }
5555 if val.chars().count() > 70 {
5556 return Err(ValidationError::new(
5557 1002,
5558 "sub_dept exceeds the maximum length of 70".to_string(),
5559 ));
5560 }
5561 let pattern = Regex::new(
5562 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5563 )
5564 .unwrap();
5565 if !pattern.is_match(val) {
5566 return Err(ValidationError::new(
5567 1005,
5568 "sub_dept does not match the required pattern".to_string(),
5569 ));
5570 }
5571 }
5572 if let Some(ref val) = self.strt_nm {
5573 if val.chars().count() < 1 {
5574 return Err(ValidationError::new(
5575 1001,
5576 "strt_nm is shorter than the minimum length of 1".to_string(),
5577 ));
5578 }
5579 if val.chars().count() > 70 {
5580 return Err(ValidationError::new(
5581 1002,
5582 "strt_nm exceeds the maximum length of 70".to_string(),
5583 ));
5584 }
5585 let pattern = Regex::new(
5586 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5587 )
5588 .unwrap();
5589 if !pattern.is_match(val) {
5590 return Err(ValidationError::new(
5591 1005,
5592 "strt_nm does not match the required pattern".to_string(),
5593 ));
5594 }
5595 }
5596 if let Some(ref val) = self.bldg_nb {
5597 if val.chars().count() < 1 {
5598 return Err(ValidationError::new(
5599 1001,
5600 "bldg_nb is shorter than the minimum length of 1".to_string(),
5601 ));
5602 }
5603 if val.chars().count() > 16 {
5604 return Err(ValidationError::new(
5605 1002,
5606 "bldg_nb exceeds the maximum length of 16".to_string(),
5607 ));
5608 }
5609 let pattern = Regex::new(
5610 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5611 )
5612 .unwrap();
5613 if !pattern.is_match(val) {
5614 return Err(ValidationError::new(
5615 1005,
5616 "bldg_nb does not match the required pattern".to_string(),
5617 ));
5618 }
5619 }
5620 if let Some(ref val) = self.bldg_nm {
5621 if val.chars().count() < 1 {
5622 return Err(ValidationError::new(
5623 1001,
5624 "bldg_nm is shorter than the minimum length of 1".to_string(),
5625 ));
5626 }
5627 if val.chars().count() > 35 {
5628 return Err(ValidationError::new(
5629 1002,
5630 "bldg_nm exceeds the maximum length of 35".to_string(),
5631 ));
5632 }
5633 let pattern = Regex::new(
5634 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5635 )
5636 .unwrap();
5637 if !pattern.is_match(val) {
5638 return Err(ValidationError::new(
5639 1005,
5640 "bldg_nm does not match the required pattern".to_string(),
5641 ));
5642 }
5643 }
5644 if let Some(ref val) = self.flr {
5645 if val.chars().count() < 1 {
5646 return Err(ValidationError::new(
5647 1001,
5648 "flr is shorter than the minimum length of 1".to_string(),
5649 ));
5650 }
5651 if val.chars().count() > 70 {
5652 return Err(ValidationError::new(
5653 1002,
5654 "flr exceeds the maximum length of 70".to_string(),
5655 ));
5656 }
5657 let pattern = Regex::new(
5658 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5659 )
5660 .unwrap();
5661 if !pattern.is_match(val) {
5662 return Err(ValidationError::new(
5663 1005,
5664 "flr does not match the required pattern".to_string(),
5665 ));
5666 }
5667 }
5668 if let Some(ref val) = self.pst_bx {
5669 if val.chars().count() < 1 {
5670 return Err(ValidationError::new(
5671 1001,
5672 "pst_bx is shorter than the minimum length of 1".to_string(),
5673 ));
5674 }
5675 if val.chars().count() > 16 {
5676 return Err(ValidationError::new(
5677 1002,
5678 "pst_bx exceeds the maximum length of 16".to_string(),
5679 ));
5680 }
5681 let pattern = Regex::new(
5682 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5683 )
5684 .unwrap();
5685 if !pattern.is_match(val) {
5686 return Err(ValidationError::new(
5687 1005,
5688 "pst_bx does not match the required pattern".to_string(),
5689 ));
5690 }
5691 }
5692 if let Some(ref val) = self.room {
5693 if val.chars().count() < 1 {
5694 return Err(ValidationError::new(
5695 1001,
5696 "room is shorter than the minimum length of 1".to_string(),
5697 ));
5698 }
5699 if val.chars().count() > 70 {
5700 return Err(ValidationError::new(
5701 1002,
5702 "room exceeds the maximum length of 70".to_string(),
5703 ));
5704 }
5705 let pattern = Regex::new(
5706 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5707 )
5708 .unwrap();
5709 if !pattern.is_match(val) {
5710 return Err(ValidationError::new(
5711 1005,
5712 "room does not match the required pattern".to_string(),
5713 ));
5714 }
5715 }
5716 if let Some(ref val) = self.pst_cd {
5717 if val.chars().count() < 1 {
5718 return Err(ValidationError::new(
5719 1001,
5720 "pst_cd is shorter than the minimum length of 1".to_string(),
5721 ));
5722 }
5723 if val.chars().count() > 16 {
5724 return Err(ValidationError::new(
5725 1002,
5726 "pst_cd exceeds the maximum length of 16".to_string(),
5727 ));
5728 }
5729 let pattern = Regex::new(
5730 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5731 )
5732 .unwrap();
5733 if !pattern.is_match(val) {
5734 return Err(ValidationError::new(
5735 1005,
5736 "pst_cd does not match the required pattern".to_string(),
5737 ));
5738 }
5739 }
5740 if self.twn_nm.chars().count() < 1 {
5741 return Err(ValidationError::new(
5742 1001,
5743 "twn_nm is shorter than the minimum length of 1".to_string(),
5744 ));
5745 }
5746 if self.twn_nm.chars().count() > 35 {
5747 return Err(ValidationError::new(
5748 1002,
5749 "twn_nm exceeds the maximum length of 35".to_string(),
5750 ));
5751 }
5752 if let Some(ref val) = self.twn_lctn_nm {
5753 if val.chars().count() < 1 {
5754 return Err(ValidationError::new(
5755 1001,
5756 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
5757 ));
5758 }
5759 if val.chars().count() > 35 {
5760 return Err(ValidationError::new(
5761 1002,
5762 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
5763 ));
5764 }
5765 let pattern = Regex::new(
5766 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5767 )
5768 .unwrap();
5769 if !pattern.is_match(val) {
5770 return Err(ValidationError::new(
5771 1005,
5772 "twn_lctn_nm does not match the required pattern".to_string(),
5773 ));
5774 }
5775 }
5776 if let Some(ref val) = self.dstrct_nm {
5777 if val.chars().count() < 1 {
5778 return Err(ValidationError::new(
5779 1001,
5780 "dstrct_nm is shorter than the minimum length of 1".to_string(),
5781 ));
5782 }
5783 if val.chars().count() > 35 {
5784 return Err(ValidationError::new(
5785 1002,
5786 "dstrct_nm exceeds the maximum length of 35".to_string(),
5787 ));
5788 }
5789 let pattern = Regex::new(
5790 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5791 )
5792 .unwrap();
5793 if !pattern.is_match(val) {
5794 return Err(ValidationError::new(
5795 1005,
5796 "dstrct_nm does not match the required pattern".to_string(),
5797 ));
5798 }
5799 }
5800 if let Some(ref val) = self.ctry_sub_dvsn {
5801 if val.chars().count() < 1 {
5802 return Err(ValidationError::new(
5803 1001,
5804 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
5805 ));
5806 }
5807 if val.chars().count() > 35 {
5808 return Err(ValidationError::new(
5809 1002,
5810 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
5811 ));
5812 }
5813 let pattern = Regex::new(
5814 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5815 )
5816 .unwrap();
5817 if !pattern.is_match(val) {
5818 return Err(ValidationError::new(
5819 1005,
5820 "ctry_sub_dvsn does not match the required pattern".to_string(),
5821 ));
5822 }
5823 }
5824 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
5825 if !pattern.is_match(&self.ctry) {
5826 return Err(ValidationError::new(
5827 1005,
5828 "ctry does not match the required pattern".to_string(),
5829 ));
5830 }
5831 if let Some(ref vec) = self.adr_line {
5832 for item in vec {
5833 if item.chars().count() < 1 {
5834 return Err(ValidationError::new(
5835 1001,
5836 "adr_line is shorter than the minimum length of 1".to_string(),
5837 ));
5838 }
5839 if item.chars().count() > 70 {
5840 return Err(ValidationError::new(
5841 1002,
5842 "adr_line exceeds the maximum length of 70".to_string(),
5843 ));
5844 }
5845 let pattern = Regex::new(
5846 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
5847 )
5848 .unwrap();
5849 if !pattern.is_match(&item) {
5850 return Err(ValidationError::new(
5851 1005,
5852 "adr_line does not match the required pattern".to_string(),
5853 ));
5854 }
5855 }
5856 }
5857 Ok(())
5858 }
5859}
5860
5861#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5863pub enum Priority2Code {
5864 #[default]
5865 #[serde(rename = "HIGH")]
5866 CodeHIGH,
5867 #[serde(rename = "NORM")]
5868 CodeNORM,
5869}
5870
5871impl Priority2Code {
5872 pub fn validate(&self) -> Result<(), ValidationError> {
5873 Ok(())
5874 }
5875}
5876
5877#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5879pub enum Priority3Code {
5880 #[default]
5881 #[serde(rename = "URGT")]
5882 CodeURGT,
5883 #[serde(rename = "HIGH")]
5884 CodeHIGH,
5885 #[serde(rename = "NORM")]
5886 CodeNORM,
5887}
5888
5889impl Priority3Code {
5890 pub fn validate(&self) -> Result<(), ValidationError> {
5891 Ok(())
5892 }
5893}
5894
5895#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5897pub struct ProxyAccountIdentification11 {
5898 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
5899 pub tp: Option<ProxyAccountType1Choice>,
5900 #[serde(rename = "Id")]
5901 pub id: String,
5902}
5903
5904impl ProxyAccountIdentification11 {
5905 pub fn validate(&self) -> Result<(), ValidationError> {
5906 if let Some(ref val) = self.tp {
5907 val.validate()?
5908 }
5909 if self.id.chars().count() < 1 {
5910 return Err(ValidationError::new(
5911 1001,
5912 "id is shorter than the minimum length of 1".to_string(),
5913 ));
5914 }
5915 if self.id.chars().count() > 320 {
5916 return Err(ValidationError::new(
5917 1002,
5918 "id exceeds the maximum length of 320".to_string(),
5919 ));
5920 }
5921 let pattern =
5922 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
5923 .unwrap();
5924 if !pattern.is_match(&self.id) {
5925 return Err(ValidationError::new(
5926 1005,
5927 "id does not match the required pattern".to_string(),
5928 ));
5929 }
5930 Ok(())
5931 }
5932}
5933
5934#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5936pub struct ProxyAccountIdentification12 {
5937 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
5938 pub tp: Option<ProxyAccountType1Choice1>,
5939 #[serde(rename = "Id")]
5940 pub id: String,
5941}
5942
5943impl ProxyAccountIdentification12 {
5944 pub fn validate(&self) -> Result<(), ValidationError> {
5945 if let Some(ref val) = self.tp {
5946 val.validate()?
5947 }
5948 if self.id.chars().count() < 1 {
5949 return Err(ValidationError::new(
5950 1001,
5951 "id is shorter than the minimum length of 1".to_string(),
5952 ));
5953 }
5954 if self.id.chars().count() > 320 {
5955 return Err(ValidationError::new(
5956 1002,
5957 "id exceeds the maximum length of 320".to_string(),
5958 ));
5959 }
5960 let pattern =
5961 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
5962 .unwrap();
5963 if !pattern.is_match(&self.id) {
5964 return Err(ValidationError::new(
5965 1005,
5966 "id does not match the required pattern".to_string(),
5967 ));
5968 }
5969 Ok(())
5970 }
5971}
5972
5973#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
5975pub struct ProxyAccountType1Choice {
5976 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
5977 pub cd: Option<String>,
5978 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
5979 pub prtry: Option<String>,
5980}
5981
5982impl ProxyAccountType1Choice {
5983 pub fn validate(&self) -> Result<(), ValidationError> {
5984 if let Some(ref val) = self.cd {
5985 if val.chars().count() < 1 {
5986 return Err(ValidationError::new(
5987 1001,
5988 "cd is shorter than the minimum length of 1".to_string(),
5989 ));
5990 }
5991 if val.chars().count() > 4 {
5992 return Err(ValidationError::new(
5993 1002,
5994 "cd exceeds the maximum length of 4".to_string(),
5995 ));
5996 }
5997 }
5998 if let Some(ref val) = self.prtry {
5999 if val.chars().count() < 1 {
6000 return Err(ValidationError::new(
6001 1001,
6002 "prtry is shorter than the minimum length of 1".to_string(),
6003 ));
6004 }
6005 if val.chars().count() > 35 {
6006 return Err(ValidationError::new(
6007 1002,
6008 "prtry exceeds the maximum length of 35".to_string(),
6009 ));
6010 }
6011 }
6012 Ok(())
6013 }
6014}
6015
6016#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6018pub struct ProxyAccountType1Choice1 {
6019 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6020 pub cd: Option<String>,
6021 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6022 pub prtry: Option<String>,
6023}
6024
6025impl ProxyAccountType1Choice1 {
6026 pub fn validate(&self) -> Result<(), ValidationError> {
6027 if let Some(ref val) = self.cd {
6028 if val.chars().count() < 1 {
6029 return Err(ValidationError::new(
6030 1001,
6031 "cd is shorter than the minimum length of 1".to_string(),
6032 ));
6033 }
6034 if val.chars().count() > 4 {
6035 return Err(ValidationError::new(
6036 1002,
6037 "cd exceeds the maximum length of 4".to_string(),
6038 ));
6039 }
6040 }
6041 if let Some(ref val) = self.prtry {
6042 if val.chars().count() < 1 {
6043 return Err(ValidationError::new(
6044 1001,
6045 "prtry is shorter than the minimum length of 1".to_string(),
6046 ));
6047 }
6048 if val.chars().count() > 35 {
6049 return Err(ValidationError::new(
6050 1002,
6051 "prtry exceeds the maximum length of 35".to_string(),
6052 ));
6053 }
6054 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6055 if !pattern.is_match(val) {
6056 return Err(ValidationError::new(
6057 1005,
6058 "prtry does not match the required pattern".to_string(),
6059 ));
6060 }
6061 }
6062 Ok(())
6063 }
6064}
6065
6066#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6068pub struct Purpose2Choice1 {
6069 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6070 pub cd: Option<String>,
6071 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6072 pub prtry: Option<String>,
6073}
6074
6075impl Purpose2Choice1 {
6076 pub fn validate(&self) -> Result<(), ValidationError> {
6077 if let Some(ref val) = self.cd {
6078 if val.chars().count() < 1 {
6079 return Err(ValidationError::new(
6080 1001,
6081 "cd is shorter than the minimum length of 1".to_string(),
6082 ));
6083 }
6084 if val.chars().count() > 4 {
6085 return Err(ValidationError::new(
6086 1002,
6087 "cd exceeds the maximum length of 4".to_string(),
6088 ));
6089 }
6090 }
6091 if let Some(ref val) = self.prtry {
6092 if val.chars().count() < 1 {
6093 return Err(ValidationError::new(
6094 1001,
6095 "prtry is shorter than the minimum length of 1".to_string(),
6096 ));
6097 }
6098 if val.chars().count() > 35 {
6099 return Err(ValidationError::new(
6100 1002,
6101 "prtry exceeds the maximum length of 35".to_string(),
6102 ));
6103 }
6104 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6105 if !pattern.is_match(val) {
6106 return Err(ValidationError::new(
6107 1005,
6108 "prtry does not match the required pattern".to_string(),
6109 ));
6110 }
6111 }
6112 Ok(())
6113 }
6114}
6115
6116#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6118pub struct ReferredDocumentInformation71 {
6119 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6120 pub tp: Option<ReferredDocumentType41>,
6121 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
6122 pub nb: Option<String>,
6123 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
6124 pub rltd_dt: Option<String>,
6125 #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
6126 pub line_dtls: Option<Vec<DocumentLineInformation11>>,
6127}
6128
6129impl ReferredDocumentInformation71 {
6130 pub fn validate(&self) -> Result<(), ValidationError> {
6131 if let Some(ref val) = self.tp {
6132 val.validate()?
6133 }
6134 if let Some(ref val) = self.nb {
6135 if val.chars().count() < 1 {
6136 return Err(ValidationError::new(
6137 1001,
6138 "nb is shorter than the minimum length of 1".to_string(),
6139 ));
6140 }
6141 if val.chars().count() > 35 {
6142 return Err(ValidationError::new(
6143 1002,
6144 "nb exceeds the maximum length of 35".to_string(),
6145 ));
6146 }
6147 let pattern = Regex::new(
6148 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6149 )
6150 .unwrap();
6151 if !pattern.is_match(val) {
6152 return Err(ValidationError::new(
6153 1005,
6154 "nb does not match the required pattern".to_string(),
6155 ));
6156 }
6157 }
6158 if let Some(ref vec) = self.line_dtls {
6159 for item in vec {
6160 item.validate()?
6161 }
6162 }
6163 Ok(())
6164 }
6165}
6166
6167#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6169pub struct ReferredDocumentType3Choice {
6170 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6171 pub cd: Option<DocumentType6Code>,
6172 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6173 pub prtry: Option<String>,
6174}
6175
6176impl ReferredDocumentType3Choice {
6177 pub fn validate(&self) -> Result<(), ValidationError> {
6178 if let Some(ref val) = self.cd {
6179 val.validate()?
6180 }
6181 if let Some(ref val) = self.prtry {
6182 if val.chars().count() < 1 {
6183 return Err(ValidationError::new(
6184 1001,
6185 "prtry is shorter than the minimum length of 1".to_string(),
6186 ));
6187 }
6188 if val.chars().count() > 35 {
6189 return Err(ValidationError::new(
6190 1002,
6191 "prtry exceeds the maximum length of 35".to_string(),
6192 ));
6193 }
6194 }
6195 Ok(())
6196 }
6197}
6198
6199#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6201pub struct ReferredDocumentType41 {
6202 #[serde(rename = "CdOrPrtry")]
6203 pub cd_or_prtry: ReferredDocumentType3Choice,
6204 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
6205 pub issr: Option<String>,
6206}
6207
6208impl ReferredDocumentType41 {
6209 pub fn validate(&self) -> Result<(), ValidationError> {
6210 self.cd_or_prtry.validate()?;
6211 if let Some(ref val) = self.issr {
6212 if val.chars().count() < 1 {
6213 return Err(ValidationError::new(
6214 1001,
6215 "issr is shorter than the minimum length of 1".to_string(),
6216 ));
6217 }
6218 if val.chars().count() > 35 {
6219 return Err(ValidationError::new(
6220 1002,
6221 "issr exceeds the maximum length of 35".to_string(),
6222 ));
6223 }
6224 let pattern = Regex::new(
6225 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6226 )
6227 .unwrap();
6228 if !pattern.is_match(val) {
6229 return Err(ValidationError::new(
6230 1005,
6231 "issr does not match the required pattern".to_string(),
6232 ));
6233 }
6234 }
6235 Ok(())
6236 }
6237}
6238
6239#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6241pub struct RegulatoryAuthority21 {
6242 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
6243 pub nm: Option<String>,
6244 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
6245 pub ctry: Option<String>,
6246}
6247
6248impl RegulatoryAuthority21 {
6249 pub fn validate(&self) -> Result<(), ValidationError> {
6250 if let Some(ref val) = self.nm {
6251 if val.chars().count() < 1 {
6252 return Err(ValidationError::new(
6253 1001,
6254 "nm is shorter than the minimum length of 1".to_string(),
6255 ));
6256 }
6257 if val.chars().count() > 140 {
6258 return Err(ValidationError::new(
6259 1002,
6260 "nm exceeds the maximum length of 140".to_string(),
6261 ));
6262 }
6263 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6264 if !pattern.is_match(val) {
6265 return Err(ValidationError::new(
6266 1005,
6267 "nm does not match the required pattern".to_string(),
6268 ));
6269 }
6270 }
6271 if let Some(ref val) = self.ctry {
6272 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
6273 if !pattern.is_match(val) {
6274 return Err(ValidationError::new(
6275 1005,
6276 "ctry does not match the required pattern".to_string(),
6277 ));
6278 }
6279 }
6280 Ok(())
6281 }
6282}
6283
6284#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6286pub struct RegulatoryReporting31 {
6287 #[serde(rename = "DbtCdtRptgInd", skip_serializing_if = "Option::is_none")]
6288 pub dbt_cdt_rptg_ind: Option<RegulatoryReportingType1Code>,
6289 #[serde(rename = "Authrty", skip_serializing_if = "Option::is_none")]
6290 pub authrty: Option<RegulatoryAuthority21>,
6291 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
6292 pub dtls: Option<Vec<StructuredRegulatoryReporting31>>,
6293}
6294
6295impl RegulatoryReporting31 {
6296 pub fn validate(&self) -> Result<(), ValidationError> {
6297 if let Some(ref val) = self.dbt_cdt_rptg_ind {
6298 val.validate()?
6299 }
6300 if let Some(ref val) = self.authrty {
6301 val.validate()?
6302 }
6303 if let Some(ref vec) = self.dtls {
6304 for item in vec {
6305 item.validate()?
6306 }
6307 }
6308 Ok(())
6309 }
6310}
6311
6312#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6314pub enum RegulatoryReportingType1Code {
6315 #[default]
6316 #[serde(rename = "CRED")]
6317 CodeCRED,
6318 #[serde(rename = "DEBT")]
6319 CodeDEBT,
6320 #[serde(rename = "BOTH")]
6321 CodeBOTH,
6322}
6323
6324impl RegulatoryReportingType1Code {
6325 pub fn validate(&self) -> Result<(), ValidationError> {
6326 Ok(())
6327 }
6328}
6329
6330#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6332pub struct RemittanceAmount2 {
6333 #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
6334 pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6335 #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
6336 pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
6337 #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
6338 pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6339 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
6340 pub tax_amt: Option<Vec<TaxAmountAndType1>>,
6341 #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
6342 pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
6343 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
6344 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6345}
6346
6347impl RemittanceAmount2 {
6348 pub fn validate(&self) -> Result<(), ValidationError> {
6349 if let Some(ref val) = self.due_pybl_amt {
6350 val.validate()?
6351 }
6352 if let Some(ref vec) = self.dscnt_apld_amt {
6353 for item in vec {
6354 item.validate()?
6355 }
6356 }
6357 if let Some(ref val) = self.cdt_note_amt {
6358 val.validate()?
6359 }
6360 if let Some(ref vec) = self.tax_amt {
6361 for item in vec {
6362 item.validate()?
6363 }
6364 }
6365 if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
6366 for item in vec {
6367 item.validate()?
6368 }
6369 }
6370 if let Some(ref val) = self.rmtd_amt {
6371 val.validate()?
6372 }
6373 Ok(())
6374 }
6375}
6376
6377#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6379pub struct RemittanceAmount31 {
6380 #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
6381 pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6382 #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
6383 pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType11>>,
6384 #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
6385 pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6386 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
6387 pub tax_amt: Option<Vec<TaxAmountAndType11>>,
6388 #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
6389 pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment11>>,
6390 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
6391 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6392}
6393
6394impl RemittanceAmount31 {
6395 pub fn validate(&self) -> Result<(), ValidationError> {
6396 if let Some(ref val) = self.due_pybl_amt {
6397 val.validate()?
6398 }
6399 if let Some(ref vec) = self.dscnt_apld_amt {
6400 for item in vec {
6401 item.validate()?
6402 }
6403 }
6404 if let Some(ref val) = self.cdt_note_amt {
6405 val.validate()?
6406 }
6407 if let Some(ref vec) = self.tax_amt {
6408 for item in vec {
6409 item.validate()?
6410 }
6411 }
6412 if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
6413 for item in vec {
6414 item.validate()?
6415 }
6416 }
6417 if let Some(ref val) = self.rmtd_amt {
6418 val.validate()?
6419 }
6420 Ok(())
6421 }
6422}
6423
6424#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6426pub struct RemittanceInformation161 {
6427 #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
6428 pub ustrd: Option<String>,
6429 #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
6430 pub strd: Option<Vec<StructuredRemittanceInformation161>>,
6431}
6432
6433impl RemittanceInformation161 {
6434 pub fn validate(&self) -> Result<(), ValidationError> {
6435 if let Some(ref val) = self.ustrd {
6436 if val.chars().count() < 1 {
6437 return Err(ValidationError::new(
6438 1001,
6439 "ustrd is shorter than the minimum length of 1".to_string(),
6440 ));
6441 }
6442 if val.chars().count() > 140 {
6443 return Err(ValidationError::new(
6444 1002,
6445 "ustrd exceeds the maximum length of 140".to_string(),
6446 ));
6447 }
6448 let pattern = Regex::new(
6449 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6450 )
6451 .unwrap();
6452 if !pattern.is_match(val) {
6453 return Err(ValidationError::new(
6454 1005,
6455 "ustrd does not match the required pattern".to_string(),
6456 ));
6457 }
6458 }
6459 if let Some(ref vec) = self.strd {
6460 for item in vec {
6461 item.validate()?
6462 }
6463 }
6464 Ok(())
6465 }
6466}
6467
6468#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6470pub struct RemittanceLocation71 {
6471 #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
6472 pub rmt_id: Option<String>,
6473 #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
6474 pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData11>>,
6475}
6476
6477impl RemittanceLocation71 {
6478 pub fn validate(&self) -> Result<(), ValidationError> {
6479 if let Some(ref val) = self.rmt_id {
6480 if val.chars().count() < 1 {
6481 return Err(ValidationError::new(
6482 1001,
6483 "rmt_id is shorter than the minimum length of 1".to_string(),
6484 ));
6485 }
6486 if val.chars().count() > 35 {
6487 return Err(ValidationError::new(
6488 1002,
6489 "rmt_id exceeds the maximum length of 35".to_string(),
6490 ));
6491 }
6492 let pattern = Regex::new(
6493 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6494 )
6495 .unwrap();
6496 if !pattern.is_match(val) {
6497 return Err(ValidationError::new(
6498 1005,
6499 "rmt_id does not match the required pattern".to_string(),
6500 ));
6501 }
6502 }
6503 if let Some(ref vec) = self.rmt_lctn_dtls {
6504 for item in vec {
6505 item.validate()?
6506 }
6507 }
6508 Ok(())
6509 }
6510}
6511
6512#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6514pub struct RemittanceLocationData11 {
6515 #[serde(rename = "Mtd")]
6516 pub mtd: RemittanceLocationMethod2Code,
6517 #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
6518 pub elctrnc_adr: Option<String>,
6519 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
6520 pub pstl_adr: Option<NameAndAddress161>,
6521}
6522
6523impl RemittanceLocationData11 {
6524 pub fn validate(&self) -> Result<(), ValidationError> {
6525 self.mtd.validate()?;
6526 if let Some(ref val) = self.elctrnc_adr {
6527 if val.chars().count() < 1 {
6528 return Err(ValidationError::new(
6529 1001,
6530 "elctrnc_adr is shorter than the minimum length of 1".to_string(),
6531 ));
6532 }
6533 if val.chars().count() > 2048 {
6534 return Err(ValidationError::new(
6535 1002,
6536 "elctrnc_adr exceeds the maximum length of 2048".to_string(),
6537 ));
6538 }
6539 let pattern = Regex::new(
6540 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6541 )
6542 .unwrap();
6543 if !pattern.is_match(val) {
6544 return Err(ValidationError::new(
6545 1005,
6546 "elctrnc_adr does not match the required pattern".to_string(),
6547 ));
6548 }
6549 }
6550 if let Some(ref val) = self.pstl_adr {
6551 val.validate()?
6552 }
6553 Ok(())
6554 }
6555}
6556
6557#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6559pub enum RemittanceLocationMethod2Code {
6560 #[default]
6561 #[serde(rename = "FAXI")]
6562 CodeFAXI,
6563 #[serde(rename = "EDIC")]
6564 CodeEDIC,
6565 #[serde(rename = "URID")]
6566 CodeURID,
6567 #[serde(rename = "EMAL")]
6568 CodeEMAL,
6569 #[serde(rename = "POST")]
6570 CodePOST,
6571 #[serde(rename = "SMSM")]
6572 CodeSMSM,
6573}
6574
6575impl RemittanceLocationMethod2Code {
6576 pub fn validate(&self) -> Result<(), ValidationError> {
6577 Ok(())
6578 }
6579}
6580
6581#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6583pub enum SequenceType3Code {
6584 #[default]
6585 #[serde(rename = "FRST")]
6586 CodeFRST,
6587 #[serde(rename = "RCUR")]
6588 CodeRCUR,
6589 #[serde(rename = "FNAL")]
6590 CodeFNAL,
6591 #[serde(rename = "OOFF")]
6592 CodeOOFF,
6593 #[serde(rename = "RPRE")]
6594 CodeRPRE,
6595}
6596
6597impl SequenceType3Code {
6598 pub fn validate(&self) -> Result<(), ValidationError> {
6599 Ok(())
6600 }
6601}
6602
6603#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6605pub struct ServiceLevel8Choice1 {
6606 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6607 pub cd: Option<String>,
6608 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6609 pub prtry: Option<String>,
6610}
6611
6612impl ServiceLevel8Choice1 {
6613 pub fn validate(&self) -> Result<(), ValidationError> {
6614 if let Some(ref val) = self.cd {
6615 if val.chars().count() < 1 {
6616 return Err(ValidationError::new(
6617 1001,
6618 "cd is shorter than the minimum length of 1".to_string(),
6619 ));
6620 }
6621 if val.chars().count() > 4 {
6622 return Err(ValidationError::new(
6623 1002,
6624 "cd exceeds the maximum length of 4".to_string(),
6625 ));
6626 }
6627 }
6628 if let Some(ref val) = self.prtry {
6629 if val.chars().count() < 1 {
6630 return Err(ValidationError::new(
6631 1001,
6632 "prtry is shorter than the minimum length of 1".to_string(),
6633 ));
6634 }
6635 if val.chars().count() > 35 {
6636 return Err(ValidationError::new(
6637 1002,
6638 "prtry exceeds the maximum length of 35".to_string(),
6639 ));
6640 }
6641 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6642 if !pattern.is_match(val) {
6643 return Err(ValidationError::new(
6644 1005,
6645 "prtry does not match the required pattern".to_string(),
6646 ));
6647 }
6648 }
6649 Ok(())
6650 }
6651}
6652
6653#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6655pub struct SettlementDateTimeIndication11 {
6656 #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
6657 pub dbt_dt_tm: Option<String>,
6658 #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
6659 pub cdt_dt_tm: Option<String>,
6660}
6661
6662impl SettlementDateTimeIndication11 {
6663 pub fn validate(&self) -> Result<(), ValidationError> {
6664 if let Some(ref val) = self.dbt_dt_tm {
6665 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
6666 if !pattern.is_match(val) {
6667 return Err(ValidationError::new(
6668 1005,
6669 "dbt_dt_tm does not match the required pattern".to_string(),
6670 ));
6671 }
6672 }
6673 if let Some(ref val) = self.cdt_dt_tm {
6674 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
6675 if !pattern.is_match(val) {
6676 return Err(ValidationError::new(
6677 1005,
6678 "cdt_dt_tm does not match the required pattern".to_string(),
6679 ));
6680 }
6681 }
6682 Ok(())
6683 }
6684}
6685
6686#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6688pub struct SettlementInstruction81 {
6689 #[serde(rename = "SttlmMtd")]
6690 pub sttlm_mtd: SettlementMethod2Code1,
6691 #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
6692 pub sttlm_acct: Option<CashAccount381>,
6693}
6694
6695impl SettlementInstruction81 {
6696 pub fn validate(&self) -> Result<(), ValidationError> {
6697 self.sttlm_mtd.validate()?;
6698 if let Some(ref val) = self.sttlm_acct {
6699 val.validate()?
6700 }
6701 Ok(())
6702 }
6703}
6704
6705#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6707pub enum SettlementMethod2Code1 {
6708 #[default]
6709 #[serde(rename = "INDA")]
6710 CodeINDA,
6711 #[serde(rename = "INGA")]
6712 CodeINGA,
6713}
6714
6715impl SettlementMethod2Code1 {
6716 pub fn validate(&self) -> Result<(), ValidationError> {
6717 Ok(())
6718 }
6719}
6720
6721#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6723pub struct StructuredRegulatoryReporting31 {
6724 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6725 pub tp: Option<String>,
6726 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
6727 pub dt: Option<String>,
6728 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
6729 pub ctry: Option<String>,
6730 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6731 pub cd: Option<String>,
6732 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
6733 pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6734 #[serde(rename = "Inf", skip_serializing_if = "Option::is_none")]
6735 pub inf: Option<Vec<String>>,
6736}
6737
6738impl StructuredRegulatoryReporting31 {
6739 pub fn validate(&self) -> Result<(), ValidationError> {
6740 if let Some(ref val) = self.tp {
6741 if val.chars().count() < 1 {
6742 return Err(ValidationError::new(
6743 1001,
6744 "tp is shorter than the minimum length of 1".to_string(),
6745 ));
6746 }
6747 if val.chars().count() > 35 {
6748 return Err(ValidationError::new(
6749 1002,
6750 "tp exceeds the maximum length of 35".to_string(),
6751 ));
6752 }
6753 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6754 if !pattern.is_match(val) {
6755 return Err(ValidationError::new(
6756 1005,
6757 "tp does not match the required pattern".to_string(),
6758 ));
6759 }
6760 }
6761 if let Some(ref val) = self.ctry {
6762 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
6763 if !pattern.is_match(val) {
6764 return Err(ValidationError::new(
6765 1005,
6766 "ctry does not match the required pattern".to_string(),
6767 ));
6768 }
6769 }
6770 if let Some(ref val) = self.cd {
6771 if val.chars().count() < 1 {
6772 return Err(ValidationError::new(
6773 1001,
6774 "cd is shorter than the minimum length of 1".to_string(),
6775 ));
6776 }
6777 if val.chars().count() > 10 {
6778 return Err(ValidationError::new(
6779 1002,
6780 "cd exceeds the maximum length of 10".to_string(),
6781 ));
6782 }
6783 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6784 if !pattern.is_match(val) {
6785 return Err(ValidationError::new(
6786 1005,
6787 "cd does not match the required pattern".to_string(),
6788 ));
6789 }
6790 }
6791 if let Some(ref val) = self.amt {
6792 val.validate()?
6793 }
6794 if let Some(ref vec) = self.inf {
6795 for item in vec {
6796 if item.chars().count() < 1 {
6797 return Err(ValidationError::new(
6798 1001,
6799 "inf is shorter than the minimum length of 1".to_string(),
6800 ));
6801 }
6802 if item.chars().count() > 35 {
6803 return Err(ValidationError::new(
6804 1002,
6805 "inf exceeds the maximum length of 35".to_string(),
6806 ));
6807 }
6808 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
6809 if !pattern.is_match(&item) {
6810 return Err(ValidationError::new(
6811 1005,
6812 "inf does not match the required pattern".to_string(),
6813 ));
6814 }
6815 }
6816 }
6817 Ok(())
6818 }
6819}
6820
6821#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6823pub struct StructuredRemittanceInformation161 {
6824 #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
6825 pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation71>>,
6826 #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
6827 pub rfrd_doc_amt: Option<RemittanceAmount2>,
6828 #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
6829 pub cdtr_ref_inf: Option<CreditorReferenceInformation21>,
6830 #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
6831 pub invcr: Option<PartyIdentification1355>,
6832 #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
6833 pub invcee: Option<PartyIdentification1355>,
6834 #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
6835 pub tax_rmt: Option<TaxInformation71>,
6836 #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
6837 pub grnshmt_rmt: Option<Garnishment31>,
6838 #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
6839 pub addtl_rmt_inf: Option<Vec<String>>,
6840}
6841
6842impl StructuredRemittanceInformation161 {
6843 pub fn validate(&self) -> Result<(), ValidationError> {
6844 if let Some(ref vec) = self.rfrd_doc_inf {
6845 for item in vec {
6846 item.validate()?
6847 }
6848 }
6849 if let Some(ref val) = self.rfrd_doc_amt {
6850 val.validate()?
6851 }
6852 if let Some(ref val) = self.cdtr_ref_inf {
6853 val.validate()?
6854 }
6855 if let Some(ref val) = self.invcr {
6856 val.validate()?
6857 }
6858 if let Some(ref val) = self.invcee {
6859 val.validate()?
6860 }
6861 if let Some(ref val) = self.tax_rmt {
6862 val.validate()?
6863 }
6864 if let Some(ref val) = self.grnshmt_rmt {
6865 val.validate()?
6866 }
6867 if let Some(ref vec) = self.addtl_rmt_inf {
6868 for item in vec {
6869 if item.chars().count() < 1 {
6870 return Err(ValidationError::new(
6871 1001,
6872 "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
6873 ));
6874 }
6875 if item.chars().count() > 140 {
6876 return Err(ValidationError::new(
6877 1002,
6878 "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
6879 ));
6880 }
6881 let pattern = Regex::new(
6882 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
6883 )
6884 .unwrap();
6885 if !pattern.is_match(&item) {
6886 return Err(ValidationError::new(
6887 1005,
6888 "addtl_rmt_inf does not match the required pattern".to_string(),
6889 ));
6890 }
6891 }
6892 }
6893 Ok(())
6894 }
6895}
6896
6897#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6899pub struct TaxAmount2 {
6900 #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
6901 pub rate: Option<f64>,
6902 #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
6903 pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6904 #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
6905 pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
6906 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
6907 pub dtls: Option<Vec<TaxRecordDetails2>>,
6908}
6909
6910impl TaxAmount2 {
6911 pub fn validate(&self) -> Result<(), ValidationError> {
6912 if let Some(ref val) = self.taxbl_base_amt {
6913 val.validate()?
6914 }
6915 if let Some(ref val) = self.ttl_amt {
6916 val.validate()?
6917 }
6918 if let Some(ref vec) = self.dtls {
6919 for item in vec {
6920 item.validate()?
6921 }
6922 }
6923 Ok(())
6924 }
6925}
6926
6927#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6929pub struct TaxAmountAndType1 {
6930 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6931 pub tp: Option<TaxAmountType1Choice>,
6932 #[serde(rename = "Amt")]
6933 pub amt: ActiveOrHistoricCurrencyAndAmount,
6934}
6935
6936impl TaxAmountAndType1 {
6937 pub fn validate(&self) -> Result<(), ValidationError> {
6938 if let Some(ref val) = self.tp {
6939 val.validate()?
6940 }
6941 self.amt.validate()?;
6942 Ok(())
6943 }
6944}
6945
6946#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6948pub struct TaxAmountAndType11 {
6949 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
6950 pub tp: Option<TaxAmountType1Choice1>,
6951 #[serde(rename = "Amt")]
6952 pub amt: ActiveOrHistoricCurrencyAndAmount,
6953}
6954
6955impl TaxAmountAndType11 {
6956 pub fn validate(&self) -> Result<(), ValidationError> {
6957 if let Some(ref val) = self.tp {
6958 val.validate()?
6959 }
6960 self.amt.validate()?;
6961 Ok(())
6962 }
6963}
6964
6965#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
6967pub struct TaxAmountType1Choice {
6968 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
6969 pub cd: Option<String>,
6970 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
6971 pub prtry: Option<String>,
6972}
6973
6974impl TaxAmountType1Choice {
6975 pub fn validate(&self) -> Result<(), ValidationError> {
6976 if let Some(ref val) = self.cd {
6977 if val.chars().count() < 1 {
6978 return Err(ValidationError::new(
6979 1001,
6980 "cd is shorter than the minimum length of 1".to_string(),
6981 ));
6982 }
6983 if val.chars().count() > 4 {
6984 return Err(ValidationError::new(
6985 1002,
6986 "cd exceeds the maximum length of 4".to_string(),
6987 ));
6988 }
6989 }
6990 if let Some(ref val) = self.prtry {
6991 if val.chars().count() < 1 {
6992 return Err(ValidationError::new(
6993 1001,
6994 "prtry is shorter than the minimum length of 1".to_string(),
6995 ));
6996 }
6997 if val.chars().count() > 35 {
6998 return Err(ValidationError::new(
6999 1002,
7000 "prtry exceeds the maximum length of 35".to_string(),
7001 ));
7002 }
7003 }
7004 Ok(())
7005 }
7006}
7007
7008#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7010pub struct TaxAmountType1Choice1 {
7011 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
7012 pub cd: Option<String>,
7013 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
7014 pub prtry: Option<String>,
7015}
7016
7017impl TaxAmountType1Choice1 {
7018 pub fn validate(&self) -> Result<(), ValidationError> {
7019 if let Some(ref val) = self.cd {
7020 if val.chars().count() < 1 {
7021 return Err(ValidationError::new(
7022 1001,
7023 "cd is shorter than the minimum length of 1".to_string(),
7024 ));
7025 }
7026 if val.chars().count() > 4 {
7027 return Err(ValidationError::new(
7028 1002,
7029 "cd exceeds the maximum length of 4".to_string(),
7030 ));
7031 }
7032 }
7033 if let Some(ref val) = self.prtry {
7034 if val.chars().count() < 1 {
7035 return Err(ValidationError::new(
7036 1001,
7037 "prtry is shorter than the minimum length of 1".to_string(),
7038 ));
7039 }
7040 if val.chars().count() > 35 {
7041 return Err(ValidationError::new(
7042 1002,
7043 "prtry exceeds the maximum length of 35".to_string(),
7044 ));
7045 }
7046 let pattern = Regex::new(
7047 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7048 )
7049 .unwrap();
7050 if !pattern.is_match(val) {
7051 return Err(ValidationError::new(
7052 1005,
7053 "prtry does not match the required pattern".to_string(),
7054 ));
7055 }
7056 }
7057 Ok(())
7058 }
7059}
7060
7061#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7063pub struct TaxAuthorisation11 {
7064 #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
7065 pub titl: Option<String>,
7066 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
7067 pub nm: Option<String>,
7068}
7069
7070impl TaxAuthorisation11 {
7071 pub fn validate(&self) -> Result<(), ValidationError> {
7072 if let Some(ref val) = self.titl {
7073 if val.chars().count() < 1 {
7074 return Err(ValidationError::new(
7075 1001,
7076 "titl is shorter than the minimum length of 1".to_string(),
7077 ));
7078 }
7079 if val.chars().count() > 35 {
7080 return Err(ValidationError::new(
7081 1002,
7082 "titl exceeds the maximum length of 35".to_string(),
7083 ));
7084 }
7085 let pattern = Regex::new(
7086 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7087 )
7088 .unwrap();
7089 if !pattern.is_match(val) {
7090 return Err(ValidationError::new(
7091 1005,
7092 "titl does not match the required pattern".to_string(),
7093 ));
7094 }
7095 }
7096 if let Some(ref val) = self.nm {
7097 if val.chars().count() < 1 {
7098 return Err(ValidationError::new(
7099 1001,
7100 "nm is shorter than the minimum length of 1".to_string(),
7101 ));
7102 }
7103 if val.chars().count() > 140 {
7104 return Err(ValidationError::new(
7105 1002,
7106 "nm exceeds the maximum length of 140".to_string(),
7107 ));
7108 }
7109 let pattern = Regex::new(
7110 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7111 )
7112 .unwrap();
7113 if !pattern.is_match(val) {
7114 return Err(ValidationError::new(
7115 1005,
7116 "nm does not match the required pattern".to_string(),
7117 ));
7118 }
7119 }
7120 Ok(())
7121 }
7122}
7123
7124#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7126pub struct TaxInformation71 {
7127 #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
7128 pub cdtr: Option<TaxParty11>,
7129 #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
7130 pub dbtr: Option<TaxParty21>,
7131 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
7132 pub ultmt_dbtr: Option<TaxParty21>,
7133 #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
7134 pub admstn_zone: Option<String>,
7135 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
7136 pub ref_nb: Option<String>,
7137 #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
7138 pub mtd: Option<String>,
7139 #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
7140 pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7141 #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
7142 pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
7143 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
7144 pub dt: Option<String>,
7145 #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
7146 pub seq_nb: Option<f64>,
7147 #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
7148 pub rcrd: Option<Vec<TaxRecord21>>,
7149}
7150
7151impl TaxInformation71 {
7152 pub fn validate(&self) -> Result<(), ValidationError> {
7153 if let Some(ref val) = self.cdtr {
7154 val.validate()?
7155 }
7156 if let Some(ref val) = self.dbtr {
7157 val.validate()?
7158 }
7159 if let Some(ref val) = self.ultmt_dbtr {
7160 val.validate()?
7161 }
7162 if let Some(ref val) = self.admstn_zone {
7163 if val.chars().count() < 1 {
7164 return Err(ValidationError::new(
7165 1001,
7166 "admstn_zone is shorter than the minimum length of 1".to_string(),
7167 ));
7168 }
7169 if val.chars().count() > 35 {
7170 return Err(ValidationError::new(
7171 1002,
7172 "admstn_zone exceeds the maximum length of 35".to_string(),
7173 ));
7174 }
7175 let pattern = Regex::new(
7176 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7177 )
7178 .unwrap();
7179 if !pattern.is_match(val) {
7180 return Err(ValidationError::new(
7181 1005,
7182 "admstn_zone does not match the required pattern".to_string(),
7183 ));
7184 }
7185 }
7186 if let Some(ref val) = self.ref_nb {
7187 if val.chars().count() < 1 {
7188 return Err(ValidationError::new(
7189 1001,
7190 "ref_nb is shorter than the minimum length of 1".to_string(),
7191 ));
7192 }
7193 if val.chars().count() > 140 {
7194 return Err(ValidationError::new(
7195 1002,
7196 "ref_nb exceeds the maximum length of 140".to_string(),
7197 ));
7198 }
7199 let pattern = Regex::new(
7200 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7201 )
7202 .unwrap();
7203 if !pattern.is_match(val) {
7204 return Err(ValidationError::new(
7205 1005,
7206 "ref_nb does not match the required pattern".to_string(),
7207 ));
7208 }
7209 }
7210 if let Some(ref val) = self.mtd {
7211 if val.chars().count() < 1 {
7212 return Err(ValidationError::new(
7213 1001,
7214 "mtd is shorter than the minimum length of 1".to_string(),
7215 ));
7216 }
7217 if val.chars().count() > 35 {
7218 return Err(ValidationError::new(
7219 1002,
7220 "mtd exceeds the maximum length of 35".to_string(),
7221 ));
7222 }
7223 let pattern = Regex::new(
7224 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7225 )
7226 .unwrap();
7227 if !pattern.is_match(val) {
7228 return Err(ValidationError::new(
7229 1005,
7230 "mtd does not match the required pattern".to_string(),
7231 ));
7232 }
7233 }
7234 if let Some(ref val) = self.ttl_taxbl_base_amt {
7235 val.validate()?
7236 }
7237 if let Some(ref val) = self.ttl_tax_amt {
7238 val.validate()?
7239 }
7240 if let Some(ref vec) = self.rcrd {
7241 for item in vec {
7242 item.validate()?
7243 }
7244 }
7245 Ok(())
7246 }
7247}
7248
7249#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7251pub struct TaxParty11 {
7252 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
7253 pub tax_id: Option<String>,
7254 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
7255 pub regn_id: Option<String>,
7256 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
7257 pub tax_tp: Option<String>,
7258}
7259
7260impl TaxParty11 {
7261 pub fn validate(&self) -> Result<(), ValidationError> {
7262 if let Some(ref val) = self.tax_id {
7263 if val.chars().count() < 1 {
7264 return Err(ValidationError::new(
7265 1001,
7266 "tax_id is shorter than the minimum length of 1".to_string(),
7267 ));
7268 }
7269 if val.chars().count() > 35 {
7270 return Err(ValidationError::new(
7271 1002,
7272 "tax_id exceeds the maximum length of 35".to_string(),
7273 ));
7274 }
7275 let pattern = Regex::new(
7276 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7277 )
7278 .unwrap();
7279 if !pattern.is_match(val) {
7280 return Err(ValidationError::new(
7281 1005,
7282 "tax_id does not match the required pattern".to_string(),
7283 ));
7284 }
7285 }
7286 if let Some(ref val) = self.regn_id {
7287 if val.chars().count() < 1 {
7288 return Err(ValidationError::new(
7289 1001,
7290 "regn_id is shorter than the minimum length of 1".to_string(),
7291 ));
7292 }
7293 if val.chars().count() > 35 {
7294 return Err(ValidationError::new(
7295 1002,
7296 "regn_id exceeds the maximum length of 35".to_string(),
7297 ));
7298 }
7299 let pattern = Regex::new(
7300 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7301 )
7302 .unwrap();
7303 if !pattern.is_match(val) {
7304 return Err(ValidationError::new(
7305 1005,
7306 "regn_id does not match the required pattern".to_string(),
7307 ));
7308 }
7309 }
7310 if let Some(ref val) = self.tax_tp {
7311 if val.chars().count() < 1 {
7312 return Err(ValidationError::new(
7313 1001,
7314 "tax_tp is shorter than the minimum length of 1".to_string(),
7315 ));
7316 }
7317 if val.chars().count() > 35 {
7318 return Err(ValidationError::new(
7319 1002,
7320 "tax_tp exceeds the maximum length of 35".to_string(),
7321 ));
7322 }
7323 let pattern = Regex::new(
7324 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7325 )
7326 .unwrap();
7327 if !pattern.is_match(val) {
7328 return Err(ValidationError::new(
7329 1005,
7330 "tax_tp does not match the required pattern".to_string(),
7331 ));
7332 }
7333 }
7334 Ok(())
7335 }
7336}
7337
7338#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7340pub struct TaxParty21 {
7341 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
7342 pub tax_id: Option<String>,
7343 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
7344 pub regn_id: Option<String>,
7345 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
7346 pub tax_tp: Option<String>,
7347 #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
7348 pub authstn: Option<TaxAuthorisation11>,
7349}
7350
7351impl TaxParty21 {
7352 pub fn validate(&self) -> Result<(), ValidationError> {
7353 if let Some(ref val) = self.tax_id {
7354 if val.chars().count() < 1 {
7355 return Err(ValidationError::new(
7356 1001,
7357 "tax_id is shorter than the minimum length of 1".to_string(),
7358 ));
7359 }
7360 if val.chars().count() > 35 {
7361 return Err(ValidationError::new(
7362 1002,
7363 "tax_id exceeds the maximum length of 35".to_string(),
7364 ));
7365 }
7366 let pattern = Regex::new(
7367 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7368 )
7369 .unwrap();
7370 if !pattern.is_match(val) {
7371 return Err(ValidationError::new(
7372 1005,
7373 "tax_id does not match the required pattern".to_string(),
7374 ));
7375 }
7376 }
7377 if let Some(ref val) = self.regn_id {
7378 if val.chars().count() < 1 {
7379 return Err(ValidationError::new(
7380 1001,
7381 "regn_id is shorter than the minimum length of 1".to_string(),
7382 ));
7383 }
7384 if val.chars().count() > 35 {
7385 return Err(ValidationError::new(
7386 1002,
7387 "regn_id exceeds the maximum length of 35".to_string(),
7388 ));
7389 }
7390 let pattern = Regex::new(
7391 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7392 )
7393 .unwrap();
7394 if !pattern.is_match(val) {
7395 return Err(ValidationError::new(
7396 1005,
7397 "regn_id does not match the required pattern".to_string(),
7398 ));
7399 }
7400 }
7401 if let Some(ref val) = self.tax_tp {
7402 if val.chars().count() < 1 {
7403 return Err(ValidationError::new(
7404 1001,
7405 "tax_tp is shorter than the minimum length of 1".to_string(),
7406 ));
7407 }
7408 if val.chars().count() > 35 {
7409 return Err(ValidationError::new(
7410 1002,
7411 "tax_tp exceeds the maximum length of 35".to_string(),
7412 ));
7413 }
7414 let pattern = Regex::new(
7415 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7416 )
7417 .unwrap();
7418 if !pattern.is_match(val) {
7419 return Err(ValidationError::new(
7420 1005,
7421 "tax_tp does not match the required pattern".to_string(),
7422 ));
7423 }
7424 }
7425 if let Some(ref val) = self.authstn {
7426 val.validate()?
7427 }
7428 Ok(())
7429 }
7430}
7431
7432#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7434pub struct TaxPeriod2 {
7435 #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
7436 pub yr: Option<String>,
7437 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7438 pub tp: Option<TaxRecordPeriod1Code>,
7439 #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
7440 pub fr_to_dt: Option<DatePeriod2>,
7441}
7442
7443impl TaxPeriod2 {
7444 pub fn validate(&self) -> Result<(), ValidationError> {
7445 if let Some(ref val) = self.tp {
7446 val.validate()?
7447 }
7448 if let Some(ref val) = self.fr_to_dt {
7449 val.validate()?
7450 }
7451 Ok(())
7452 }
7453}
7454
7455#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7457pub struct TaxRecord21 {
7458 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
7459 pub tp: Option<String>,
7460 #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
7461 pub ctgy: Option<String>,
7462 #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
7463 pub ctgy_dtls: Option<String>,
7464 #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
7465 pub dbtr_sts: Option<String>,
7466 #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
7467 pub cert_id: Option<String>,
7468 #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
7469 pub frms_cd: Option<String>,
7470 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
7471 pub prd: Option<TaxPeriod2>,
7472 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
7473 pub tax_amt: Option<TaxAmount2>,
7474 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
7475 pub addtl_inf: Option<String>,
7476}
7477
7478impl TaxRecord21 {
7479 pub fn validate(&self) -> Result<(), ValidationError> {
7480 if let Some(ref val) = self.tp {
7481 if val.chars().count() < 1 {
7482 return Err(ValidationError::new(
7483 1001,
7484 "tp is shorter than the minimum length of 1".to_string(),
7485 ));
7486 }
7487 if val.chars().count() > 35 {
7488 return Err(ValidationError::new(
7489 1002,
7490 "tp exceeds the maximum length of 35".to_string(),
7491 ));
7492 }
7493 let pattern = Regex::new(
7494 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7495 )
7496 .unwrap();
7497 if !pattern.is_match(val) {
7498 return Err(ValidationError::new(
7499 1005,
7500 "tp does not match the required pattern".to_string(),
7501 ));
7502 }
7503 }
7504 if let Some(ref val) = self.ctgy {
7505 if val.chars().count() < 1 {
7506 return Err(ValidationError::new(
7507 1001,
7508 "ctgy is shorter than the minimum length of 1".to_string(),
7509 ));
7510 }
7511 if val.chars().count() > 35 {
7512 return Err(ValidationError::new(
7513 1002,
7514 "ctgy exceeds the maximum length of 35".to_string(),
7515 ));
7516 }
7517 let pattern = Regex::new(
7518 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7519 )
7520 .unwrap();
7521 if !pattern.is_match(val) {
7522 return Err(ValidationError::new(
7523 1005,
7524 "ctgy does not match the required pattern".to_string(),
7525 ));
7526 }
7527 }
7528 if let Some(ref val) = self.ctgy_dtls {
7529 if val.chars().count() < 1 {
7530 return Err(ValidationError::new(
7531 1001,
7532 "ctgy_dtls is shorter than the minimum length of 1".to_string(),
7533 ));
7534 }
7535 if val.chars().count() > 35 {
7536 return Err(ValidationError::new(
7537 1002,
7538 "ctgy_dtls exceeds the maximum length of 35".to_string(),
7539 ));
7540 }
7541 let pattern = Regex::new(
7542 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7543 )
7544 .unwrap();
7545 if !pattern.is_match(val) {
7546 return Err(ValidationError::new(
7547 1005,
7548 "ctgy_dtls does not match the required pattern".to_string(),
7549 ));
7550 }
7551 }
7552 if let Some(ref val) = self.dbtr_sts {
7553 if val.chars().count() < 1 {
7554 return Err(ValidationError::new(
7555 1001,
7556 "dbtr_sts is shorter than the minimum length of 1".to_string(),
7557 ));
7558 }
7559 if val.chars().count() > 35 {
7560 return Err(ValidationError::new(
7561 1002,
7562 "dbtr_sts exceeds the maximum length of 35".to_string(),
7563 ));
7564 }
7565 let pattern = Regex::new(
7566 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7567 )
7568 .unwrap();
7569 if !pattern.is_match(val) {
7570 return Err(ValidationError::new(
7571 1005,
7572 "dbtr_sts does not match the required pattern".to_string(),
7573 ));
7574 }
7575 }
7576 if let Some(ref val) = self.cert_id {
7577 if val.chars().count() < 1 {
7578 return Err(ValidationError::new(
7579 1001,
7580 "cert_id is shorter than the minimum length of 1".to_string(),
7581 ));
7582 }
7583 if val.chars().count() > 35 {
7584 return Err(ValidationError::new(
7585 1002,
7586 "cert_id exceeds the maximum length of 35".to_string(),
7587 ));
7588 }
7589 let pattern = Regex::new(
7590 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7591 )
7592 .unwrap();
7593 if !pattern.is_match(val) {
7594 return Err(ValidationError::new(
7595 1005,
7596 "cert_id does not match the required pattern".to_string(),
7597 ));
7598 }
7599 }
7600 if let Some(ref val) = self.frms_cd {
7601 if val.chars().count() < 1 {
7602 return Err(ValidationError::new(
7603 1001,
7604 "frms_cd is shorter than the minimum length of 1".to_string(),
7605 ));
7606 }
7607 if val.chars().count() > 35 {
7608 return Err(ValidationError::new(
7609 1002,
7610 "frms_cd exceeds the maximum length of 35".to_string(),
7611 ));
7612 }
7613 let pattern = Regex::new(
7614 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7615 )
7616 .unwrap();
7617 if !pattern.is_match(val) {
7618 return Err(ValidationError::new(
7619 1005,
7620 "frms_cd does not match the required pattern".to_string(),
7621 ));
7622 }
7623 }
7624 if let Some(ref val) = self.prd {
7625 val.validate()?
7626 }
7627 if let Some(ref val) = self.tax_amt {
7628 val.validate()?
7629 }
7630 if let Some(ref val) = self.addtl_inf {
7631 if val.chars().count() < 1 {
7632 return Err(ValidationError::new(
7633 1001,
7634 "addtl_inf is shorter than the minimum length of 1".to_string(),
7635 ));
7636 }
7637 if val.chars().count() > 140 {
7638 return Err(ValidationError::new(
7639 1002,
7640 "addtl_inf exceeds the maximum length of 140".to_string(),
7641 ));
7642 }
7643 let pattern = Regex::new(
7644 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
7645 )
7646 .unwrap();
7647 if !pattern.is_match(val) {
7648 return Err(ValidationError::new(
7649 1005,
7650 "addtl_inf does not match the required pattern".to_string(),
7651 ));
7652 }
7653 }
7654 Ok(())
7655 }
7656}
7657
7658#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7660pub struct TaxRecordDetails2 {
7661 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
7662 pub prd: Option<TaxPeriod2>,
7663 #[serde(rename = "Amt")]
7664 pub amt: ActiveOrHistoricCurrencyAndAmount,
7665}
7666
7667impl TaxRecordDetails2 {
7668 pub fn validate(&self) -> Result<(), ValidationError> {
7669 if let Some(ref val) = self.prd {
7670 val.validate()?
7671 }
7672 self.amt.validate()?;
7673 Ok(())
7674 }
7675}
7676
7677#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
7679pub enum TaxRecordPeriod1Code {
7680 #[default]
7681 #[serde(rename = "MM01")]
7682 CodeMM01,
7683 #[serde(rename = "MM02")]
7684 CodeMM02,
7685 #[serde(rename = "MM03")]
7686 CodeMM03,
7687 #[serde(rename = "MM04")]
7688 CodeMM04,
7689 #[serde(rename = "MM05")]
7690 CodeMM05,
7691 #[serde(rename = "MM06")]
7692 CodeMM06,
7693 #[serde(rename = "MM07")]
7694 CodeMM07,
7695 #[serde(rename = "MM08")]
7696 CodeMM08,
7697 #[serde(rename = "MM09")]
7698 CodeMM09,
7699 #[serde(rename = "MM10")]
7700 CodeMM10,
7701 #[serde(rename = "MM11")]
7702 CodeMM11,
7703 #[serde(rename = "MM12")]
7704 CodeMM12,
7705 #[serde(rename = "QTR1")]
7706 CodeQTR1,
7707 #[serde(rename = "QTR2")]
7708 CodeQTR2,
7709 #[serde(rename = "QTR3")]
7710 CodeQTR3,
7711 #[serde(rename = "QTR4")]
7712 CodeQTR4,
7713 #[serde(rename = "HLF1")]
7714 CodeHLF1,
7715 #[serde(rename = "HLF2")]
7716 CodeHLF2,
7717}
7718
7719impl TaxRecordPeriod1Code {
7720 pub fn validate(&self) -> Result<(), ValidationError> {
7721 Ok(())
7722 }
7723}