1use crate::common::ValidationError;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice {
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<GenericAccountIdentification1>,
31}
32
33impl AccountIdentification4Choice {
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 AccountSchemeName1Choice {
54 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55 pub cd: Option<String>,
56 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57 pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice {
61 pub fn validate(&self) -> Result<(), ValidationError> {
62 if let Some(ref val) = self.cd {
63 if val.chars().count() < 1 {
64 return Err(ValidationError::new(
65 1001,
66 "cd is shorter than the minimum length of 1".to_string(),
67 ));
68 }
69 if val.chars().count() > 4 {
70 return Err(ValidationError::new(
71 1002,
72 "cd exceeds the maximum length of 4".to_string(),
73 ));
74 }
75 }
76 if let Some(ref val) = self.prtry {
77 if val.chars().count() < 1 {
78 return Err(ValidationError::new(
79 1001,
80 "prtry is shorter than the minimum length of 1".to_string(),
81 ));
82 }
83 if val.chars().count() > 35 {
84 return Err(ValidationError::new(
85 1002,
86 "prtry exceeds the maximum length of 35".to_string(),
87 ));
88 }
89 }
90 Ok(())
91 }
92}
93
94#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
96pub struct ActiveCurrencyAndAmount {
97 #[serde(rename = "@Ccy")]
98 pub ccy: String,
99 #[serde(rename = "$value")]
100 pub value: f64,
101}
102
103impl ActiveCurrencyAndAmount {
104 pub fn validate(&self) -> Result<(), ValidationError> {
105 Ok(())
106 }
107}
108
109#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
111pub struct ActiveOrHistoricCurrencyAndAmount {
112 #[serde(rename = "@Ccy")]
113 pub ccy: String,
114 #[serde(rename = "$value")]
115 pub value: f64,
116}
117
118impl ActiveOrHistoricCurrencyAndAmount {
119 pub fn validate(&self) -> Result<(), ValidationError> {
120 Ok(())
121 }
122}
123
124#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
126pub enum AddressType2Code {
127 #[default]
128 #[serde(rename = "ADDR")]
129 CodeADDR,
130 #[serde(rename = "PBOX")]
131 CodePBOX,
132 #[serde(rename = "HOME")]
133 CodeHOME,
134 #[serde(rename = "BIZZ")]
135 CodeBIZZ,
136 #[serde(rename = "MLTO")]
137 CodeMLTO,
138 #[serde(rename = "DLVY")]
139 CodeDLVY,
140}
141
142impl AddressType2Code {
143 pub fn validate(&self) -> Result<(), ValidationError> {
144 Ok(())
145 }
146}
147
148#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
150pub struct AddressType3Choice {
151 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
152 pub cd: Option<AddressType2Code>,
153 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
154 pub prtry: Option<GenericIdentification30>,
155}
156
157impl AddressType3Choice {
158 pub fn validate(&self) -> Result<(), ValidationError> {
159 if let Some(ref val) = self.cd {
160 val.validate()?
161 }
162 if let Some(ref val) = self.prtry {
163 val.validate()?
164 }
165 Ok(())
166 }
167}
168
169#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
171pub struct BranchAndFinancialInstitutionIdentification6 {
172 #[serde(rename = "FinInstnId")]
173 pub fin_instn_id: FinancialInstitutionIdentification18,
174 #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
175 pub brnch_id: Option<BranchData3>,
176}
177
178impl BranchAndFinancialInstitutionIdentification6 {
179 pub fn validate(&self) -> Result<(), ValidationError> {
180 self.fin_instn_id.validate()?;
181 if let Some(ref val) = self.brnch_id {
182 val.validate()?
183 }
184 Ok(())
185 }
186}
187
188#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
190pub struct BranchData3 {
191 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
192 pub id: Option<String>,
193 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
194 pub lei: Option<String>,
195 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
196 pub nm: Option<String>,
197 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
198 pub pstl_adr: Option<PostalAddress24>,
199}
200
201impl BranchData3 {
202 pub fn validate(&self) -> Result<(), ValidationError> {
203 if let Some(ref val) = self.id {
204 if val.chars().count() < 1 {
205 return Err(ValidationError::new(
206 1001,
207 "id is shorter than the minimum length of 1".to_string(),
208 ));
209 }
210 if val.chars().count() > 35 {
211 return Err(ValidationError::new(
212 1002,
213 "id exceeds the maximum length of 35".to_string(),
214 ));
215 }
216 }
217 if let Some(ref val) = self.lei {
218 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
219 if !pattern.is_match(val) {
220 return Err(ValidationError::new(
221 1005,
222 "lei does not match the required pattern".to_string(),
223 ));
224 }
225 }
226 if let Some(ref val) = self.nm {
227 if val.chars().count() < 1 {
228 return Err(ValidationError::new(
229 1001,
230 "nm is shorter than the minimum length of 1".to_string(),
231 ));
232 }
233 if val.chars().count() > 140 {
234 return Err(ValidationError::new(
235 1002,
236 "nm exceeds the maximum length of 140".to_string(),
237 ));
238 }
239 }
240 if let Some(ref val) = self.pstl_adr {
241 val.validate()?
242 }
243 Ok(())
244 }
245}
246
247#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
249pub struct CashAccount38 {
250 #[serde(rename = "Id")]
251 pub id: AccountIdentification4Choice,
252 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
253 pub tp: Option<CashAccountType2Choice>,
254 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
255 pub ccy: Option<String>,
256 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
257 pub nm: Option<String>,
258 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
259 pub prxy: Option<ProxyAccountIdentification1>,
260}
261
262impl CashAccount38 {
263 pub fn validate(&self) -> Result<(), ValidationError> {
264 self.id.validate()?;
265 if let Some(ref val) = self.tp {
266 val.validate()?
267 }
268 if let Some(ref val) = self.ccy {
269 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
270 if !pattern.is_match(val) {
271 return Err(ValidationError::new(
272 1005,
273 "ccy does not match the required pattern".to_string(),
274 ));
275 }
276 }
277 if let Some(ref val) = self.nm {
278 if val.chars().count() < 1 {
279 return Err(ValidationError::new(
280 1001,
281 "nm is shorter than the minimum length of 1".to_string(),
282 ));
283 }
284 if val.chars().count() > 70 {
285 return Err(ValidationError::new(
286 1002,
287 "nm exceeds the maximum length of 70".to_string(),
288 ));
289 }
290 }
291 if let Some(ref val) = self.prxy {
292 val.validate()?
293 }
294 Ok(())
295 }
296}
297
298#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
300pub struct CashAccountType2Choice {
301 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
302 pub cd: Option<String>,
303 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
304 pub prtry: Option<String>,
305}
306
307impl CashAccountType2Choice {
308 pub fn validate(&self) -> Result<(), ValidationError> {
309 if let Some(ref val) = self.cd {
310 if val.chars().count() < 1 {
311 return Err(ValidationError::new(
312 1001,
313 "cd is shorter than the minimum length of 1".to_string(),
314 ));
315 }
316 if val.chars().count() > 4 {
317 return Err(ValidationError::new(
318 1002,
319 "cd exceeds the maximum length of 4".to_string(),
320 ));
321 }
322 }
323 if let Some(ref val) = self.prtry {
324 if val.chars().count() < 1 {
325 return Err(ValidationError::new(
326 1001,
327 "prtry is shorter than the minimum length of 1".to_string(),
328 ));
329 }
330 if val.chars().count() > 35 {
331 return Err(ValidationError::new(
332 1002,
333 "prtry exceeds the maximum length of 35".to_string(),
334 ));
335 }
336 }
337 Ok(())
338 }
339}
340
341#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
343pub struct CategoryPurpose1Choice {
344 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
345 pub cd: Option<String>,
346 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
347 pub prtry: Option<String>,
348}
349
350impl CategoryPurpose1Choice {
351 pub fn validate(&self) -> Result<(), ValidationError> {
352 if let Some(ref val) = self.cd {
353 if val.chars().count() < 1 {
354 return Err(ValidationError::new(
355 1001,
356 "cd is shorter than the minimum length of 1".to_string(),
357 ));
358 }
359 if val.chars().count() > 4 {
360 return Err(ValidationError::new(
361 1002,
362 "cd exceeds the maximum length of 4".to_string(),
363 ));
364 }
365 }
366 if let Some(ref val) = self.prtry {
367 if val.chars().count() < 1 {
368 return Err(ValidationError::new(
369 1001,
370 "prtry is shorter than the minimum length of 1".to_string(),
371 ));
372 }
373 if val.chars().count() > 35 {
374 return Err(ValidationError::new(
375 1002,
376 "prtry exceeds the maximum length of 35".to_string(),
377 ));
378 }
379 }
380 Ok(())
381 }
382}
383
384#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
386pub enum ChargeBearerType1Code {
387 #[default]
388 #[serde(rename = "DEBT")]
389 CodeDEBT,
390 #[serde(rename = "CRED")]
391 CodeCRED,
392 #[serde(rename = "SHAR")]
393 CodeSHAR,
394 #[serde(rename = "SLEV")]
395 CodeSLEV,
396}
397
398impl ChargeBearerType1Code {
399 pub fn validate(&self) -> Result<(), ValidationError> {
400 Ok(())
401 }
402}
403
404#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
406pub struct Charges7 {
407 #[serde(rename = "Amt")]
408 pub amt: ActiveOrHistoricCurrencyAndAmount,
409 #[serde(rename = "Agt")]
410 pub agt: BranchAndFinancialInstitutionIdentification6,
411}
412
413impl Charges7 {
414 pub fn validate(&self) -> Result<(), ValidationError> {
415 self.amt.validate()?;
416 self.agt.validate()?;
417 Ok(())
418 }
419}
420
421#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
423pub enum ClearingChannel2Code {
424 #[default]
425 #[serde(rename = "RTGS")]
426 CodeRTGS,
427 #[serde(rename = "RTNS")]
428 CodeRTNS,
429 #[serde(rename = "MPNS")]
430 CodeMPNS,
431 #[serde(rename = "BOOK")]
432 CodeBOOK,
433}
434
435impl ClearingChannel2Code {
436 pub fn validate(&self) -> Result<(), ValidationError> {
437 Ok(())
438 }
439}
440
441#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
443pub struct ClearingSystemIdentification2Choice {
444 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
445 pub cd: Option<String>,
446 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
447 pub prtry: Option<String>,
448}
449
450impl ClearingSystemIdentification2Choice {
451 pub fn validate(&self) -> Result<(), ValidationError> {
452 if let Some(ref val) = self.cd {
453 if val.chars().count() < 1 {
454 return Err(ValidationError::new(
455 1001,
456 "cd is shorter than the minimum length of 1".to_string(),
457 ));
458 }
459 if val.chars().count() > 5 {
460 return Err(ValidationError::new(
461 1002,
462 "cd exceeds the maximum length of 5".to_string(),
463 ));
464 }
465 }
466 if let Some(ref val) = self.prtry {
467 if val.chars().count() < 1 {
468 return Err(ValidationError::new(
469 1001,
470 "prtry is shorter than the minimum length of 1".to_string(),
471 ));
472 }
473 if val.chars().count() > 35 {
474 return Err(ValidationError::new(
475 1002,
476 "prtry exceeds the maximum length of 35".to_string(),
477 ));
478 }
479 }
480 Ok(())
481 }
482}
483
484#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
486pub struct ClearingSystemIdentification3Choice {
487 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
488 pub cd: Option<String>,
489 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
490 pub prtry: Option<String>,
491}
492
493impl ClearingSystemIdentification3Choice {
494 pub fn validate(&self) -> Result<(), ValidationError> {
495 if let Some(ref val) = self.cd {
496 if val.chars().count() < 1 {
497 return Err(ValidationError::new(
498 1001,
499 "cd is shorter than the minimum length of 1".to_string(),
500 ));
501 }
502 if val.chars().count() > 3 {
503 return Err(ValidationError::new(
504 1002,
505 "cd exceeds the maximum length of 3".to_string(),
506 ));
507 }
508 }
509 if let Some(ref val) = self.prtry {
510 if val.chars().count() < 1 {
511 return Err(ValidationError::new(
512 1001,
513 "prtry is shorter than the minimum length of 1".to_string(),
514 ));
515 }
516 if val.chars().count() > 35 {
517 return Err(ValidationError::new(
518 1002,
519 "prtry exceeds the maximum length of 35".to_string(),
520 ));
521 }
522 }
523 Ok(())
524 }
525}
526
527#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
529pub struct ClearingSystemMemberIdentification2 {
530 #[serde(rename = "ClrSysId", skip_serializing_if = "Option::is_none")]
531 pub clr_sys_id: Option<ClearingSystemIdentification2Choice>,
532 #[serde(rename = "MmbId")]
533 pub mmb_id: String,
534}
535
536impl ClearingSystemMemberIdentification2 {
537 pub fn validate(&self) -> Result<(), ValidationError> {
538 if let Some(ref val) = self.clr_sys_id {
539 val.validate()?
540 }
541 if self.mmb_id.chars().count() < 1 {
542 return Err(ValidationError::new(
543 1001,
544 "mmb_id is shorter than the minimum length of 1".to_string(),
545 ));
546 }
547 if self.mmb_id.chars().count() > 35 {
548 return Err(ValidationError::new(
549 1002,
550 "mmb_id exceeds the maximum length of 35".to_string(),
551 ));
552 }
553 Ok(())
554 }
555}
556
557#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
559pub struct Contact4 {
560 #[serde(rename = "NmPrfx", skip_serializing_if = "Option::is_none")]
561 pub nm_prfx: Option<NamePrefix2Code>,
562 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
563 pub nm: Option<String>,
564 #[serde(rename = "PhneNb", skip_serializing_if = "Option::is_none")]
565 pub phne_nb: Option<String>,
566 #[serde(rename = "MobNb", skip_serializing_if = "Option::is_none")]
567 pub mob_nb: Option<String>,
568 #[serde(rename = "FaxNb", skip_serializing_if = "Option::is_none")]
569 pub fax_nb: Option<String>,
570 #[serde(rename = "EmailAdr", skip_serializing_if = "Option::is_none")]
571 pub email_adr: Option<String>,
572 #[serde(rename = "EmailPurp", skip_serializing_if = "Option::is_none")]
573 pub email_purp: Option<String>,
574 #[serde(rename = "JobTitl", skip_serializing_if = "Option::is_none")]
575 pub job_titl: Option<String>,
576 #[serde(rename = "Rspnsblty", skip_serializing_if = "Option::is_none")]
577 pub rspnsblty: Option<String>,
578 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
579 pub dept: Option<String>,
580 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
581 pub othr: Option<Vec<OtherContact1>>,
582 #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
583 pub prefrd_mtd: Option<PreferredContactMethod1Code>,
584}
585
586impl Contact4 {
587 pub fn validate(&self) -> Result<(), ValidationError> {
588 if let Some(ref val) = self.nm_prfx {
589 val.validate()?
590 }
591 if let Some(ref val) = self.nm {
592 if val.chars().count() < 1 {
593 return Err(ValidationError::new(
594 1001,
595 "nm is shorter than the minimum length of 1".to_string(),
596 ));
597 }
598 if val.chars().count() > 140 {
599 return Err(ValidationError::new(
600 1002,
601 "nm exceeds the maximum length of 140".to_string(),
602 ));
603 }
604 }
605 if let Some(ref val) = self.phne_nb {
606 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
607 if !pattern.is_match(val) {
608 return Err(ValidationError::new(
609 1005,
610 "phne_nb does not match the required pattern".to_string(),
611 ));
612 }
613 }
614 if let Some(ref val) = self.mob_nb {
615 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
616 if !pattern.is_match(val) {
617 return Err(ValidationError::new(
618 1005,
619 "mob_nb does not match the required pattern".to_string(),
620 ));
621 }
622 }
623 if let Some(ref val) = self.fax_nb {
624 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
625 if !pattern.is_match(val) {
626 return Err(ValidationError::new(
627 1005,
628 "fax_nb does not match the required pattern".to_string(),
629 ));
630 }
631 }
632 if let Some(ref val) = self.email_adr {
633 if val.chars().count() < 1 {
634 return Err(ValidationError::new(
635 1001,
636 "email_adr is shorter than the minimum length of 1".to_string(),
637 ));
638 }
639 if val.chars().count() > 2048 {
640 return Err(ValidationError::new(
641 1002,
642 "email_adr exceeds the maximum length of 2048".to_string(),
643 ));
644 }
645 }
646 if let Some(ref val) = self.email_purp {
647 if val.chars().count() < 1 {
648 return Err(ValidationError::new(
649 1001,
650 "email_purp is shorter than the minimum length of 1".to_string(),
651 ));
652 }
653 if val.chars().count() > 35 {
654 return Err(ValidationError::new(
655 1002,
656 "email_purp exceeds the maximum length of 35".to_string(),
657 ));
658 }
659 }
660 if let Some(ref val) = self.job_titl {
661 if val.chars().count() < 1 {
662 return Err(ValidationError::new(
663 1001,
664 "job_titl is shorter than the minimum length of 1".to_string(),
665 ));
666 }
667 if val.chars().count() > 35 {
668 return Err(ValidationError::new(
669 1002,
670 "job_titl exceeds the maximum length of 35".to_string(),
671 ));
672 }
673 }
674 if let Some(ref val) = self.rspnsblty {
675 if val.chars().count() < 1 {
676 return Err(ValidationError::new(
677 1001,
678 "rspnsblty is shorter than the minimum length of 1".to_string(),
679 ));
680 }
681 if val.chars().count() > 35 {
682 return Err(ValidationError::new(
683 1002,
684 "rspnsblty exceeds the maximum length of 35".to_string(),
685 ));
686 }
687 }
688 if let Some(ref val) = self.dept {
689 if val.chars().count() < 1 {
690 return Err(ValidationError::new(
691 1001,
692 "dept is shorter than the minimum length of 1".to_string(),
693 ));
694 }
695 if val.chars().count() > 70 {
696 return Err(ValidationError::new(
697 1002,
698 "dept exceeds the maximum length of 70".to_string(),
699 ));
700 }
701 }
702 if let Some(ref vec) = self.othr {
703 for item in vec {
704 item.validate()?
705 }
706 }
707 if let Some(ref val) = self.prefrd_mtd {
708 val.validate()?
709 }
710 Ok(())
711 }
712}
713
714#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
716pub enum CreditDebitCode {
717 #[default]
718 #[serde(rename = "CRDT")]
719 CodeCRDT,
720 #[serde(rename = "DBIT")]
721 CodeDBIT,
722}
723
724impl CreditDebitCode {
725 pub fn validate(&self) -> Result<(), ValidationError> {
726 Ok(())
727 }
728}
729
730#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
732pub struct CreditTransferTransaction39 {
733 #[serde(rename = "PmtId")]
734 pub pmt_id: PaymentIdentification7,
735 #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
736 pub pmt_tp_inf: Option<PaymentTypeInformation28>,
737 #[serde(rename = "IntrBkSttlmAmt")]
738 pub intr_bk_sttlm_amt: ActiveCurrencyAndAmount,
739 #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
740 pub intr_bk_sttlm_dt: Option<String>,
741 #[serde(rename = "SttlmPrty", skip_serializing_if = "Option::is_none")]
742 pub sttlm_prty: Option<Priority3Code>,
743 #[serde(rename = "SttlmTmIndctn", skip_serializing_if = "Option::is_none")]
744 pub sttlm_tm_indctn: Option<SettlementDateTimeIndication1>,
745 #[serde(rename = "SttlmTmReq", skip_serializing_if = "Option::is_none")]
746 pub sttlm_tm_req: Option<SettlementTimeRequest2>,
747 #[serde(rename = "AccptncDtTm", skip_serializing_if = "Option::is_none")]
748 pub accptnc_dt_tm: Option<String>,
749 #[serde(rename = "PoolgAdjstmntDt", skip_serializing_if = "Option::is_none")]
750 pub poolg_adjstmnt_dt: Option<String>,
751 #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
752 pub instd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
753 #[serde(rename = "XchgRate", skip_serializing_if = "Option::is_none")]
754 pub xchg_rate: Option<f64>,
755 #[serde(rename = "ChrgBr")]
756 pub chrg_br: ChargeBearerType1Code,
757 #[serde(rename = "ChrgsInf", skip_serializing_if = "Option::is_none")]
758 pub chrgs_inf: Option<Vec<Charges7>>,
759 #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
760 pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
761 #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
762 pub prvs_instg_agt1_acct: Option<CashAccount38>,
763 #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
764 pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
765 #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
766 pub prvs_instg_agt2_acct: Option<CashAccount38>,
767 #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
768 pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
769 #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
770 pub prvs_instg_agt3_acct: Option<CashAccount38>,
771 #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
772 pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
773 #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
774 pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
775 #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
776 pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification6>,
777 #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
778 pub intrmy_agt1_acct: Option<CashAccount38>,
779 #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
780 pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification6>,
781 #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
782 pub intrmy_agt2_acct: Option<CashAccount38>,
783 #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
784 pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification6>,
785 #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
786 pub intrmy_agt3_acct: Option<CashAccount38>,
787 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
788 pub ultmt_dbtr: Option<PartyIdentification135>,
789 #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
790 pub initg_pty: Option<PartyIdentification135>,
791 #[serde(rename = "Dbtr")]
792 pub dbtr: PartyIdentification135,
793 #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
794 pub dbtr_acct: Option<CashAccount38>,
795 #[serde(rename = "DbtrAgt")]
796 pub dbtr_agt: BranchAndFinancialInstitutionIdentification6,
797 #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
798 pub dbtr_agt_acct: Option<CashAccount38>,
799 #[serde(rename = "CdtrAgt")]
800 pub cdtr_agt: BranchAndFinancialInstitutionIdentification6,
801 #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
802 pub cdtr_agt_acct: Option<CashAccount38>,
803 #[serde(rename = "Cdtr")]
804 pub cdtr: PartyIdentification135,
805 #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
806 pub cdtr_acct: Option<CashAccount38>,
807 #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
808 pub ultmt_cdtr: Option<PartyIdentification135>,
809 #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
810 pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent1>>,
811 #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
812 pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent1>>,
813 #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
814 pub purp: Option<Purpose2Choice>,
815 #[serde(rename = "RgltryRptg", skip_serializing_if = "Option::is_none")]
816 pub rgltry_rptg: Option<Vec<RegulatoryReporting3>>,
817 #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
818 pub tax: Option<TaxInformation8>,
819 #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
820 pub rltd_rmt_inf: Option<Vec<RemittanceLocation7>>,
821 #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
822 pub rmt_inf: Option<RemittanceInformation16>,
823 #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
824 pub splmtry_data: Option<Vec<SupplementaryData1>>,
825}
826
827impl CreditTransferTransaction39 {
828 pub fn validate(&self) -> Result<(), ValidationError> {
829 self.pmt_id.validate()?;
830 if let Some(ref val) = self.pmt_tp_inf {
831 val.validate()?
832 }
833 self.intr_bk_sttlm_amt.validate()?;
834 if let Some(ref val) = self.sttlm_prty {
835 val.validate()?
836 }
837 if let Some(ref val) = self.sttlm_tm_indctn {
838 val.validate()?
839 }
840 if let Some(ref val) = self.sttlm_tm_req {
841 val.validate()?
842 }
843 if let Some(ref val) = self.instd_amt {
844 val.validate()?
845 }
846 self.chrg_br.validate()?;
847 if let Some(ref vec) = self.chrgs_inf {
848 for item in vec {
849 item.validate()?
850 }
851 }
852 if let Some(ref val) = self.prvs_instg_agt1 {
853 val.validate()?
854 }
855 if let Some(ref val) = self.prvs_instg_agt1_acct {
856 val.validate()?
857 }
858 if let Some(ref val) = self.prvs_instg_agt2 {
859 val.validate()?
860 }
861 if let Some(ref val) = self.prvs_instg_agt2_acct {
862 val.validate()?
863 }
864 if let Some(ref val) = self.prvs_instg_agt3 {
865 val.validate()?
866 }
867 if let Some(ref val) = self.prvs_instg_agt3_acct {
868 val.validate()?
869 }
870 if let Some(ref val) = self.instg_agt {
871 val.validate()?
872 }
873 if let Some(ref val) = self.instd_agt {
874 val.validate()?
875 }
876 if let Some(ref val) = self.intrmy_agt1 {
877 val.validate()?
878 }
879 if let Some(ref val) = self.intrmy_agt1_acct {
880 val.validate()?
881 }
882 if let Some(ref val) = self.intrmy_agt2 {
883 val.validate()?
884 }
885 if let Some(ref val) = self.intrmy_agt2_acct {
886 val.validate()?
887 }
888 if let Some(ref val) = self.intrmy_agt3 {
889 val.validate()?
890 }
891 if let Some(ref val) = self.intrmy_agt3_acct {
892 val.validate()?
893 }
894 if let Some(ref val) = self.ultmt_dbtr {
895 val.validate()?
896 }
897 if let Some(ref val) = self.initg_pty {
898 val.validate()?
899 }
900 self.dbtr.validate()?;
901 if let Some(ref val) = self.dbtr_acct {
902 val.validate()?
903 }
904 self.dbtr_agt.validate()?;
905 if let Some(ref val) = self.dbtr_agt_acct {
906 val.validate()?
907 }
908 self.cdtr_agt.validate()?;
909 if let Some(ref val) = self.cdtr_agt_acct {
910 val.validate()?
911 }
912 self.cdtr.validate()?;
913 if let Some(ref val) = self.cdtr_acct {
914 val.validate()?
915 }
916 if let Some(ref val) = self.ultmt_cdtr {
917 val.validate()?
918 }
919 if let Some(ref vec) = self.instr_for_cdtr_agt {
920 for item in vec {
921 item.validate()?
922 }
923 }
924 if let Some(ref vec) = self.instr_for_nxt_agt {
925 for item in vec {
926 item.validate()?
927 }
928 }
929 if let Some(ref val) = self.purp {
930 val.validate()?
931 }
932 if let Some(ref vec) = self.rgltry_rptg {
933 for item in vec {
934 item.validate()?
935 }
936 }
937 if let Some(ref val) = self.tax {
938 val.validate()?
939 }
940 if let Some(ref vec) = self.rltd_rmt_inf {
941 for item in vec {
942 item.validate()?
943 }
944 }
945 if let Some(ref val) = self.rmt_inf {
946 val.validate()?
947 }
948 if let Some(ref vec) = self.splmtry_data {
949 for item in vec {
950 item.validate()?
951 }
952 }
953 Ok(())
954 }
955}
956
957#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
959pub struct CreditorReferenceInformation2 {
960 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
961 pub tp: Option<CreditorReferenceType2>,
962 #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
963 pub ref_attr: Option<String>,
964}
965
966impl CreditorReferenceInformation2 {
967 pub fn validate(&self) -> Result<(), ValidationError> {
968 if let Some(ref val) = self.tp {
969 val.validate()?
970 }
971 if let Some(ref val) = self.ref_attr {
972 if val.chars().count() < 1 {
973 return Err(ValidationError::new(
974 1001,
975 "ref_attr is shorter than the minimum length of 1".to_string(),
976 ));
977 }
978 if val.chars().count() > 35 {
979 return Err(ValidationError::new(
980 1002,
981 "ref_attr exceeds the maximum length of 35".to_string(),
982 ));
983 }
984 }
985 Ok(())
986 }
987}
988
989#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
991pub struct CreditorReferenceType1Choice {
992 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
993 pub cd: Option<DocumentType3Code>,
994 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
995 pub prtry: Option<String>,
996}
997
998impl CreditorReferenceType1Choice {
999 pub fn validate(&self) -> Result<(), ValidationError> {
1000 if let Some(ref val) = self.cd {
1001 val.validate()?
1002 }
1003 if let Some(ref val) = self.prtry {
1004 if val.chars().count() < 1 {
1005 return Err(ValidationError::new(
1006 1001,
1007 "prtry is shorter than the minimum length of 1".to_string(),
1008 ));
1009 }
1010 if val.chars().count() > 35 {
1011 return Err(ValidationError::new(
1012 1002,
1013 "prtry exceeds the maximum length of 35".to_string(),
1014 ));
1015 }
1016 }
1017 Ok(())
1018 }
1019}
1020
1021#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1023pub struct CreditorReferenceType2 {
1024 #[serde(rename = "CdOrPrtry")]
1025 pub cd_or_prtry: CreditorReferenceType1Choice,
1026 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1027 pub issr: Option<String>,
1028}
1029
1030impl CreditorReferenceType2 {
1031 pub fn validate(&self) -> Result<(), ValidationError> {
1032 self.cd_or_prtry.validate()?;
1033 if let Some(ref val) = self.issr {
1034 if val.chars().count() < 1 {
1035 return Err(ValidationError::new(
1036 1001,
1037 "issr is shorter than the minimum length of 1".to_string(),
1038 ));
1039 }
1040 if val.chars().count() > 35 {
1041 return Err(ValidationError::new(
1042 1002,
1043 "issr exceeds the maximum length of 35".to_string(),
1044 ));
1045 }
1046 }
1047 Ok(())
1048 }
1049}
1050
1051#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1053pub struct DateAndPlaceOfBirth1 {
1054 #[serde(rename = "BirthDt")]
1055 pub birth_dt: String,
1056 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
1057 pub prvc_of_birth: Option<String>,
1058 #[serde(rename = "CityOfBirth")]
1059 pub city_of_birth: String,
1060 #[serde(rename = "CtryOfBirth")]
1061 pub ctry_of_birth: String,
1062}
1063
1064impl DateAndPlaceOfBirth1 {
1065 pub fn validate(&self) -> Result<(), ValidationError> {
1066 if let Some(ref val) = self.prvc_of_birth {
1067 if val.chars().count() < 1 {
1068 return Err(ValidationError::new(
1069 1001,
1070 "prvc_of_birth is shorter than the minimum length of 1".to_string(),
1071 ));
1072 }
1073 if val.chars().count() > 35 {
1074 return Err(ValidationError::new(
1075 1002,
1076 "prvc_of_birth exceeds the maximum length of 35".to_string(),
1077 ));
1078 }
1079 }
1080 if self.city_of_birth.chars().count() < 1 {
1081 return Err(ValidationError::new(
1082 1001,
1083 "city_of_birth is shorter than the minimum length of 1".to_string(),
1084 ));
1085 }
1086 if self.city_of_birth.chars().count() > 35 {
1087 return Err(ValidationError::new(
1088 1002,
1089 "city_of_birth exceeds the maximum length of 35".to_string(),
1090 ));
1091 }
1092 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1093 if !pattern.is_match(&self.ctry_of_birth) {
1094 return Err(ValidationError::new(
1095 1005,
1096 "ctry_of_birth does not match the required pattern".to_string(),
1097 ));
1098 }
1099 Ok(())
1100 }
1101}
1102
1103#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1105pub struct DatePeriod2 {
1106 #[serde(rename = "FrDt")]
1107 pub fr_dt: String,
1108 #[serde(rename = "ToDt")]
1109 pub to_dt: String,
1110}
1111
1112impl DatePeriod2 {
1113 pub fn validate(&self) -> Result<(), ValidationError> {
1114 Ok(())
1115 }
1116}
1117
1118#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1120pub struct DiscountAmountAndType1 {
1121 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1122 pub tp: Option<DiscountAmountType1Choice>,
1123 #[serde(rename = "Amt")]
1124 pub amt: ActiveOrHistoricCurrencyAndAmount,
1125}
1126
1127impl DiscountAmountAndType1 {
1128 pub fn validate(&self) -> Result<(), ValidationError> {
1129 if let Some(ref val) = self.tp {
1130 val.validate()?
1131 }
1132 self.amt.validate()?;
1133 Ok(())
1134 }
1135}
1136
1137#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1139pub struct DiscountAmountType1Choice {
1140 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1141 pub cd: Option<String>,
1142 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1143 pub prtry: Option<String>,
1144}
1145
1146impl DiscountAmountType1Choice {
1147 pub fn validate(&self) -> Result<(), ValidationError> {
1148 if let Some(ref val) = self.cd {
1149 if val.chars().count() < 1 {
1150 return Err(ValidationError::new(
1151 1001,
1152 "cd is shorter than the minimum length of 1".to_string(),
1153 ));
1154 }
1155 if val.chars().count() > 4 {
1156 return Err(ValidationError::new(
1157 1002,
1158 "cd exceeds the maximum length of 4".to_string(),
1159 ));
1160 }
1161 }
1162 if let Some(ref val) = self.prtry {
1163 if val.chars().count() < 1 {
1164 return Err(ValidationError::new(
1165 1001,
1166 "prtry is shorter than the minimum length of 1".to_string(),
1167 ));
1168 }
1169 if val.chars().count() > 35 {
1170 return Err(ValidationError::new(
1171 1002,
1172 "prtry exceeds the maximum length of 35".to_string(),
1173 ));
1174 }
1175 }
1176 Ok(())
1177 }
1178}
1179
1180#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1182pub struct DocumentAdjustment1 {
1183 #[serde(rename = "Amt")]
1184 pub amt: ActiveOrHistoricCurrencyAndAmount,
1185 #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1186 pub cdt_dbt_ind: Option<CreditDebitCode>,
1187 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1188 pub rsn: Option<String>,
1189 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1190 pub addtl_inf: Option<String>,
1191}
1192
1193impl DocumentAdjustment1 {
1194 pub fn validate(&self) -> Result<(), ValidationError> {
1195 self.amt.validate()?;
1196 if let Some(ref val) = self.cdt_dbt_ind {
1197 val.validate()?
1198 }
1199 if let Some(ref val) = self.rsn {
1200 if val.chars().count() < 1 {
1201 return Err(ValidationError::new(
1202 1001,
1203 "rsn is shorter than the minimum length of 1".to_string(),
1204 ));
1205 }
1206 if val.chars().count() > 4 {
1207 return Err(ValidationError::new(
1208 1002,
1209 "rsn exceeds the maximum length of 4".to_string(),
1210 ));
1211 }
1212 }
1213 if let Some(ref val) = self.addtl_inf {
1214 if val.chars().count() < 1 {
1215 return Err(ValidationError::new(
1216 1001,
1217 "addtl_inf is shorter than the minimum length of 1".to_string(),
1218 ));
1219 }
1220 if val.chars().count() > 140 {
1221 return Err(ValidationError::new(
1222 1002,
1223 "addtl_inf exceeds the maximum length of 140".to_string(),
1224 ));
1225 }
1226 }
1227 Ok(())
1228 }
1229}
1230
1231#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1233pub struct DocumentLineIdentification1 {
1234 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1235 pub tp: Option<DocumentLineType1>,
1236 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
1237 pub nb: Option<String>,
1238 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
1239 pub rltd_dt: Option<String>,
1240}
1241
1242impl DocumentLineIdentification1 {
1243 pub fn validate(&self) -> Result<(), ValidationError> {
1244 if let Some(ref val) = self.tp {
1245 val.validate()?
1246 }
1247 if let Some(ref val) = self.nb {
1248 if val.chars().count() < 1 {
1249 return Err(ValidationError::new(
1250 1001,
1251 "nb is shorter than the minimum length of 1".to_string(),
1252 ));
1253 }
1254 if val.chars().count() > 35 {
1255 return Err(ValidationError::new(
1256 1002,
1257 "nb exceeds the maximum length of 35".to_string(),
1258 ));
1259 }
1260 }
1261 Ok(())
1262 }
1263}
1264
1265#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1267pub struct DocumentLineInformation1 {
1268 #[serde(rename = "Id")]
1269 pub id: Vec<DocumentLineIdentification1>,
1270 #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
1271 pub desc: Option<String>,
1272 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
1273 pub amt: Option<RemittanceAmount3>,
1274}
1275
1276impl DocumentLineInformation1 {
1277 pub fn validate(&self) -> Result<(), ValidationError> {
1278 for item in &self.id {
1279 item.validate()?
1280 }
1281 if let Some(ref val) = self.desc {
1282 if val.chars().count() < 1 {
1283 return Err(ValidationError::new(
1284 1001,
1285 "desc is shorter than the minimum length of 1".to_string(),
1286 ));
1287 }
1288 if val.chars().count() > 2048 {
1289 return Err(ValidationError::new(
1290 1002,
1291 "desc exceeds the maximum length of 2048".to_string(),
1292 ));
1293 }
1294 }
1295 if let Some(ref val) = self.amt {
1296 val.validate()?
1297 }
1298 Ok(())
1299 }
1300}
1301
1302#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1304pub struct DocumentLineType1 {
1305 #[serde(rename = "CdOrPrtry")]
1306 pub cd_or_prtry: DocumentLineType1Choice,
1307 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1308 pub issr: Option<String>,
1309}
1310
1311impl DocumentLineType1 {
1312 pub fn validate(&self) -> Result<(), ValidationError> {
1313 self.cd_or_prtry.validate()?;
1314 if let Some(ref val) = self.issr {
1315 if val.chars().count() < 1 {
1316 return Err(ValidationError::new(
1317 1001,
1318 "issr is shorter than the minimum length of 1".to_string(),
1319 ));
1320 }
1321 if val.chars().count() > 35 {
1322 return Err(ValidationError::new(
1323 1002,
1324 "issr exceeds the maximum length of 35".to_string(),
1325 ));
1326 }
1327 }
1328 Ok(())
1329 }
1330}
1331
1332#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1334pub struct DocumentLineType1Choice {
1335 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1336 pub cd: Option<String>,
1337 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1338 pub prtry: Option<String>,
1339}
1340
1341impl DocumentLineType1Choice {
1342 pub fn validate(&self) -> Result<(), ValidationError> {
1343 if let Some(ref val) = self.cd {
1344 if val.chars().count() < 1 {
1345 return Err(ValidationError::new(
1346 1001,
1347 "cd is shorter than the minimum length of 1".to_string(),
1348 ));
1349 }
1350 if val.chars().count() > 4 {
1351 return Err(ValidationError::new(
1352 1002,
1353 "cd exceeds the maximum length of 4".to_string(),
1354 ));
1355 }
1356 }
1357 if let Some(ref val) = self.prtry {
1358 if val.chars().count() < 1 {
1359 return Err(ValidationError::new(
1360 1001,
1361 "prtry is shorter than the minimum length of 1".to_string(),
1362 ));
1363 }
1364 if val.chars().count() > 35 {
1365 return Err(ValidationError::new(
1366 1002,
1367 "prtry exceeds the maximum length of 35".to_string(),
1368 ));
1369 }
1370 }
1371 Ok(())
1372 }
1373}
1374
1375#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1377pub enum DocumentType3Code {
1378 #[default]
1379 #[serde(rename = "RADM")]
1380 CodeRADM,
1381 #[serde(rename = "RPIN")]
1382 CodeRPIN,
1383 #[serde(rename = "FXDR")]
1384 CodeFXDR,
1385 #[serde(rename = "DISP")]
1386 CodeDISP,
1387 #[serde(rename = "PUOR")]
1388 CodePUOR,
1389 #[serde(rename = "SCOR")]
1390 CodeSCOR,
1391}
1392
1393impl DocumentType3Code {
1394 pub fn validate(&self) -> Result<(), ValidationError> {
1395 Ok(())
1396 }
1397}
1398
1399#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1401pub enum DocumentType6Code {
1402 #[default]
1403 #[serde(rename = "MSIN")]
1404 CodeMSIN,
1405 #[serde(rename = "CNFA")]
1406 CodeCNFA,
1407 #[serde(rename = "DNFA")]
1408 CodeDNFA,
1409 #[serde(rename = "CINV")]
1410 CodeCINV,
1411 #[serde(rename = "CREN")]
1412 CodeCREN,
1413 #[serde(rename = "DEBN")]
1414 CodeDEBN,
1415 #[serde(rename = "HIRI")]
1416 CodeHIRI,
1417 #[serde(rename = "SBIN")]
1418 CodeSBIN,
1419 #[serde(rename = "CMCN")]
1420 CodeCMCN,
1421 #[serde(rename = "SOAC")]
1422 CodeSOAC,
1423 #[serde(rename = "DISP")]
1424 CodeDISP,
1425 #[serde(rename = "BOLD")]
1426 CodeBOLD,
1427 #[serde(rename = "VCHR")]
1428 CodeVCHR,
1429 #[serde(rename = "AROI")]
1430 CodeAROI,
1431 #[serde(rename = "TSUT")]
1432 CodeTSUT,
1433 #[serde(rename = "PUOR")]
1434 CodePUOR,
1435}
1436
1437impl DocumentType6Code {
1438 pub fn validate(&self) -> Result<(), ValidationError> {
1439 Ok(())
1440 }
1441}
1442
1443#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1445pub struct FIToFICustomerCreditTransferV08 {
1446 #[serde(rename = "GrpHdr")]
1447 pub grp_hdr: GroupHeader93,
1448 #[serde(rename = "CdtTrfTxInf")]
1449 pub cdt_trf_tx_inf: Vec<CreditTransferTransaction39>,
1450 #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
1451 pub splmtry_data: Option<Vec<SupplementaryData1>>,
1452}
1453
1454impl FIToFICustomerCreditTransferV08 {
1455 pub fn validate(&self) -> Result<(), ValidationError> {
1456 self.grp_hdr.validate()?;
1457 for item in &self.cdt_trf_tx_inf {
1458 item.validate()?
1459 }
1460 if let Some(ref vec) = self.splmtry_data {
1461 for item in vec {
1462 item.validate()?
1463 }
1464 }
1465 Ok(())
1466 }
1467}
1468
1469#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1471pub struct FinancialIdentificationSchemeName1Choice {
1472 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1473 pub cd: Option<String>,
1474 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1475 pub prtry: Option<String>,
1476}
1477
1478impl FinancialIdentificationSchemeName1Choice {
1479 pub fn validate(&self) -> Result<(), ValidationError> {
1480 if let Some(ref val) = self.cd {
1481 if val.chars().count() < 1 {
1482 return Err(ValidationError::new(
1483 1001,
1484 "cd is shorter than the minimum length of 1".to_string(),
1485 ));
1486 }
1487 if val.chars().count() > 4 {
1488 return Err(ValidationError::new(
1489 1002,
1490 "cd exceeds the maximum length of 4".to_string(),
1491 ));
1492 }
1493 }
1494 if let Some(ref val) = self.prtry {
1495 if val.chars().count() < 1 {
1496 return Err(ValidationError::new(
1497 1001,
1498 "prtry is shorter than the minimum length of 1".to_string(),
1499 ));
1500 }
1501 if val.chars().count() > 35 {
1502 return Err(ValidationError::new(
1503 1002,
1504 "prtry exceeds the maximum length of 35".to_string(),
1505 ));
1506 }
1507 }
1508 Ok(())
1509 }
1510}
1511
1512#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1514pub struct FinancialInstitutionIdentification18 {
1515 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1516 pub bicfi: Option<String>,
1517 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1518 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification2>,
1519 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1520 pub lei: Option<String>,
1521 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1522 pub nm: Option<String>,
1523 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1524 pub pstl_adr: Option<PostalAddress24>,
1525 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1526 pub othr: Option<GenericFinancialIdentification1>,
1527}
1528
1529impl FinancialInstitutionIdentification18 {
1530 pub fn validate(&self) -> Result<(), ValidationError> {
1531 if let Some(ref val) = self.bicfi {
1532 let pattern =
1533 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1534 if !pattern.is_match(val) {
1535 return Err(ValidationError::new(
1536 1005,
1537 "bicfi does not match the required pattern".to_string(),
1538 ));
1539 }
1540 }
1541 if let Some(ref val) = self.clr_sys_mmb_id {
1542 val.validate()?
1543 }
1544 if let Some(ref val) = self.lei {
1545 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1546 if !pattern.is_match(val) {
1547 return Err(ValidationError::new(
1548 1005,
1549 "lei does not match the required pattern".to_string(),
1550 ));
1551 }
1552 }
1553 if let Some(ref val) = self.nm {
1554 if val.chars().count() < 1 {
1555 return Err(ValidationError::new(
1556 1001,
1557 "nm is shorter than the minimum length of 1".to_string(),
1558 ));
1559 }
1560 if val.chars().count() > 140 {
1561 return Err(ValidationError::new(
1562 1002,
1563 "nm exceeds the maximum length of 140".to_string(),
1564 ));
1565 }
1566 }
1567 if let Some(ref val) = self.pstl_adr {
1568 val.validate()?
1569 }
1570 if let Some(ref val) = self.othr {
1571 val.validate()?
1572 }
1573 Ok(())
1574 }
1575}
1576
1577#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1579pub struct Garnishment3 {
1580 #[serde(rename = "Tp")]
1581 pub tp: GarnishmentType1,
1582 #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
1583 pub grnshee: Option<PartyIdentification135>,
1584 #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
1585 pub grnshmt_admstr: Option<PartyIdentification135>,
1586 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
1587 pub ref_nb: Option<String>,
1588 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
1589 pub dt: Option<String>,
1590 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
1591 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1592 #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
1593 pub fmly_mdcl_insrnc_ind: Option<bool>,
1594 #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
1595 pub mplyee_termntn_ind: Option<bool>,
1596}
1597
1598impl Garnishment3 {
1599 pub fn validate(&self) -> Result<(), ValidationError> {
1600 self.tp.validate()?;
1601 if let Some(ref val) = self.grnshee {
1602 val.validate()?
1603 }
1604 if let Some(ref val) = self.grnshmt_admstr {
1605 val.validate()?
1606 }
1607 if let Some(ref val) = self.ref_nb {
1608 if val.chars().count() < 1 {
1609 return Err(ValidationError::new(
1610 1001,
1611 "ref_nb is shorter than the minimum length of 1".to_string(),
1612 ));
1613 }
1614 if val.chars().count() > 140 {
1615 return Err(ValidationError::new(
1616 1002,
1617 "ref_nb exceeds the maximum length of 140".to_string(),
1618 ));
1619 }
1620 }
1621 if let Some(ref val) = self.rmtd_amt {
1622 val.validate()?
1623 }
1624 Ok(())
1625 }
1626}
1627
1628#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1630pub struct GarnishmentType1 {
1631 #[serde(rename = "CdOrPrtry")]
1632 pub cd_or_prtry: GarnishmentType1Choice,
1633 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1634 pub issr: Option<String>,
1635}
1636
1637impl GarnishmentType1 {
1638 pub fn validate(&self) -> Result<(), ValidationError> {
1639 self.cd_or_prtry.validate()?;
1640 if let Some(ref val) = self.issr {
1641 if val.chars().count() < 1 {
1642 return Err(ValidationError::new(
1643 1001,
1644 "issr is shorter than the minimum length of 1".to_string(),
1645 ));
1646 }
1647 if val.chars().count() > 35 {
1648 return Err(ValidationError::new(
1649 1002,
1650 "issr exceeds the maximum length of 35".to_string(),
1651 ));
1652 }
1653 }
1654 Ok(())
1655 }
1656}
1657
1658#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1660pub struct GarnishmentType1Choice {
1661 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1662 pub cd: Option<String>,
1663 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1664 pub prtry: Option<String>,
1665}
1666
1667impl GarnishmentType1Choice {
1668 pub fn validate(&self) -> Result<(), ValidationError> {
1669 if let Some(ref val) = self.cd {
1670 if val.chars().count() < 1 {
1671 return Err(ValidationError::new(
1672 1001,
1673 "cd is shorter than the minimum length of 1".to_string(),
1674 ));
1675 }
1676 if val.chars().count() > 4 {
1677 return Err(ValidationError::new(
1678 1002,
1679 "cd exceeds the maximum length of 4".to_string(),
1680 ));
1681 }
1682 }
1683 if let Some(ref val) = self.prtry {
1684 if val.chars().count() < 1 {
1685 return Err(ValidationError::new(
1686 1001,
1687 "prtry is shorter than the minimum length of 1".to_string(),
1688 ));
1689 }
1690 if val.chars().count() > 35 {
1691 return Err(ValidationError::new(
1692 1002,
1693 "prtry exceeds the maximum length of 35".to_string(),
1694 ));
1695 }
1696 }
1697 Ok(())
1698 }
1699}
1700
1701#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1703pub struct GenericAccountIdentification1 {
1704 #[serde(rename = "Id")]
1705 pub id: String,
1706 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1707 pub schme_nm: Option<AccountSchemeName1Choice>,
1708 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1709 pub issr: Option<String>,
1710}
1711
1712impl GenericAccountIdentification1 {
1713 pub fn validate(&self) -> Result<(), ValidationError> {
1714 if self.id.chars().count() < 1 {
1715 return Err(ValidationError::new(
1716 1001,
1717 "id is shorter than the minimum length of 1".to_string(),
1718 ));
1719 }
1720 if self.id.chars().count() > 34 {
1721 return Err(ValidationError::new(
1722 1002,
1723 "id exceeds the maximum length of 34".to_string(),
1724 ));
1725 }
1726 if let Some(ref val) = self.schme_nm {
1727 val.validate()?
1728 }
1729 if let Some(ref val) = self.issr {
1730 if val.chars().count() < 1 {
1731 return Err(ValidationError::new(
1732 1001,
1733 "issr is shorter than the minimum length of 1".to_string(),
1734 ));
1735 }
1736 if val.chars().count() > 35 {
1737 return Err(ValidationError::new(
1738 1002,
1739 "issr exceeds the maximum length of 35".to_string(),
1740 ));
1741 }
1742 }
1743 Ok(())
1744 }
1745}
1746
1747#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1749pub struct GenericFinancialIdentification1 {
1750 #[serde(rename = "Id")]
1751 pub id: String,
1752 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1753 pub schme_nm: Option<FinancialIdentificationSchemeName1Choice>,
1754 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1755 pub issr: Option<String>,
1756}
1757
1758impl GenericFinancialIdentification1 {
1759 pub fn validate(&self) -> Result<(), ValidationError> {
1760 if self.id.chars().count() < 1 {
1761 return Err(ValidationError::new(
1762 1001,
1763 "id is shorter than the minimum length of 1".to_string(),
1764 ));
1765 }
1766 if self.id.chars().count() > 35 {
1767 return Err(ValidationError::new(
1768 1002,
1769 "id exceeds the maximum length of 35".to_string(),
1770 ));
1771 }
1772 if let Some(ref val) = self.schme_nm {
1773 val.validate()?
1774 }
1775 if let Some(ref val) = self.issr {
1776 if val.chars().count() < 1 {
1777 return Err(ValidationError::new(
1778 1001,
1779 "issr is shorter than the minimum length of 1".to_string(),
1780 ));
1781 }
1782 if val.chars().count() > 35 {
1783 return Err(ValidationError::new(
1784 1002,
1785 "issr exceeds the maximum length of 35".to_string(),
1786 ));
1787 }
1788 }
1789 Ok(())
1790 }
1791}
1792
1793#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1795pub struct GenericIdentification30 {
1796 #[serde(rename = "Id")]
1797 pub id: String,
1798 #[serde(rename = "Issr")]
1799 pub issr: String,
1800 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1801 pub schme_nm: Option<String>,
1802}
1803
1804impl GenericIdentification30 {
1805 pub fn validate(&self) -> Result<(), ValidationError> {
1806 let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
1807 if !pattern.is_match(&self.id) {
1808 return Err(ValidationError::new(
1809 1005,
1810 "id does not match the required pattern".to_string(),
1811 ));
1812 }
1813 if self.issr.chars().count() < 1 {
1814 return Err(ValidationError::new(
1815 1001,
1816 "issr is shorter than the minimum length of 1".to_string(),
1817 ));
1818 }
1819 if self.issr.chars().count() > 35 {
1820 return Err(ValidationError::new(
1821 1002,
1822 "issr exceeds the maximum length of 35".to_string(),
1823 ));
1824 }
1825 if let Some(ref val) = self.schme_nm {
1826 if val.chars().count() < 1 {
1827 return Err(ValidationError::new(
1828 1001,
1829 "schme_nm is shorter than the minimum length of 1".to_string(),
1830 ));
1831 }
1832 if val.chars().count() > 35 {
1833 return Err(ValidationError::new(
1834 1002,
1835 "schme_nm exceeds the maximum length of 35".to_string(),
1836 ));
1837 }
1838 }
1839 Ok(())
1840 }
1841}
1842
1843#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1845pub struct GenericOrganisationIdentification1 {
1846 #[serde(rename = "Id")]
1847 pub id: String,
1848 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1849 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
1850 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1851 pub issr: Option<String>,
1852}
1853
1854impl GenericOrganisationIdentification1 {
1855 pub fn validate(&self) -> Result<(), ValidationError> {
1856 if self.id.chars().count() < 1 {
1857 return Err(ValidationError::new(
1858 1001,
1859 "id is shorter than the minimum length of 1".to_string(),
1860 ));
1861 }
1862 if self.id.chars().count() > 35 {
1863 return Err(ValidationError::new(
1864 1002,
1865 "id exceeds the maximum length of 35".to_string(),
1866 ));
1867 }
1868 if let Some(ref val) = self.schme_nm {
1869 val.validate()?
1870 }
1871 if let Some(ref val) = self.issr {
1872 if val.chars().count() < 1 {
1873 return Err(ValidationError::new(
1874 1001,
1875 "issr is shorter than the minimum length of 1".to_string(),
1876 ));
1877 }
1878 if val.chars().count() > 35 {
1879 return Err(ValidationError::new(
1880 1002,
1881 "issr exceeds the maximum length of 35".to_string(),
1882 ));
1883 }
1884 }
1885 Ok(())
1886 }
1887}
1888
1889#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1891pub struct GenericPersonIdentification1 {
1892 #[serde(rename = "Id")]
1893 pub id: String,
1894 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1895 pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
1896 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1897 pub issr: Option<String>,
1898}
1899
1900impl GenericPersonIdentification1 {
1901 pub fn validate(&self) -> Result<(), ValidationError> {
1902 if self.id.chars().count() < 1 {
1903 return Err(ValidationError::new(
1904 1001,
1905 "id is shorter than the minimum length of 1".to_string(),
1906 ));
1907 }
1908 if self.id.chars().count() > 35 {
1909 return Err(ValidationError::new(
1910 1002,
1911 "id exceeds the maximum length of 35".to_string(),
1912 ));
1913 }
1914 if let Some(ref val) = self.schme_nm {
1915 val.validate()?
1916 }
1917 if let Some(ref val) = self.issr {
1918 if val.chars().count() < 1 {
1919 return Err(ValidationError::new(
1920 1001,
1921 "issr is shorter than the minimum length of 1".to_string(),
1922 ));
1923 }
1924 if val.chars().count() > 35 {
1925 return Err(ValidationError::new(
1926 1002,
1927 "issr exceeds the maximum length of 35".to_string(),
1928 ));
1929 }
1930 }
1931 Ok(())
1932 }
1933}
1934
1935#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1937pub struct GroupHeader93 {
1938 #[serde(rename = "MsgId")]
1939 pub msg_id: String,
1940 #[serde(rename = "CreDtTm")]
1941 pub cre_dt_tm: String,
1942 #[serde(rename = "BtchBookg", skip_serializing_if = "Option::is_none")]
1943 pub btch_bookg: Option<bool>,
1944 #[serde(rename = "NbOfTxs")]
1945 pub nb_of_txs: String,
1946 #[serde(rename = "CtrlSum", skip_serializing_if = "Option::is_none")]
1947 pub ctrl_sum: Option<f64>,
1948 #[serde(rename = "TtlIntrBkSttlmAmt", skip_serializing_if = "Option::is_none")]
1949 pub ttl_intr_bk_sttlm_amt: Option<ActiveCurrencyAndAmount>,
1950 #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
1951 pub intr_bk_sttlm_dt: Option<String>,
1952 #[serde(rename = "SttlmInf")]
1953 pub sttlm_inf: SettlementInstruction7,
1954 #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
1955 pub pmt_tp_inf: Option<PaymentTypeInformation28>,
1956 #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
1957 pub instg_agt: Option<BranchAndFinancialInstitutionIdentification6>,
1958 #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
1959 pub instd_agt: Option<BranchAndFinancialInstitutionIdentification6>,
1960}
1961
1962impl GroupHeader93 {
1963 pub fn validate(&self) -> Result<(), ValidationError> {
1964 if self.msg_id.chars().count() < 1 {
1965 return Err(ValidationError::new(
1966 1001,
1967 "msg_id is shorter than the minimum length of 1".to_string(),
1968 ));
1969 }
1970 if self.msg_id.chars().count() > 35 {
1971 return Err(ValidationError::new(
1972 1002,
1973 "msg_id exceeds the maximum length of 35".to_string(),
1974 ));
1975 }
1976 let pattern = Regex::new("[0-9]{1,15}").unwrap();
1977 if !pattern.is_match(&self.nb_of_txs) {
1978 return Err(ValidationError::new(
1979 1005,
1980 "nb_of_txs does not match the required pattern".to_string(),
1981 ));
1982 }
1983 if let Some(ref val) = self.ttl_intr_bk_sttlm_amt {
1984 val.validate()?
1985 }
1986 self.sttlm_inf.validate()?;
1987 if let Some(ref val) = self.pmt_tp_inf {
1988 val.validate()?
1989 }
1990 if let Some(ref val) = self.instg_agt {
1991 val.validate()?
1992 }
1993 if let Some(ref val) = self.instd_agt {
1994 val.validate()?
1995 }
1996 Ok(())
1997 }
1998}
1999
2000#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2002pub enum Instruction3Code {
2003 #[default]
2004 #[serde(rename = "CHQB")]
2005 CodeCHQB,
2006 #[serde(rename = "HOLD")]
2007 CodeHOLD,
2008 #[serde(rename = "PHOB")]
2009 CodePHOB,
2010 #[serde(rename = "TELB")]
2011 CodeTELB,
2012}
2013
2014impl Instruction3Code {
2015 pub fn validate(&self) -> Result<(), ValidationError> {
2016 Ok(())
2017 }
2018}
2019
2020#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2022pub enum Instruction4Code {
2023 #[default]
2024 #[serde(rename = "PHOA")]
2025 CodePHOA,
2026 #[serde(rename = "TELA")]
2027 CodeTELA,
2028}
2029
2030impl Instruction4Code {
2031 pub fn validate(&self) -> Result<(), ValidationError> {
2032 Ok(())
2033 }
2034}
2035
2036#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2038pub struct InstructionForCreditorAgent1 {
2039 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2040 pub cd: Option<Instruction3Code>,
2041 #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2042 pub instr_inf: Option<String>,
2043}
2044
2045impl InstructionForCreditorAgent1 {
2046 pub fn validate(&self) -> Result<(), ValidationError> {
2047 if let Some(ref val) = self.cd {
2048 val.validate()?
2049 }
2050 if let Some(ref val) = self.instr_inf {
2051 if val.chars().count() < 1 {
2052 return Err(ValidationError::new(
2053 1001,
2054 "instr_inf is shorter than the minimum length of 1".to_string(),
2055 ));
2056 }
2057 if val.chars().count() > 140 {
2058 return Err(ValidationError::new(
2059 1002,
2060 "instr_inf exceeds the maximum length of 140".to_string(),
2061 ));
2062 }
2063 }
2064 Ok(())
2065 }
2066}
2067
2068#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2070pub struct InstructionForNextAgent1 {
2071 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2072 pub cd: Option<Instruction4Code>,
2073 #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
2074 pub instr_inf: Option<String>,
2075}
2076
2077impl InstructionForNextAgent1 {
2078 pub fn validate(&self) -> Result<(), ValidationError> {
2079 if let Some(ref val) = self.cd {
2080 val.validate()?
2081 }
2082 if let Some(ref val) = self.instr_inf {
2083 if val.chars().count() < 1 {
2084 return Err(ValidationError::new(
2085 1001,
2086 "instr_inf is shorter than the minimum length of 1".to_string(),
2087 ));
2088 }
2089 if val.chars().count() > 140 {
2090 return Err(ValidationError::new(
2091 1002,
2092 "instr_inf exceeds the maximum length of 140".to_string(),
2093 ));
2094 }
2095 }
2096 Ok(())
2097 }
2098}
2099
2100#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2102pub struct LocalInstrument2Choice {
2103 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2104 pub cd: Option<String>,
2105 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2106 pub prtry: Option<String>,
2107}
2108
2109impl LocalInstrument2Choice {
2110 pub fn validate(&self) -> Result<(), ValidationError> {
2111 if let Some(ref val) = self.cd {
2112 if val.chars().count() < 1 {
2113 return Err(ValidationError::new(
2114 1001,
2115 "cd is shorter than the minimum length of 1".to_string(),
2116 ));
2117 }
2118 if val.chars().count() > 35 {
2119 return Err(ValidationError::new(
2120 1002,
2121 "cd exceeds the maximum length of 35".to_string(),
2122 ));
2123 }
2124 }
2125 if let Some(ref val) = self.prtry {
2126 if val.chars().count() < 1 {
2127 return Err(ValidationError::new(
2128 1001,
2129 "prtry is shorter than the minimum length of 1".to_string(),
2130 ));
2131 }
2132 if val.chars().count() > 35 {
2133 return Err(ValidationError::new(
2134 1002,
2135 "prtry exceeds the maximum length of 35".to_string(),
2136 ));
2137 }
2138 }
2139 Ok(())
2140 }
2141}
2142
2143#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2145pub struct NameAndAddress16 {
2146 #[serde(rename = "Nm")]
2147 pub nm: String,
2148 #[serde(rename = "Adr")]
2149 pub adr: PostalAddress24,
2150}
2151
2152impl NameAndAddress16 {
2153 pub fn validate(&self) -> Result<(), ValidationError> {
2154 if self.nm.chars().count() < 1 {
2155 return Err(ValidationError::new(
2156 1001,
2157 "nm is shorter than the minimum length of 1".to_string(),
2158 ));
2159 }
2160 if self.nm.chars().count() > 140 {
2161 return Err(ValidationError::new(
2162 1002,
2163 "nm exceeds the maximum length of 140".to_string(),
2164 ));
2165 }
2166 self.adr.validate()?;
2167 Ok(())
2168 }
2169}
2170
2171#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2173pub enum NamePrefix2Code {
2174 #[default]
2175 #[serde(rename = "DOCT")]
2176 CodeDOCT,
2177 #[serde(rename = "MADM")]
2178 CodeMADM,
2179 #[serde(rename = "MISS")]
2180 CodeMISS,
2181 #[serde(rename = "MIST")]
2182 CodeMIST,
2183 #[serde(rename = "MIKS")]
2184 CodeMIKS,
2185}
2186
2187impl NamePrefix2Code {
2188 pub fn validate(&self) -> Result<(), ValidationError> {
2189 Ok(())
2190 }
2191}
2192
2193#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2195pub struct OrganisationIdentification29 {
2196 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2197 pub any_bic: Option<String>,
2198 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2199 pub lei: Option<String>,
2200 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2201 pub othr: Option<Vec<GenericOrganisationIdentification1>>,
2202}
2203
2204impl OrganisationIdentification29 {
2205 pub fn validate(&self) -> Result<(), ValidationError> {
2206 if let Some(ref val) = self.any_bic {
2207 let pattern =
2208 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2209 if !pattern.is_match(val) {
2210 return Err(ValidationError::new(
2211 1005,
2212 "any_bic does not match the required pattern".to_string(),
2213 ));
2214 }
2215 }
2216 if let Some(ref val) = self.lei {
2217 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2218 if !pattern.is_match(val) {
2219 return Err(ValidationError::new(
2220 1005,
2221 "lei does not match the required pattern".to_string(),
2222 ));
2223 }
2224 }
2225 if let Some(ref vec) = self.othr {
2226 for item in vec {
2227 item.validate()?
2228 }
2229 }
2230 Ok(())
2231 }
2232}
2233
2234#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2236pub struct OrganisationIdentificationSchemeName1Choice {
2237 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2238 pub cd: Option<String>,
2239 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2240 pub prtry: Option<String>,
2241}
2242
2243impl OrganisationIdentificationSchemeName1Choice {
2244 pub fn validate(&self) -> Result<(), ValidationError> {
2245 if let Some(ref val) = self.cd {
2246 if val.chars().count() < 1 {
2247 return Err(ValidationError::new(
2248 1001,
2249 "cd is shorter than the minimum length of 1".to_string(),
2250 ));
2251 }
2252 if val.chars().count() > 4 {
2253 return Err(ValidationError::new(
2254 1002,
2255 "cd exceeds the maximum length of 4".to_string(),
2256 ));
2257 }
2258 }
2259 if let Some(ref val) = self.prtry {
2260 if val.chars().count() < 1 {
2261 return Err(ValidationError::new(
2262 1001,
2263 "prtry is shorter than the minimum length of 1".to_string(),
2264 ));
2265 }
2266 if val.chars().count() > 35 {
2267 return Err(ValidationError::new(
2268 1002,
2269 "prtry exceeds the maximum length of 35".to_string(),
2270 ));
2271 }
2272 }
2273 Ok(())
2274 }
2275}
2276
2277#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2279pub struct OtherContact1 {
2280 #[serde(rename = "ChanlTp")]
2281 pub chanl_tp: String,
2282 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2283 pub id: Option<String>,
2284}
2285
2286impl OtherContact1 {
2287 pub fn validate(&self) -> Result<(), ValidationError> {
2288 if self.chanl_tp.chars().count() < 1 {
2289 return Err(ValidationError::new(
2290 1001,
2291 "chanl_tp is shorter than the minimum length of 1".to_string(),
2292 ));
2293 }
2294 if self.chanl_tp.chars().count() > 4 {
2295 return Err(ValidationError::new(
2296 1002,
2297 "chanl_tp exceeds the maximum length of 4".to_string(),
2298 ));
2299 }
2300 if let Some(ref val) = self.id {
2301 if val.chars().count() < 1 {
2302 return Err(ValidationError::new(
2303 1001,
2304 "id is shorter than the minimum length of 1".to_string(),
2305 ));
2306 }
2307 if val.chars().count() > 128 {
2308 return Err(ValidationError::new(
2309 1002,
2310 "id exceeds the maximum length of 128".to_string(),
2311 ));
2312 }
2313 }
2314 Ok(())
2315 }
2316}
2317
2318#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2320pub struct Party38Choice {
2321 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2322 pub org_id: Option<OrganisationIdentification29>,
2323 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2324 pub prvt_id: Option<PersonIdentification13>,
2325}
2326
2327impl Party38Choice {
2328 pub fn validate(&self) -> Result<(), ValidationError> {
2329 if let Some(ref val) = self.org_id {
2330 val.validate()?
2331 }
2332 if let Some(ref val) = self.prvt_id {
2333 val.validate()?
2334 }
2335 Ok(())
2336 }
2337}
2338
2339#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2341pub struct PartyIdentification135 {
2342 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2343 pub nm: Option<String>,
2344 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2345 pub pstl_adr: Option<PostalAddress24>,
2346 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2347 pub id: Option<Party38Choice>,
2348 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2349 pub ctry_of_res: Option<String>,
2350 #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
2351 pub ctct_dtls: Option<Contact4>,
2352}
2353
2354impl PartyIdentification135 {
2355 pub fn validate(&self) -> Result<(), ValidationError> {
2356 if let Some(ref val) = self.nm {
2357 if val.chars().count() < 1 {
2358 return Err(ValidationError::new(
2359 1001,
2360 "nm is shorter than the minimum length of 1".to_string(),
2361 ));
2362 }
2363 if val.chars().count() > 140 {
2364 return Err(ValidationError::new(
2365 1002,
2366 "nm exceeds the maximum length of 140".to_string(),
2367 ));
2368 }
2369 }
2370 if let Some(ref val) = self.pstl_adr {
2371 val.validate()?
2372 }
2373 if let Some(ref val) = self.id {
2374 val.validate()?
2375 }
2376 if let Some(ref val) = self.ctry_of_res {
2377 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2378 if !pattern.is_match(val) {
2379 return Err(ValidationError::new(
2380 1005,
2381 "ctry_of_res does not match the required pattern".to_string(),
2382 ));
2383 }
2384 }
2385 if let Some(ref val) = self.ctct_dtls {
2386 val.validate()?
2387 }
2388 Ok(())
2389 }
2390}
2391
2392#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2394pub struct PaymentIdentification7 {
2395 #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
2396 pub instr_id: Option<String>,
2397 #[serde(rename = "EndToEndId")]
2398 pub end_to_end_id: String,
2399 #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
2400 pub tx_id: Option<String>,
2401 #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
2402 pub uetr: Option<String>,
2403 #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
2404 pub clr_sys_ref: Option<String>,
2405}
2406
2407impl PaymentIdentification7 {
2408 pub fn validate(&self) -> Result<(), ValidationError> {
2409 if let Some(ref val) = self.instr_id {
2410 if val.chars().count() < 1 {
2411 return Err(ValidationError::new(
2412 1001,
2413 "instr_id is shorter than the minimum length of 1".to_string(),
2414 ));
2415 }
2416 if val.chars().count() > 35 {
2417 return Err(ValidationError::new(
2418 1002,
2419 "instr_id exceeds the maximum length of 35".to_string(),
2420 ));
2421 }
2422 }
2423 if self.end_to_end_id.chars().count() < 1 {
2424 return Err(ValidationError::new(
2425 1001,
2426 "end_to_end_id is shorter than the minimum length of 1".to_string(),
2427 ));
2428 }
2429 if self.end_to_end_id.chars().count() > 35 {
2430 return Err(ValidationError::new(
2431 1002,
2432 "end_to_end_id exceeds the maximum length of 35".to_string(),
2433 ));
2434 }
2435 if let Some(ref val) = self.tx_id {
2436 if val.chars().count() < 1 {
2437 return Err(ValidationError::new(
2438 1001,
2439 "tx_id is shorter than the minimum length of 1".to_string(),
2440 ));
2441 }
2442 if val.chars().count() > 35 {
2443 return Err(ValidationError::new(
2444 1002,
2445 "tx_id exceeds the maximum length of 35".to_string(),
2446 ));
2447 }
2448 }
2449 if let Some(ref val) = self.uetr {
2450 let pattern =
2451 Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}")
2452 .unwrap();
2453 if !pattern.is_match(val) {
2454 return Err(ValidationError::new(
2455 1005,
2456 "uetr does not match the required pattern".to_string(),
2457 ));
2458 }
2459 }
2460 if let Some(ref val) = self.clr_sys_ref {
2461 if val.chars().count() < 1 {
2462 return Err(ValidationError::new(
2463 1001,
2464 "clr_sys_ref is shorter than the minimum length of 1".to_string(),
2465 ));
2466 }
2467 if val.chars().count() > 35 {
2468 return Err(ValidationError::new(
2469 1002,
2470 "clr_sys_ref exceeds the maximum length of 35".to_string(),
2471 ));
2472 }
2473 }
2474 Ok(())
2475 }
2476}
2477
2478#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2480pub struct PaymentTypeInformation28 {
2481 #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
2482 pub instr_prty: Option<Priority2Code>,
2483 #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
2484 pub clr_chanl: Option<ClearingChannel2Code>,
2485 #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
2486 pub svc_lvl: Option<Vec<ServiceLevel8Choice>>,
2487 #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2488 pub lcl_instrm: Option<LocalInstrument2Choice>,
2489 #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
2490 pub ctgy_purp: Option<CategoryPurpose1Choice>,
2491}
2492
2493impl PaymentTypeInformation28 {
2494 pub fn validate(&self) -> Result<(), ValidationError> {
2495 if let Some(ref val) = self.instr_prty {
2496 val.validate()?
2497 }
2498 if let Some(ref val) = self.clr_chanl {
2499 val.validate()?
2500 }
2501 if let Some(ref vec) = self.svc_lvl {
2502 for item in vec {
2503 item.validate()?
2504 }
2505 }
2506 if let Some(ref val) = self.lcl_instrm {
2507 val.validate()?
2508 }
2509 if let Some(ref val) = self.ctgy_purp {
2510 val.validate()?
2511 }
2512 Ok(())
2513 }
2514}
2515
2516#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2518pub struct PersonIdentification13 {
2519 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
2520 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
2521 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2522 pub othr: Option<Vec<GenericPersonIdentification1>>,
2523}
2524
2525impl PersonIdentification13 {
2526 pub fn validate(&self) -> Result<(), ValidationError> {
2527 if let Some(ref val) = self.dt_and_plc_of_birth {
2528 val.validate()?
2529 }
2530 if let Some(ref vec) = self.othr {
2531 for item in vec {
2532 item.validate()?
2533 }
2534 }
2535 Ok(())
2536 }
2537}
2538
2539#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2541pub struct PersonIdentificationSchemeName1Choice {
2542 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2543 pub cd: Option<String>,
2544 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2545 pub prtry: Option<String>,
2546}
2547
2548impl PersonIdentificationSchemeName1Choice {
2549 pub fn validate(&self) -> Result<(), ValidationError> {
2550 if let Some(ref val) = self.cd {
2551 if val.chars().count() < 1 {
2552 return Err(ValidationError::new(
2553 1001,
2554 "cd is shorter than the minimum length of 1".to_string(),
2555 ));
2556 }
2557 if val.chars().count() > 4 {
2558 return Err(ValidationError::new(
2559 1002,
2560 "cd exceeds the maximum length of 4".to_string(),
2561 ));
2562 }
2563 }
2564 if let Some(ref val) = self.prtry {
2565 if val.chars().count() < 1 {
2566 return Err(ValidationError::new(
2567 1001,
2568 "prtry is shorter than the minimum length of 1".to_string(),
2569 ));
2570 }
2571 if val.chars().count() > 35 {
2572 return Err(ValidationError::new(
2573 1002,
2574 "prtry exceeds the maximum length of 35".to_string(),
2575 ));
2576 }
2577 }
2578 Ok(())
2579 }
2580}
2581
2582#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2584pub struct PostalAddress24 {
2585 #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
2586 pub adr_tp: Option<AddressType3Choice>,
2587 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
2588 pub dept: Option<String>,
2589 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
2590 pub sub_dept: Option<String>,
2591 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
2592 pub strt_nm: Option<String>,
2593 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
2594 pub bldg_nb: Option<String>,
2595 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
2596 pub bldg_nm: Option<String>,
2597 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
2598 pub flr: Option<String>,
2599 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
2600 pub pst_bx: Option<String>,
2601 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
2602 pub room: Option<String>,
2603 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
2604 pub pst_cd: Option<String>,
2605 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
2606 pub twn_nm: Option<String>,
2607 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
2608 pub twn_lctn_nm: Option<String>,
2609 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
2610 pub dstrct_nm: Option<String>,
2611 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
2612 pub ctry_sub_dvsn: Option<String>,
2613 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
2614 pub ctry: Option<String>,
2615 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
2616 pub adr_line: Option<Vec<String>>,
2617}
2618
2619impl PostalAddress24 {
2620 pub fn validate(&self) -> Result<(), ValidationError> {
2621 if let Some(ref val) = self.adr_tp {
2622 val.validate()?
2623 }
2624 if let Some(ref val) = self.dept {
2625 if val.chars().count() < 1 {
2626 return Err(ValidationError::new(
2627 1001,
2628 "dept is shorter than the minimum length of 1".to_string(),
2629 ));
2630 }
2631 if val.chars().count() > 70 {
2632 return Err(ValidationError::new(
2633 1002,
2634 "dept exceeds the maximum length of 70".to_string(),
2635 ));
2636 }
2637 }
2638 if let Some(ref val) = self.sub_dept {
2639 if val.chars().count() < 1 {
2640 return Err(ValidationError::new(
2641 1001,
2642 "sub_dept is shorter than the minimum length of 1".to_string(),
2643 ));
2644 }
2645 if val.chars().count() > 70 {
2646 return Err(ValidationError::new(
2647 1002,
2648 "sub_dept exceeds the maximum length of 70".to_string(),
2649 ));
2650 }
2651 }
2652 if let Some(ref val) = self.strt_nm {
2653 if val.chars().count() < 1 {
2654 return Err(ValidationError::new(
2655 1001,
2656 "strt_nm is shorter than the minimum length of 1".to_string(),
2657 ));
2658 }
2659 if val.chars().count() > 70 {
2660 return Err(ValidationError::new(
2661 1002,
2662 "strt_nm exceeds the maximum length of 70".to_string(),
2663 ));
2664 }
2665 }
2666 if let Some(ref val) = self.bldg_nb {
2667 if val.chars().count() < 1 {
2668 return Err(ValidationError::new(
2669 1001,
2670 "bldg_nb is shorter than the minimum length of 1".to_string(),
2671 ));
2672 }
2673 if val.chars().count() > 16 {
2674 return Err(ValidationError::new(
2675 1002,
2676 "bldg_nb exceeds the maximum length of 16".to_string(),
2677 ));
2678 }
2679 }
2680 if let Some(ref val) = self.bldg_nm {
2681 if val.chars().count() < 1 {
2682 return Err(ValidationError::new(
2683 1001,
2684 "bldg_nm is shorter than the minimum length of 1".to_string(),
2685 ));
2686 }
2687 if val.chars().count() > 35 {
2688 return Err(ValidationError::new(
2689 1002,
2690 "bldg_nm exceeds the maximum length of 35".to_string(),
2691 ));
2692 }
2693 }
2694 if let Some(ref val) = self.flr {
2695 if val.chars().count() < 1 {
2696 return Err(ValidationError::new(
2697 1001,
2698 "flr is shorter than the minimum length of 1".to_string(),
2699 ));
2700 }
2701 if val.chars().count() > 70 {
2702 return Err(ValidationError::new(
2703 1002,
2704 "flr exceeds the maximum length of 70".to_string(),
2705 ));
2706 }
2707 }
2708 if let Some(ref val) = self.pst_bx {
2709 if val.chars().count() < 1 {
2710 return Err(ValidationError::new(
2711 1001,
2712 "pst_bx is shorter than the minimum length of 1".to_string(),
2713 ));
2714 }
2715 if val.chars().count() > 16 {
2716 return Err(ValidationError::new(
2717 1002,
2718 "pst_bx exceeds the maximum length of 16".to_string(),
2719 ));
2720 }
2721 }
2722 if let Some(ref val) = self.room {
2723 if val.chars().count() < 1 {
2724 return Err(ValidationError::new(
2725 1001,
2726 "room is shorter than the minimum length of 1".to_string(),
2727 ));
2728 }
2729 if val.chars().count() > 70 {
2730 return Err(ValidationError::new(
2731 1002,
2732 "room exceeds the maximum length of 70".to_string(),
2733 ));
2734 }
2735 }
2736 if let Some(ref val) = self.pst_cd {
2737 if val.chars().count() < 1 {
2738 return Err(ValidationError::new(
2739 1001,
2740 "pst_cd is shorter than the minimum length of 1".to_string(),
2741 ));
2742 }
2743 if val.chars().count() > 16 {
2744 return Err(ValidationError::new(
2745 1002,
2746 "pst_cd exceeds the maximum length of 16".to_string(),
2747 ));
2748 }
2749 }
2750 if let Some(ref val) = self.twn_nm {
2751 if val.chars().count() < 1 {
2752 return Err(ValidationError::new(
2753 1001,
2754 "twn_nm is shorter than the minimum length of 1".to_string(),
2755 ));
2756 }
2757 if val.chars().count() > 35 {
2758 return Err(ValidationError::new(
2759 1002,
2760 "twn_nm exceeds the maximum length of 35".to_string(),
2761 ));
2762 }
2763 }
2764 if let Some(ref val) = self.twn_lctn_nm {
2765 if val.chars().count() < 1 {
2766 return Err(ValidationError::new(
2767 1001,
2768 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
2769 ));
2770 }
2771 if val.chars().count() > 35 {
2772 return Err(ValidationError::new(
2773 1002,
2774 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
2775 ));
2776 }
2777 }
2778 if let Some(ref val) = self.dstrct_nm {
2779 if val.chars().count() < 1 {
2780 return Err(ValidationError::new(
2781 1001,
2782 "dstrct_nm is shorter than the minimum length of 1".to_string(),
2783 ));
2784 }
2785 if val.chars().count() > 35 {
2786 return Err(ValidationError::new(
2787 1002,
2788 "dstrct_nm exceeds the maximum length of 35".to_string(),
2789 ));
2790 }
2791 }
2792 if let Some(ref val) = self.ctry_sub_dvsn {
2793 if val.chars().count() < 1 {
2794 return Err(ValidationError::new(
2795 1001,
2796 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
2797 ));
2798 }
2799 if val.chars().count() > 35 {
2800 return Err(ValidationError::new(
2801 1002,
2802 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
2803 ));
2804 }
2805 }
2806 if let Some(ref val) = self.ctry {
2807 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2808 if !pattern.is_match(val) {
2809 return Err(ValidationError::new(
2810 1005,
2811 "ctry does not match the required pattern".to_string(),
2812 ));
2813 }
2814 }
2815 if let Some(ref vec) = self.adr_line {
2816 for item in vec {
2817 if item.chars().count() < 1 {
2818 return Err(ValidationError::new(
2819 1001,
2820 "adr_line is shorter than the minimum length of 1".to_string(),
2821 ));
2822 }
2823 if item.chars().count() > 70 {
2824 return Err(ValidationError::new(
2825 1002,
2826 "adr_line exceeds the maximum length of 70".to_string(),
2827 ));
2828 }
2829 }
2830 }
2831 Ok(())
2832 }
2833}
2834
2835#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2837pub enum PreferredContactMethod1Code {
2838 #[default]
2839 #[serde(rename = "LETT")]
2840 CodeLETT,
2841 #[serde(rename = "MAIL")]
2842 CodeMAIL,
2843 #[serde(rename = "PHON")]
2844 CodePHON,
2845 #[serde(rename = "FAXX")]
2846 CodeFAXX,
2847 #[serde(rename = "CELL")]
2848 CodeCELL,
2849}
2850
2851impl PreferredContactMethod1Code {
2852 pub fn validate(&self) -> Result<(), ValidationError> {
2853 Ok(())
2854 }
2855}
2856
2857#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2859pub enum Priority2Code {
2860 #[default]
2861 #[serde(rename = "HIGH")]
2862 CodeHIGH,
2863 #[serde(rename = "NORM")]
2864 CodeNORM,
2865}
2866
2867impl Priority2Code {
2868 pub fn validate(&self) -> Result<(), ValidationError> {
2869 Ok(())
2870 }
2871}
2872
2873#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2875pub enum Priority3Code {
2876 #[default]
2877 #[serde(rename = "URGT")]
2878 CodeURGT,
2879 #[serde(rename = "HIGH")]
2880 CodeHIGH,
2881 #[serde(rename = "NORM")]
2882 CodeNORM,
2883}
2884
2885impl Priority3Code {
2886 pub fn validate(&self) -> Result<(), ValidationError> {
2887 Ok(())
2888 }
2889}
2890
2891#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2893pub struct ProxyAccountIdentification1 {
2894 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2895 pub tp: Option<ProxyAccountType1Choice>,
2896 #[serde(rename = "Id")]
2897 pub id: String,
2898}
2899
2900impl ProxyAccountIdentification1 {
2901 pub fn validate(&self) -> Result<(), ValidationError> {
2902 if let Some(ref val) = self.tp {
2903 val.validate()?
2904 }
2905 if self.id.chars().count() < 1 {
2906 return Err(ValidationError::new(
2907 1001,
2908 "id is shorter than the minimum length of 1".to_string(),
2909 ));
2910 }
2911 if self.id.chars().count() > 2048 {
2912 return Err(ValidationError::new(
2913 1002,
2914 "id exceeds the maximum length of 2048".to_string(),
2915 ));
2916 }
2917 Ok(())
2918 }
2919}
2920
2921#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2923pub struct ProxyAccountType1Choice {
2924 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2925 pub cd: Option<String>,
2926 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2927 pub prtry: Option<String>,
2928}
2929
2930impl ProxyAccountType1Choice {
2931 pub fn validate(&self) -> Result<(), ValidationError> {
2932 if let Some(ref val) = self.cd {
2933 if val.chars().count() < 1 {
2934 return Err(ValidationError::new(
2935 1001,
2936 "cd is shorter than the minimum length of 1".to_string(),
2937 ));
2938 }
2939 if val.chars().count() > 4 {
2940 return Err(ValidationError::new(
2941 1002,
2942 "cd exceeds the maximum length of 4".to_string(),
2943 ));
2944 }
2945 }
2946 if let Some(ref val) = self.prtry {
2947 if val.chars().count() < 1 {
2948 return Err(ValidationError::new(
2949 1001,
2950 "prtry is shorter than the minimum length of 1".to_string(),
2951 ));
2952 }
2953 if val.chars().count() > 35 {
2954 return Err(ValidationError::new(
2955 1002,
2956 "prtry exceeds the maximum length of 35".to_string(),
2957 ));
2958 }
2959 }
2960 Ok(())
2961 }
2962}
2963
2964#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2966pub struct Purpose2Choice {
2967 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2968 pub cd: Option<String>,
2969 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2970 pub prtry: Option<String>,
2971}
2972
2973impl Purpose2Choice {
2974 pub fn validate(&self) -> Result<(), ValidationError> {
2975 if let Some(ref val) = self.cd {
2976 if val.chars().count() < 1 {
2977 return Err(ValidationError::new(
2978 1001,
2979 "cd is shorter than the minimum length of 1".to_string(),
2980 ));
2981 }
2982 if val.chars().count() > 4 {
2983 return Err(ValidationError::new(
2984 1002,
2985 "cd exceeds the maximum length of 4".to_string(),
2986 ));
2987 }
2988 }
2989 if let Some(ref val) = self.prtry {
2990 if val.chars().count() < 1 {
2991 return Err(ValidationError::new(
2992 1001,
2993 "prtry is shorter than the minimum length of 1".to_string(),
2994 ));
2995 }
2996 if val.chars().count() > 35 {
2997 return Err(ValidationError::new(
2998 1002,
2999 "prtry exceeds the maximum length of 35".to_string(),
3000 ));
3001 }
3002 }
3003 Ok(())
3004 }
3005}
3006
3007#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3009pub struct ReferredDocumentInformation7 {
3010 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3011 pub tp: Option<ReferredDocumentType4>,
3012 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
3013 pub nb: Option<String>,
3014 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
3015 pub rltd_dt: Option<String>,
3016 #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
3017 pub line_dtls: Option<Vec<DocumentLineInformation1>>,
3018}
3019
3020impl ReferredDocumentInformation7 {
3021 pub fn validate(&self) -> Result<(), ValidationError> {
3022 if let Some(ref val) = self.tp {
3023 val.validate()?
3024 }
3025 if let Some(ref val) = self.nb {
3026 if val.chars().count() < 1 {
3027 return Err(ValidationError::new(
3028 1001,
3029 "nb is shorter than the minimum length of 1".to_string(),
3030 ));
3031 }
3032 if val.chars().count() > 35 {
3033 return Err(ValidationError::new(
3034 1002,
3035 "nb exceeds the maximum length of 35".to_string(),
3036 ));
3037 }
3038 }
3039 if let Some(ref vec) = self.line_dtls {
3040 for item in vec {
3041 item.validate()?
3042 }
3043 }
3044 Ok(())
3045 }
3046}
3047
3048#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3050pub struct ReferredDocumentType3Choice {
3051 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3052 pub cd: Option<DocumentType6Code>,
3053 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3054 pub prtry: Option<String>,
3055}
3056
3057impl ReferredDocumentType3Choice {
3058 pub fn validate(&self) -> Result<(), ValidationError> {
3059 if let Some(ref val) = self.cd {
3060 val.validate()?
3061 }
3062 if let Some(ref val) = self.prtry {
3063 if val.chars().count() < 1 {
3064 return Err(ValidationError::new(
3065 1001,
3066 "prtry is shorter than the minimum length of 1".to_string(),
3067 ));
3068 }
3069 if val.chars().count() > 35 {
3070 return Err(ValidationError::new(
3071 1002,
3072 "prtry exceeds the maximum length of 35".to_string(),
3073 ));
3074 }
3075 }
3076 Ok(())
3077 }
3078}
3079
3080#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3082pub struct ReferredDocumentType4 {
3083 #[serde(rename = "CdOrPrtry")]
3084 pub cd_or_prtry: ReferredDocumentType3Choice,
3085 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
3086 pub issr: Option<String>,
3087}
3088
3089impl ReferredDocumentType4 {
3090 pub fn validate(&self) -> Result<(), ValidationError> {
3091 self.cd_or_prtry.validate()?;
3092 if let Some(ref val) = self.issr {
3093 if val.chars().count() < 1 {
3094 return Err(ValidationError::new(
3095 1001,
3096 "issr is shorter than the minimum length of 1".to_string(),
3097 ));
3098 }
3099 if val.chars().count() > 35 {
3100 return Err(ValidationError::new(
3101 1002,
3102 "issr exceeds the maximum length of 35".to_string(),
3103 ));
3104 }
3105 }
3106 Ok(())
3107 }
3108}
3109
3110#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3112pub struct RegulatoryAuthority2 {
3113 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3114 pub nm: Option<String>,
3115 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
3116 pub ctry: Option<String>,
3117}
3118
3119impl RegulatoryAuthority2 {
3120 pub fn validate(&self) -> Result<(), ValidationError> {
3121 if let Some(ref val) = self.nm {
3122 if val.chars().count() < 1 {
3123 return Err(ValidationError::new(
3124 1001,
3125 "nm is shorter than the minimum length of 1".to_string(),
3126 ));
3127 }
3128 if val.chars().count() > 140 {
3129 return Err(ValidationError::new(
3130 1002,
3131 "nm exceeds the maximum length of 140".to_string(),
3132 ));
3133 }
3134 }
3135 if let Some(ref val) = self.ctry {
3136 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3137 if !pattern.is_match(val) {
3138 return Err(ValidationError::new(
3139 1005,
3140 "ctry does not match the required pattern".to_string(),
3141 ));
3142 }
3143 }
3144 Ok(())
3145 }
3146}
3147
3148#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3150pub struct RegulatoryReporting3 {
3151 #[serde(rename = "DbtCdtRptgInd", skip_serializing_if = "Option::is_none")]
3152 pub dbt_cdt_rptg_ind: Option<RegulatoryReportingType1Code>,
3153 #[serde(rename = "Authrty", skip_serializing_if = "Option::is_none")]
3154 pub authrty: Option<RegulatoryAuthority2>,
3155 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
3156 pub dtls: Option<Vec<StructuredRegulatoryReporting3>>,
3157}
3158
3159impl RegulatoryReporting3 {
3160 pub fn validate(&self) -> Result<(), ValidationError> {
3161 if let Some(ref val) = self.dbt_cdt_rptg_ind {
3162 val.validate()?
3163 }
3164 if let Some(ref val) = self.authrty {
3165 val.validate()?
3166 }
3167 if let Some(ref vec) = self.dtls {
3168 for item in vec {
3169 item.validate()?
3170 }
3171 }
3172 Ok(())
3173 }
3174}
3175
3176#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3178pub enum RegulatoryReportingType1Code {
3179 #[default]
3180 #[serde(rename = "CRED")]
3181 CodeCRED,
3182 #[serde(rename = "DEBT")]
3183 CodeDEBT,
3184 #[serde(rename = "BOTH")]
3185 CodeBOTH,
3186}
3187
3188impl RegulatoryReportingType1Code {
3189 pub fn validate(&self) -> Result<(), ValidationError> {
3190 Ok(())
3191 }
3192}
3193
3194#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3196pub struct RemittanceAmount2 {
3197 #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
3198 pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3199 #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
3200 pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
3201 #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
3202 pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3203 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3204 pub tax_amt: Option<Vec<TaxAmountAndType1>>,
3205 #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
3206 pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
3207 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3208 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3209}
3210
3211impl RemittanceAmount2 {
3212 pub fn validate(&self) -> Result<(), ValidationError> {
3213 if let Some(ref val) = self.due_pybl_amt {
3214 val.validate()?
3215 }
3216 if let Some(ref vec) = self.dscnt_apld_amt {
3217 for item in vec {
3218 item.validate()?
3219 }
3220 }
3221 if let Some(ref val) = self.cdt_note_amt {
3222 val.validate()?
3223 }
3224 if let Some(ref vec) = self.tax_amt {
3225 for item in vec {
3226 item.validate()?
3227 }
3228 }
3229 if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
3230 for item in vec {
3231 item.validate()?
3232 }
3233 }
3234 if let Some(ref val) = self.rmtd_amt {
3235 val.validate()?
3236 }
3237 Ok(())
3238 }
3239}
3240
3241#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3243pub struct RemittanceAmount3 {
3244 #[serde(rename = "DuePyblAmt", skip_serializing_if = "Option::is_none")]
3245 pub due_pybl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3246 #[serde(rename = "DscntApldAmt", skip_serializing_if = "Option::is_none")]
3247 pub dscnt_apld_amt: Option<Vec<DiscountAmountAndType1>>,
3248 #[serde(rename = "CdtNoteAmt", skip_serializing_if = "Option::is_none")]
3249 pub cdt_note_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3250 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3251 pub tax_amt: Option<Vec<TaxAmountAndType1>>,
3252 #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
3253 pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
3254 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
3255 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3256}
3257
3258impl RemittanceAmount3 {
3259 pub fn validate(&self) -> Result<(), ValidationError> {
3260 if let Some(ref val) = self.due_pybl_amt {
3261 val.validate()?
3262 }
3263 if let Some(ref vec) = self.dscnt_apld_amt {
3264 for item in vec {
3265 item.validate()?
3266 }
3267 }
3268 if let Some(ref val) = self.cdt_note_amt {
3269 val.validate()?
3270 }
3271 if let Some(ref vec) = self.tax_amt {
3272 for item in vec {
3273 item.validate()?
3274 }
3275 }
3276 if let Some(ref vec) = self.adjstmnt_amt_and_rsn {
3277 for item in vec {
3278 item.validate()?
3279 }
3280 }
3281 if let Some(ref val) = self.rmtd_amt {
3282 val.validate()?
3283 }
3284 Ok(())
3285 }
3286}
3287
3288#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3290pub struct RemittanceInformation16 {
3291 #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
3292 pub ustrd: Option<Vec<String>>,
3293 #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
3294 pub strd: Option<Vec<StructuredRemittanceInformation16>>,
3295}
3296
3297impl RemittanceInformation16 {
3298 pub fn validate(&self) -> Result<(), ValidationError> {
3299 if let Some(ref vec) = self.ustrd {
3300 for item in vec {
3301 if item.chars().count() < 1 {
3302 return Err(ValidationError::new(
3303 1001,
3304 "ustrd is shorter than the minimum length of 1".to_string(),
3305 ));
3306 }
3307 if item.chars().count() > 140 {
3308 return Err(ValidationError::new(
3309 1002,
3310 "ustrd exceeds the maximum length of 140".to_string(),
3311 ));
3312 }
3313 }
3314 }
3315 if let Some(ref vec) = self.strd {
3316 for item in vec {
3317 item.validate()?
3318 }
3319 }
3320 Ok(())
3321 }
3322}
3323
3324#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3326pub struct RemittanceLocation7 {
3327 #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
3328 pub rmt_id: Option<String>,
3329 #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
3330 pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData1>>,
3331}
3332
3333impl RemittanceLocation7 {
3334 pub fn validate(&self) -> Result<(), ValidationError> {
3335 if let Some(ref val) = self.rmt_id {
3336 if val.chars().count() < 1 {
3337 return Err(ValidationError::new(
3338 1001,
3339 "rmt_id is shorter than the minimum length of 1".to_string(),
3340 ));
3341 }
3342 if val.chars().count() > 35 {
3343 return Err(ValidationError::new(
3344 1002,
3345 "rmt_id exceeds the maximum length of 35".to_string(),
3346 ));
3347 }
3348 }
3349 if let Some(ref vec) = self.rmt_lctn_dtls {
3350 for item in vec {
3351 item.validate()?
3352 }
3353 }
3354 Ok(())
3355 }
3356}
3357
3358#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3360pub struct RemittanceLocationData1 {
3361 #[serde(rename = "Mtd")]
3362 pub mtd: RemittanceLocationMethod2Code,
3363 #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
3364 pub elctrnc_adr: Option<String>,
3365 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
3366 pub pstl_adr: Option<NameAndAddress16>,
3367}
3368
3369impl RemittanceLocationData1 {
3370 pub fn validate(&self) -> Result<(), ValidationError> {
3371 self.mtd.validate()?;
3372 if let Some(ref val) = self.elctrnc_adr {
3373 if val.chars().count() < 1 {
3374 return Err(ValidationError::new(
3375 1001,
3376 "elctrnc_adr is shorter than the minimum length of 1".to_string(),
3377 ));
3378 }
3379 if val.chars().count() > 2048 {
3380 return Err(ValidationError::new(
3381 1002,
3382 "elctrnc_adr exceeds the maximum length of 2048".to_string(),
3383 ));
3384 }
3385 }
3386 if let Some(ref val) = self.pstl_adr {
3387 val.validate()?
3388 }
3389 Ok(())
3390 }
3391}
3392
3393#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3395pub enum RemittanceLocationMethod2Code {
3396 #[default]
3397 #[serde(rename = "FAXI")]
3398 CodeFAXI,
3399 #[serde(rename = "EDIC")]
3400 CodeEDIC,
3401 #[serde(rename = "URID")]
3402 CodeURID,
3403 #[serde(rename = "EMAL")]
3404 CodeEMAL,
3405 #[serde(rename = "POST")]
3406 CodePOST,
3407 #[serde(rename = "SMSM")]
3408 CodeSMSM,
3409}
3410
3411impl RemittanceLocationMethod2Code {
3412 pub fn validate(&self) -> Result<(), ValidationError> {
3413 Ok(())
3414 }
3415}
3416
3417#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3419pub struct ServiceLevel8Choice {
3420 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3421 pub cd: Option<String>,
3422 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3423 pub prtry: Option<String>,
3424}
3425
3426impl ServiceLevel8Choice {
3427 pub fn validate(&self) -> Result<(), ValidationError> {
3428 if let Some(ref val) = self.cd {
3429 if val.chars().count() < 1 {
3430 return Err(ValidationError::new(
3431 1001,
3432 "cd is shorter than the minimum length of 1".to_string(),
3433 ));
3434 }
3435 if val.chars().count() > 4 {
3436 return Err(ValidationError::new(
3437 1002,
3438 "cd exceeds the maximum length of 4".to_string(),
3439 ));
3440 }
3441 }
3442 if let Some(ref val) = self.prtry {
3443 if val.chars().count() < 1 {
3444 return Err(ValidationError::new(
3445 1001,
3446 "prtry is shorter than the minimum length of 1".to_string(),
3447 ));
3448 }
3449 if val.chars().count() > 35 {
3450 return Err(ValidationError::new(
3451 1002,
3452 "prtry exceeds the maximum length of 35".to_string(),
3453 ));
3454 }
3455 }
3456 Ok(())
3457 }
3458}
3459
3460#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3462pub struct SettlementDateTimeIndication1 {
3463 #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
3464 pub dbt_dt_tm: Option<String>,
3465 #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
3466 pub cdt_dt_tm: Option<String>,
3467}
3468
3469impl SettlementDateTimeIndication1 {
3470 pub fn validate(&self) -> Result<(), ValidationError> {
3471 Ok(())
3472 }
3473}
3474
3475#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3477pub struct SettlementInstruction7 {
3478 #[serde(rename = "SttlmMtd")]
3479 pub sttlm_mtd: SettlementMethod1Code,
3480 #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
3481 pub sttlm_acct: Option<CashAccount38>,
3482 #[serde(rename = "ClrSys", skip_serializing_if = "Option::is_none")]
3483 pub clr_sys: Option<ClearingSystemIdentification3Choice>,
3484 #[serde(rename = "InstgRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3485 pub instg_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3486 #[serde(
3487 rename = "InstgRmbrsmntAgtAcct",
3488 skip_serializing_if = "Option::is_none"
3489 )]
3490 pub instg_rmbrsmnt_agt_acct: Option<CashAccount38>,
3491 #[serde(rename = "InstdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3492 pub instd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3493 #[serde(
3494 rename = "InstdRmbrsmntAgtAcct",
3495 skip_serializing_if = "Option::is_none"
3496 )]
3497 pub instd_rmbrsmnt_agt_acct: Option<CashAccount38>,
3498 #[serde(rename = "ThrdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3499 pub thrd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification6>,
3500 #[serde(
3501 rename = "ThrdRmbrsmntAgtAcct",
3502 skip_serializing_if = "Option::is_none"
3503 )]
3504 pub thrd_rmbrsmnt_agt_acct: Option<CashAccount38>,
3505}
3506
3507impl SettlementInstruction7 {
3508 pub fn validate(&self) -> Result<(), ValidationError> {
3509 self.sttlm_mtd.validate()?;
3510 if let Some(ref val) = self.sttlm_acct {
3511 val.validate()?
3512 }
3513 if let Some(ref val) = self.clr_sys {
3514 val.validate()?
3515 }
3516 if let Some(ref val) = self.instg_rmbrsmnt_agt {
3517 val.validate()?
3518 }
3519 if let Some(ref val) = self.instg_rmbrsmnt_agt_acct {
3520 val.validate()?
3521 }
3522 if let Some(ref val) = self.instd_rmbrsmnt_agt {
3523 val.validate()?
3524 }
3525 if let Some(ref val) = self.instd_rmbrsmnt_agt_acct {
3526 val.validate()?
3527 }
3528 if let Some(ref val) = self.thrd_rmbrsmnt_agt {
3529 val.validate()?
3530 }
3531 if let Some(ref val) = self.thrd_rmbrsmnt_agt_acct {
3532 val.validate()?
3533 }
3534 Ok(())
3535 }
3536}
3537
3538#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3540pub enum SettlementMethod1Code {
3541 #[default]
3542 #[serde(rename = "INDA")]
3543 CodeINDA,
3544 #[serde(rename = "INGA")]
3545 CodeINGA,
3546 #[serde(rename = "COVE")]
3547 CodeCOVE,
3548 #[serde(rename = "CLRG")]
3549 CodeCLRG,
3550}
3551
3552impl SettlementMethod1Code {
3553 pub fn validate(&self) -> Result<(), ValidationError> {
3554 Ok(())
3555 }
3556}
3557
3558#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3560pub struct SettlementTimeRequest2 {
3561 #[serde(rename = "CLSTm", skip_serializing_if = "Option::is_none")]
3562 pub cls_tm: Option<String>,
3563 #[serde(rename = "TillTm", skip_serializing_if = "Option::is_none")]
3564 pub till_tm: Option<String>,
3565 #[serde(rename = "FrTm", skip_serializing_if = "Option::is_none")]
3566 pub fr_tm: Option<String>,
3567 #[serde(rename = "RjctTm", skip_serializing_if = "Option::is_none")]
3568 pub rjct_tm: Option<String>,
3569}
3570
3571impl SettlementTimeRequest2 {
3572 pub fn validate(&self) -> Result<(), ValidationError> {
3573 Ok(())
3574 }
3575}
3576
3577#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3579pub struct StructuredRegulatoryReporting3 {
3580 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3581 pub tp: Option<String>,
3582 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3583 pub dt: Option<String>,
3584 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
3585 pub ctry: Option<String>,
3586 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3587 pub cd: Option<String>,
3588 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
3589 pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3590 #[serde(rename = "Inf", skip_serializing_if = "Option::is_none")]
3591 pub inf: Option<Vec<String>>,
3592}
3593
3594impl StructuredRegulatoryReporting3 {
3595 pub fn validate(&self) -> Result<(), ValidationError> {
3596 if let Some(ref val) = self.tp {
3597 if val.chars().count() < 1 {
3598 return Err(ValidationError::new(
3599 1001,
3600 "tp is shorter than the minimum length of 1".to_string(),
3601 ));
3602 }
3603 if val.chars().count() > 35 {
3604 return Err(ValidationError::new(
3605 1002,
3606 "tp exceeds the maximum length of 35".to_string(),
3607 ));
3608 }
3609 }
3610 if let Some(ref val) = self.ctry {
3611 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3612 if !pattern.is_match(val) {
3613 return Err(ValidationError::new(
3614 1005,
3615 "ctry does not match the required pattern".to_string(),
3616 ));
3617 }
3618 }
3619 if let Some(ref val) = self.cd {
3620 if val.chars().count() < 1 {
3621 return Err(ValidationError::new(
3622 1001,
3623 "cd is shorter than the minimum length of 1".to_string(),
3624 ));
3625 }
3626 if val.chars().count() > 10 {
3627 return Err(ValidationError::new(
3628 1002,
3629 "cd exceeds the maximum length of 10".to_string(),
3630 ));
3631 }
3632 }
3633 if let Some(ref val) = self.amt {
3634 val.validate()?
3635 }
3636 if let Some(ref vec) = self.inf {
3637 for item in vec {
3638 if item.chars().count() < 1 {
3639 return Err(ValidationError::new(
3640 1001,
3641 "inf is shorter than the minimum length of 1".to_string(),
3642 ));
3643 }
3644 if item.chars().count() > 35 {
3645 return Err(ValidationError::new(
3646 1002,
3647 "inf exceeds the maximum length of 35".to_string(),
3648 ));
3649 }
3650 }
3651 }
3652 Ok(())
3653 }
3654}
3655
3656#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3658pub struct StructuredRemittanceInformation16 {
3659 #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
3660 pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation7>>,
3661 #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
3662 pub rfrd_doc_amt: Option<RemittanceAmount2>,
3663 #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
3664 pub cdtr_ref_inf: Option<CreditorReferenceInformation2>,
3665 #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
3666 pub invcr: Option<PartyIdentification135>,
3667 #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
3668 pub invcee: Option<PartyIdentification135>,
3669 #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
3670 pub tax_rmt: Option<TaxInformation7>,
3671 #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
3672 pub grnshmt_rmt: Option<Garnishment3>,
3673 #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
3674 pub addtl_rmt_inf: Option<Vec<String>>,
3675}
3676
3677impl StructuredRemittanceInformation16 {
3678 pub fn validate(&self) -> Result<(), ValidationError> {
3679 if let Some(ref vec) = self.rfrd_doc_inf {
3680 for item in vec {
3681 item.validate()?
3682 }
3683 }
3684 if let Some(ref val) = self.rfrd_doc_amt {
3685 val.validate()?
3686 }
3687 if let Some(ref val) = self.cdtr_ref_inf {
3688 val.validate()?
3689 }
3690 if let Some(ref val) = self.invcr {
3691 val.validate()?
3692 }
3693 if let Some(ref val) = self.invcee {
3694 val.validate()?
3695 }
3696 if let Some(ref val) = self.tax_rmt {
3697 val.validate()?
3698 }
3699 if let Some(ref val) = self.grnshmt_rmt {
3700 val.validate()?
3701 }
3702 if let Some(ref vec) = self.addtl_rmt_inf {
3703 for item in vec {
3704 if item.chars().count() < 1 {
3705 return Err(ValidationError::new(
3706 1001,
3707 "addtl_rmt_inf is shorter than the minimum length of 1".to_string(),
3708 ));
3709 }
3710 if item.chars().count() > 140 {
3711 return Err(ValidationError::new(
3712 1002,
3713 "addtl_rmt_inf exceeds the maximum length of 140".to_string(),
3714 ));
3715 }
3716 }
3717 }
3718 Ok(())
3719 }
3720}
3721
3722#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3724pub struct SupplementaryData1 {
3725 #[serde(rename = "PlcAndNm", skip_serializing_if = "Option::is_none")]
3726 pub plc_and_nm: Option<String>,
3727 #[serde(rename = "Envlp")]
3728 pub envlp: SupplementaryDataEnvelope1,
3729}
3730
3731impl SupplementaryData1 {
3732 pub fn validate(&self) -> Result<(), ValidationError> {
3733 if let Some(ref val) = self.plc_and_nm {
3734 if val.chars().count() < 1 {
3735 return Err(ValidationError::new(
3736 1001,
3737 "plc_and_nm is shorter than the minimum length of 1".to_string(),
3738 ));
3739 }
3740 if val.chars().count() > 350 {
3741 return Err(ValidationError::new(
3742 1002,
3743 "plc_and_nm exceeds the maximum length of 350".to_string(),
3744 ));
3745 }
3746 }
3747 self.envlp.validate()?;
3748 Ok(())
3749 }
3750}
3751
3752#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3754pub struct SupplementaryDataEnvelope1 {}
3755
3756impl SupplementaryDataEnvelope1 {
3757 pub fn validate(&self) -> Result<(), ValidationError> {
3758 Ok(())
3759 }
3760}
3761
3762#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3764pub struct TaxAmount2 {
3765 #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
3766 pub rate: Option<f64>,
3767 #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3768 pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3769 #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
3770 pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3771 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
3772 pub dtls: Option<Vec<TaxRecordDetails2>>,
3773}
3774
3775impl TaxAmount2 {
3776 pub fn validate(&self) -> Result<(), ValidationError> {
3777 if let Some(ref val) = self.taxbl_base_amt {
3778 val.validate()?
3779 }
3780 if let Some(ref val) = self.ttl_amt {
3781 val.validate()?
3782 }
3783 if let Some(ref vec) = self.dtls {
3784 for item in vec {
3785 item.validate()?
3786 }
3787 }
3788 Ok(())
3789 }
3790}
3791
3792#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3794pub struct TaxAmountAndType1 {
3795 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3796 pub tp: Option<TaxAmountType1Choice>,
3797 #[serde(rename = "Amt")]
3798 pub amt: ActiveOrHistoricCurrencyAndAmount,
3799}
3800
3801impl TaxAmountAndType1 {
3802 pub fn validate(&self) -> Result<(), ValidationError> {
3803 if let Some(ref val) = self.tp {
3804 val.validate()?
3805 }
3806 self.amt.validate()?;
3807 Ok(())
3808 }
3809}
3810
3811#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3813pub struct TaxAmountType1Choice {
3814 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3815 pub cd: Option<String>,
3816 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
3817 pub prtry: Option<String>,
3818}
3819
3820impl TaxAmountType1Choice {
3821 pub fn validate(&self) -> Result<(), ValidationError> {
3822 if let Some(ref val) = self.cd {
3823 if val.chars().count() < 1 {
3824 return Err(ValidationError::new(
3825 1001,
3826 "cd is shorter than the minimum length of 1".to_string(),
3827 ));
3828 }
3829 if val.chars().count() > 4 {
3830 return Err(ValidationError::new(
3831 1002,
3832 "cd exceeds the maximum length of 4".to_string(),
3833 ));
3834 }
3835 }
3836 if let Some(ref val) = self.prtry {
3837 if val.chars().count() < 1 {
3838 return Err(ValidationError::new(
3839 1001,
3840 "prtry is shorter than the minimum length of 1".to_string(),
3841 ));
3842 }
3843 if val.chars().count() > 35 {
3844 return Err(ValidationError::new(
3845 1002,
3846 "prtry exceeds the maximum length of 35".to_string(),
3847 ));
3848 }
3849 }
3850 Ok(())
3851 }
3852}
3853
3854#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3856pub struct TaxAuthorisation1 {
3857 #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
3858 pub titl: Option<String>,
3859 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3860 pub nm: Option<String>,
3861}
3862
3863impl TaxAuthorisation1 {
3864 pub fn validate(&self) -> Result<(), ValidationError> {
3865 if let Some(ref val) = self.titl {
3866 if val.chars().count() < 1 {
3867 return Err(ValidationError::new(
3868 1001,
3869 "titl is shorter than the minimum length of 1".to_string(),
3870 ));
3871 }
3872 if val.chars().count() > 35 {
3873 return Err(ValidationError::new(
3874 1002,
3875 "titl exceeds the maximum length of 35".to_string(),
3876 ));
3877 }
3878 }
3879 if let Some(ref val) = self.nm {
3880 if val.chars().count() < 1 {
3881 return Err(ValidationError::new(
3882 1001,
3883 "nm is shorter than the minimum length of 1".to_string(),
3884 ));
3885 }
3886 if val.chars().count() > 140 {
3887 return Err(ValidationError::new(
3888 1002,
3889 "nm exceeds the maximum length of 140".to_string(),
3890 ));
3891 }
3892 }
3893 Ok(())
3894 }
3895}
3896
3897#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3899pub struct TaxInformation7 {
3900 #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3901 pub cdtr: Option<TaxParty1>,
3902 #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3903 pub dbtr: Option<TaxParty2>,
3904 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
3905 pub ultmt_dbtr: Option<TaxParty2>,
3906 #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
3907 pub admstn_zone: Option<String>,
3908 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3909 pub ref_nb: Option<String>,
3910 #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
3911 pub mtd: Option<String>,
3912 #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3913 pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3914 #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
3915 pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3916 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3917 pub dt: Option<String>,
3918 #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
3919 pub seq_nb: Option<f64>,
3920 #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
3921 pub rcrd: Option<Vec<TaxRecord2>>,
3922}
3923
3924impl TaxInformation7 {
3925 pub fn validate(&self) -> Result<(), ValidationError> {
3926 if let Some(ref val) = self.cdtr {
3927 val.validate()?
3928 }
3929 if let Some(ref val) = self.dbtr {
3930 val.validate()?
3931 }
3932 if let Some(ref val) = self.ultmt_dbtr {
3933 val.validate()?
3934 }
3935 if let Some(ref val) = self.admstn_zone {
3936 if val.chars().count() < 1 {
3937 return Err(ValidationError::new(
3938 1001,
3939 "admstn_zone is shorter than the minimum length of 1".to_string(),
3940 ));
3941 }
3942 if val.chars().count() > 35 {
3943 return Err(ValidationError::new(
3944 1002,
3945 "admstn_zone exceeds the maximum length of 35".to_string(),
3946 ));
3947 }
3948 }
3949 if let Some(ref val) = self.ref_nb {
3950 if val.chars().count() < 1 {
3951 return Err(ValidationError::new(
3952 1001,
3953 "ref_nb is shorter than the minimum length of 1".to_string(),
3954 ));
3955 }
3956 if val.chars().count() > 140 {
3957 return Err(ValidationError::new(
3958 1002,
3959 "ref_nb exceeds the maximum length of 140".to_string(),
3960 ));
3961 }
3962 }
3963 if let Some(ref val) = self.mtd {
3964 if val.chars().count() < 1 {
3965 return Err(ValidationError::new(
3966 1001,
3967 "mtd is shorter than the minimum length of 1".to_string(),
3968 ));
3969 }
3970 if val.chars().count() > 35 {
3971 return Err(ValidationError::new(
3972 1002,
3973 "mtd exceeds the maximum length of 35".to_string(),
3974 ));
3975 }
3976 }
3977 if let Some(ref val) = self.ttl_taxbl_base_amt {
3978 val.validate()?
3979 }
3980 if let Some(ref val) = self.ttl_tax_amt {
3981 val.validate()?
3982 }
3983 if let Some(ref vec) = self.rcrd {
3984 for item in vec {
3985 item.validate()?
3986 }
3987 }
3988 Ok(())
3989 }
3990}
3991
3992#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3994pub struct TaxInformation8 {
3995 #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3996 pub cdtr: Option<TaxParty1>,
3997 #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3998 pub dbtr: Option<TaxParty2>,
3999 #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
4000 pub admstn_zone: Option<String>,
4001 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
4002 pub ref_nb: Option<String>,
4003 #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
4004 pub mtd: Option<String>,
4005 #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
4006 pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4007 #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
4008 pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
4009 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
4010 pub dt: Option<String>,
4011 #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
4012 pub seq_nb: Option<f64>,
4013 #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
4014 pub rcrd: Option<Vec<TaxRecord2>>,
4015}
4016
4017impl TaxInformation8 {
4018 pub fn validate(&self) -> Result<(), ValidationError> {
4019 if let Some(ref val) = self.cdtr {
4020 val.validate()?
4021 }
4022 if let Some(ref val) = self.dbtr {
4023 val.validate()?
4024 }
4025 if let Some(ref val) = self.admstn_zone {
4026 if val.chars().count() < 1 {
4027 return Err(ValidationError::new(
4028 1001,
4029 "admstn_zone is shorter than the minimum length of 1".to_string(),
4030 ));
4031 }
4032 if val.chars().count() > 35 {
4033 return Err(ValidationError::new(
4034 1002,
4035 "admstn_zone exceeds the maximum length of 35".to_string(),
4036 ));
4037 }
4038 }
4039 if let Some(ref val) = self.ref_nb {
4040 if val.chars().count() < 1 {
4041 return Err(ValidationError::new(
4042 1001,
4043 "ref_nb is shorter than the minimum length of 1".to_string(),
4044 ));
4045 }
4046 if val.chars().count() > 140 {
4047 return Err(ValidationError::new(
4048 1002,
4049 "ref_nb exceeds the maximum length of 140".to_string(),
4050 ));
4051 }
4052 }
4053 if let Some(ref val) = self.mtd {
4054 if val.chars().count() < 1 {
4055 return Err(ValidationError::new(
4056 1001,
4057 "mtd is shorter than the minimum length of 1".to_string(),
4058 ));
4059 }
4060 if val.chars().count() > 35 {
4061 return Err(ValidationError::new(
4062 1002,
4063 "mtd exceeds the maximum length of 35".to_string(),
4064 ));
4065 }
4066 }
4067 if let Some(ref val) = self.ttl_taxbl_base_amt {
4068 val.validate()?
4069 }
4070 if let Some(ref val) = self.ttl_tax_amt {
4071 val.validate()?
4072 }
4073 if let Some(ref vec) = self.rcrd {
4074 for item in vec {
4075 item.validate()?
4076 }
4077 }
4078 Ok(())
4079 }
4080}
4081
4082#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4084pub struct TaxParty1 {
4085 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
4086 pub tax_id: Option<String>,
4087 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
4088 pub regn_id: Option<String>,
4089 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
4090 pub tax_tp: Option<String>,
4091}
4092
4093impl TaxParty1 {
4094 pub fn validate(&self) -> Result<(), ValidationError> {
4095 if let Some(ref val) = self.tax_id {
4096 if val.chars().count() < 1 {
4097 return Err(ValidationError::new(
4098 1001,
4099 "tax_id is shorter than the minimum length of 1".to_string(),
4100 ));
4101 }
4102 if val.chars().count() > 35 {
4103 return Err(ValidationError::new(
4104 1002,
4105 "tax_id exceeds the maximum length of 35".to_string(),
4106 ));
4107 }
4108 }
4109 if let Some(ref val) = self.regn_id {
4110 if val.chars().count() < 1 {
4111 return Err(ValidationError::new(
4112 1001,
4113 "regn_id is shorter than the minimum length of 1".to_string(),
4114 ));
4115 }
4116 if val.chars().count() > 35 {
4117 return Err(ValidationError::new(
4118 1002,
4119 "regn_id exceeds the maximum length of 35".to_string(),
4120 ));
4121 }
4122 }
4123 if let Some(ref val) = self.tax_tp {
4124 if val.chars().count() < 1 {
4125 return Err(ValidationError::new(
4126 1001,
4127 "tax_tp is shorter than the minimum length of 1".to_string(),
4128 ));
4129 }
4130 if val.chars().count() > 35 {
4131 return Err(ValidationError::new(
4132 1002,
4133 "tax_tp exceeds the maximum length of 35".to_string(),
4134 ));
4135 }
4136 }
4137 Ok(())
4138 }
4139}
4140
4141#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4143pub struct TaxParty2 {
4144 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
4145 pub tax_id: Option<String>,
4146 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
4147 pub regn_id: Option<String>,
4148 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
4149 pub tax_tp: Option<String>,
4150 #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
4151 pub authstn: Option<TaxAuthorisation1>,
4152}
4153
4154impl TaxParty2 {
4155 pub fn validate(&self) -> Result<(), ValidationError> {
4156 if let Some(ref val) = self.tax_id {
4157 if val.chars().count() < 1 {
4158 return Err(ValidationError::new(
4159 1001,
4160 "tax_id is shorter than the minimum length of 1".to_string(),
4161 ));
4162 }
4163 if val.chars().count() > 35 {
4164 return Err(ValidationError::new(
4165 1002,
4166 "tax_id exceeds the maximum length of 35".to_string(),
4167 ));
4168 }
4169 }
4170 if let Some(ref val) = self.regn_id {
4171 if val.chars().count() < 1 {
4172 return Err(ValidationError::new(
4173 1001,
4174 "regn_id is shorter than the minimum length of 1".to_string(),
4175 ));
4176 }
4177 if val.chars().count() > 35 {
4178 return Err(ValidationError::new(
4179 1002,
4180 "regn_id exceeds the maximum length of 35".to_string(),
4181 ));
4182 }
4183 }
4184 if let Some(ref val) = self.tax_tp {
4185 if val.chars().count() < 1 {
4186 return Err(ValidationError::new(
4187 1001,
4188 "tax_tp is shorter than the minimum length of 1".to_string(),
4189 ));
4190 }
4191 if val.chars().count() > 35 {
4192 return Err(ValidationError::new(
4193 1002,
4194 "tax_tp exceeds the maximum length of 35".to_string(),
4195 ));
4196 }
4197 }
4198 if let Some(ref val) = self.authstn {
4199 val.validate()?
4200 }
4201 Ok(())
4202 }
4203}
4204
4205#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4207pub struct TaxPeriod2 {
4208 #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
4209 pub yr: Option<String>,
4210 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4211 pub tp: Option<TaxRecordPeriod1Code>,
4212 #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
4213 pub fr_to_dt: Option<DatePeriod2>,
4214}
4215
4216impl TaxPeriod2 {
4217 pub fn validate(&self) -> Result<(), ValidationError> {
4218 if let Some(ref val) = self.tp {
4219 val.validate()?
4220 }
4221 if let Some(ref val) = self.fr_to_dt {
4222 val.validate()?
4223 }
4224 Ok(())
4225 }
4226}
4227
4228#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4230pub struct TaxRecord2 {
4231 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
4232 pub tp: Option<String>,
4233 #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
4234 pub ctgy: Option<String>,
4235 #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
4236 pub ctgy_dtls: Option<String>,
4237 #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
4238 pub dbtr_sts: Option<String>,
4239 #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
4240 pub cert_id: Option<String>,
4241 #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
4242 pub frms_cd: Option<String>,
4243 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
4244 pub prd: Option<TaxPeriod2>,
4245 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
4246 pub tax_amt: Option<TaxAmount2>,
4247 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
4248 pub addtl_inf: Option<String>,
4249}
4250
4251impl TaxRecord2 {
4252 pub fn validate(&self) -> Result<(), ValidationError> {
4253 if let Some(ref val) = self.tp {
4254 if val.chars().count() < 1 {
4255 return Err(ValidationError::new(
4256 1001,
4257 "tp is shorter than the minimum length of 1".to_string(),
4258 ));
4259 }
4260 if val.chars().count() > 35 {
4261 return Err(ValidationError::new(
4262 1002,
4263 "tp exceeds the maximum length of 35".to_string(),
4264 ));
4265 }
4266 }
4267 if let Some(ref val) = self.ctgy {
4268 if val.chars().count() < 1 {
4269 return Err(ValidationError::new(
4270 1001,
4271 "ctgy is shorter than the minimum length of 1".to_string(),
4272 ));
4273 }
4274 if val.chars().count() > 35 {
4275 return Err(ValidationError::new(
4276 1002,
4277 "ctgy exceeds the maximum length of 35".to_string(),
4278 ));
4279 }
4280 }
4281 if let Some(ref val) = self.ctgy_dtls {
4282 if val.chars().count() < 1 {
4283 return Err(ValidationError::new(
4284 1001,
4285 "ctgy_dtls is shorter than the minimum length of 1".to_string(),
4286 ));
4287 }
4288 if val.chars().count() > 35 {
4289 return Err(ValidationError::new(
4290 1002,
4291 "ctgy_dtls exceeds the maximum length of 35".to_string(),
4292 ));
4293 }
4294 }
4295 if let Some(ref val) = self.dbtr_sts {
4296 if val.chars().count() < 1 {
4297 return Err(ValidationError::new(
4298 1001,
4299 "dbtr_sts is shorter than the minimum length of 1".to_string(),
4300 ));
4301 }
4302 if val.chars().count() > 35 {
4303 return Err(ValidationError::new(
4304 1002,
4305 "dbtr_sts exceeds the maximum length of 35".to_string(),
4306 ));
4307 }
4308 }
4309 if let Some(ref val) = self.cert_id {
4310 if val.chars().count() < 1 {
4311 return Err(ValidationError::new(
4312 1001,
4313 "cert_id is shorter than the minimum length of 1".to_string(),
4314 ));
4315 }
4316 if val.chars().count() > 35 {
4317 return Err(ValidationError::new(
4318 1002,
4319 "cert_id exceeds the maximum length of 35".to_string(),
4320 ));
4321 }
4322 }
4323 if let Some(ref val) = self.frms_cd {
4324 if val.chars().count() < 1 {
4325 return Err(ValidationError::new(
4326 1001,
4327 "frms_cd is shorter than the minimum length of 1".to_string(),
4328 ));
4329 }
4330 if val.chars().count() > 35 {
4331 return Err(ValidationError::new(
4332 1002,
4333 "frms_cd exceeds the maximum length of 35".to_string(),
4334 ));
4335 }
4336 }
4337 if let Some(ref val) = self.prd {
4338 val.validate()?
4339 }
4340 if let Some(ref val) = self.tax_amt {
4341 val.validate()?
4342 }
4343 if let Some(ref val) = self.addtl_inf {
4344 if val.chars().count() < 1 {
4345 return Err(ValidationError::new(
4346 1001,
4347 "addtl_inf is shorter than the minimum length of 1".to_string(),
4348 ));
4349 }
4350 if val.chars().count() > 140 {
4351 return Err(ValidationError::new(
4352 1002,
4353 "addtl_inf exceeds the maximum length of 140".to_string(),
4354 ));
4355 }
4356 }
4357 Ok(())
4358 }
4359}
4360
4361#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4363pub struct TaxRecordDetails2 {
4364 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
4365 pub prd: Option<TaxPeriod2>,
4366 #[serde(rename = "Amt")]
4367 pub amt: ActiveOrHistoricCurrencyAndAmount,
4368}
4369
4370impl TaxRecordDetails2 {
4371 pub fn validate(&self) -> Result<(), ValidationError> {
4372 if let Some(ref val) = self.prd {
4373 val.validate()?
4374 }
4375 self.amt.validate()?;
4376 Ok(())
4377 }
4378}
4379
4380#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
4382pub enum TaxRecordPeriod1Code {
4383 #[default]
4384 #[serde(rename = "MM01")]
4385 CodeMM01,
4386 #[serde(rename = "MM02")]
4387 CodeMM02,
4388 #[serde(rename = "MM03")]
4389 CodeMM03,
4390 #[serde(rename = "MM04")]
4391 CodeMM04,
4392 #[serde(rename = "MM05")]
4393 CodeMM05,
4394 #[serde(rename = "MM06")]
4395 CodeMM06,
4396 #[serde(rename = "MM07")]
4397 CodeMM07,
4398 #[serde(rename = "MM08")]
4399 CodeMM08,
4400 #[serde(rename = "MM09")]
4401 CodeMM09,
4402 #[serde(rename = "MM10")]
4403 CodeMM10,
4404 #[serde(rename = "MM11")]
4405 CodeMM11,
4406 #[serde(rename = "MM12")]
4407 CodeMM12,
4408 #[serde(rename = "QTR1")]
4409 CodeQTR1,
4410 #[serde(rename = "QTR2")]
4411 CodeQTR2,
4412 #[serde(rename = "QTR3")]
4413 CodeQTR3,
4414 #[serde(rename = "QTR4")]
4415 CodeQTR4,
4416 #[serde(rename = "HLF1")]
4417 CodeHLF1,
4418 #[serde(rename = "HLF2")]
4419 CodeHLF2,
4420}
4421
4422impl TaxRecordPeriod1Code {
4423 pub fn validate(&self) -> Result<(), ValidationError> {
4424 Ok(())
4425 }
4426}