1use regex::Regex;
22use crate::common::ValidationError;
23use serde::{Deserialize, Serialize};
24
25
26#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
28pub struct AccountIdentification4Choice {
29 #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
30 pub iban: Option<String>,
31 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
32 pub othr: Option<GenericAccountIdentification1>,
33}
34
35impl AccountIdentification4Choice {
36 pub fn validate(&self) -> Result<(), ValidationError> {
37 if let Some(ref val) = self.iban {
38 let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
39 if !pattern.is_match(val) {
40 return Err(ValidationError::new(1005, "iban does not match the required pattern".to_string()));
41 }
42 }
43 if let Some(ref val) = self.othr { val.validate()? }
44 Ok(())
45 }
46}
47
48
49#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
51pub struct AccountSchemeName1Choice {
52 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
53 pub cd: Option<String>,
54 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
55 pub prtry: Option<String>,
56}
57
58impl AccountSchemeName1Choice {
59 pub fn validate(&self) -> Result<(), ValidationError> {
60 if let Some(ref val) = self.cd {
61 if val.chars().count() < 1 {
62 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
63 }
64 if val.chars().count() > 4 {
65 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
66 }
67 }
68 if let Some(ref val) = self.prtry {
69 if val.chars().count() < 1 {
70 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
71 }
72 if val.chars().count() > 35 {
73 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
74 }
75 }
76 Ok(())
77 }
78}
79
80
81#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
83pub struct ActiveCurrencyAndAmount {
84 #[serde(rename = "@Ccy")]
85 pub ccy: String,
86 #[serde(rename = "$value")]
87 pub value: f64,
88}
89
90impl ActiveCurrencyAndAmount {
91 pub fn validate(&self) -> Result<(), ValidationError> {
92 Ok(())
93 }
94}
95
96
97#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
99pub struct ActiveOrHistoricCurrencyAndAmount {
100 #[serde(rename = "@Ccy")]
101 pub ccy: String,
102 #[serde(rename = "$value")]
103 pub value: f64,
104}
105
106impl ActiveOrHistoricCurrencyAndAmount {
107 pub fn validate(&self) -> Result<(), ValidationError> {
108 Ok(())
109 }
110}
111
112
113#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
115pub struct AdditionalDateTime1 {
116 #[serde(rename = "AccptncDtTm", skip_serializing_if = "Option::is_none")]
117 pub accptnc_dt_tm: Option<String>,
118 #[serde(rename = "PoolgAdjstmntDt", skip_serializing_if = "Option::is_none")]
119 pub poolg_adjstmnt_dt: Option<String>,
120 #[serde(rename = "XpryDtTm", skip_serializing_if = "Option::is_none")]
121 pub xpry_dt_tm: Option<String>,
122}
123
124impl AdditionalDateTime1 {
125 pub fn validate(&self) -> Result<(), ValidationError> {
126 Ok(())
127 }
128}
129
130
131#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
133pub enum AddressType2Code {
134 #[default]
135 #[serde(rename = "ADDR")]
136 CodeADDR,
137 #[serde(rename = "PBOX")]
138 CodePBOX,
139 #[serde(rename = "HOME")]
140 CodeHOME,
141 #[serde(rename = "BIZZ")]
142 CodeBIZZ,
143 #[serde(rename = "MLTO")]
144 CodeMLTO,
145 #[serde(rename = "DLVY")]
146 CodeDLVY,
147}
148
149impl AddressType2Code {
150 pub fn validate(&self) -> Result<(), ValidationError> {
151 Ok(())
152 }
153}
154
155
156#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
158pub struct AddressType3Choice {
159 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
160 pub cd: Option<AddressType2Code>,
161 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
162 pub prtry: Option<GenericIdentification30>,
163}
164
165impl AddressType3Choice {
166 pub fn validate(&self) -> Result<(), ValidationError> {
167 if let Some(ref val) = self.cd { val.validate()? }
168 if let Some(ref val) = self.prtry { val.validate()? }
169 Ok(())
170 }
171}
172
173
174#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
176pub struct BranchAndFinancialInstitutionIdentification8 {
177 #[serde(rename = "FinInstnId")]
178 pub fin_instn_id: FinancialInstitutionIdentification23,
179 #[serde(rename = "BrnchId", skip_serializing_if = "Option::is_none")]
180 pub brnch_id: Option<BranchData5>,
181}
182
183impl BranchAndFinancialInstitutionIdentification8 {
184 pub fn validate(&self) -> Result<(), ValidationError> {
185 self.fin_instn_id.validate()?;
186 if let Some(ref val) = self.brnch_id { val.validate()? }
187 Ok(())
188 }
189}
190
191
192#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
194pub struct BranchData5 {
195 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
196 pub id: Option<String>,
197 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
198 pub lei: Option<String>,
199 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
200 pub nm: Option<String>,
201 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
202 pub pstl_adr: Option<PostalAddress27>,
203}
204
205impl BranchData5 {
206 pub fn validate(&self) -> Result<(), ValidationError> {
207 if let Some(ref val) = self.id {
208 if val.chars().count() < 1 {
209 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
210 }
211 if val.chars().count() > 35 {
212 return Err(ValidationError::new(1002, "id exceeds the maximum length of 35".to_string()));
213 }
214 }
215 if let Some(ref val) = self.lei {
216 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
217 if !pattern.is_match(val) {
218 return Err(ValidationError::new(1005, "lei does not match the required pattern".to_string()));
219 }
220 }
221 if let Some(ref val) = self.nm {
222 if val.chars().count() < 1 {
223 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
224 }
225 if val.chars().count() > 140 {
226 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
227 }
228 }
229 if let Some(ref val) = self.pstl_adr { val.validate()? }
230 Ok(())
231 }
232}
233
234
235#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
237pub struct CashAccount40 {
238 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
239 pub id: Option<AccountIdentification4Choice>,
240 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
241 pub tp: Option<CashAccountType2Choice>,
242 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
243 pub ccy: Option<String>,
244 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
245 pub nm: Option<String>,
246 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
247 pub prxy: Option<ProxyAccountIdentification1>,
248}
249
250impl CashAccount40 {
251 pub fn validate(&self) -> Result<(), ValidationError> {
252 if let Some(ref val) = self.id { val.validate()? }
253 if let Some(ref val) = self.tp { val.validate()? }
254 if let Some(ref val) = self.ccy {
255 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
256 if !pattern.is_match(val) {
257 return Err(ValidationError::new(1005, "ccy does not match the required pattern".to_string()));
258 }
259 }
260 if let Some(ref val) = self.nm {
261 if val.chars().count() < 1 {
262 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
263 }
264 if val.chars().count() > 70 {
265 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 70".to_string()));
266 }
267 }
268 if let Some(ref val) = self.prxy { val.validate()? }
269 Ok(())
270 }
271}
272
273
274#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
276pub struct CashAccountType2Choice {
277 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
278 pub cd: Option<String>,
279 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
280 pub prtry: Option<String>,
281}
282
283impl CashAccountType2Choice {
284 pub fn validate(&self) -> Result<(), ValidationError> {
285 if let Some(ref val) = self.cd {
286 if val.chars().count() < 1 {
287 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
288 }
289 if val.chars().count() > 4 {
290 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
291 }
292 }
293 if let Some(ref val) = self.prtry {
294 if val.chars().count() < 1 {
295 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
296 }
297 if val.chars().count() > 35 {
298 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
299 }
300 }
301 Ok(())
302 }
303}
304
305
306#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
308pub struct CategoryPurpose1Choice {
309 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
310 pub cd: Option<String>,
311 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
312 pub prtry: Option<String>,
313}
314
315impl CategoryPurpose1Choice {
316 pub fn validate(&self) -> Result<(), ValidationError> {
317 if let Some(ref val) = self.cd {
318 if val.chars().count() < 1 {
319 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
320 }
321 if val.chars().count() > 4 {
322 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
323 }
324 }
325 if let Some(ref val) = self.prtry {
326 if val.chars().count() < 1 {
327 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
328 }
329 if val.chars().count() > 35 {
330 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
331 }
332 }
333 Ok(())
334 }
335}
336
337
338#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
340pub enum ChargeBearerType1Code {
341 #[default]
342 #[serde(rename = "DEBT")]
343 CodeDEBT,
344 #[serde(rename = "CRED")]
345 CodeCRED,
346 #[serde(rename = "SHAR")]
347 CodeSHAR,
348 #[serde(rename = "SLEV")]
349 CodeSLEV,
350}
351
352impl ChargeBearerType1Code {
353 pub fn validate(&self) -> Result<(), ValidationError> {
354 Ok(())
355 }
356}
357
358
359#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
361pub struct ChargeType3Choice {
362 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
363 pub cd: Option<String>,
364 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
365 pub prtry: Option<GenericIdentification3>,
366}
367
368impl ChargeType3Choice {
369 pub fn validate(&self) -> Result<(), ValidationError> {
370 if let Some(ref val) = self.cd {
371 if val.chars().count() < 1 {
372 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
373 }
374 if val.chars().count() > 4 {
375 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
376 }
377 }
378 if let Some(ref val) = self.prtry { val.validate()? }
379 Ok(())
380 }
381}
382
383
384#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
386pub struct Charges16 {
387 #[serde(rename = "Amt")]
388 pub amt: ActiveOrHistoricCurrencyAndAmount,
389 #[serde(rename = "Agt")]
390 pub agt: BranchAndFinancialInstitutionIdentification8,
391 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
392 pub tp: Option<ChargeType3Choice>,
393}
394
395impl Charges16 {
396 pub fn validate(&self) -> Result<(), ValidationError> {
397 self.amt.validate()?;
398 self.agt.validate()?;
399 if let Some(ref val) = self.tp { val.validate()? }
400 Ok(())
401 }
402}
403
404
405#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
407pub enum ClearingChannel2Code {
408 #[default]
409 #[serde(rename = "RTGS")]
410 CodeRTGS,
411 #[serde(rename = "RTNS")]
412 CodeRTNS,
413 #[serde(rename = "MPNS")]
414 CodeMPNS,
415 #[serde(rename = "BOOK")]
416 CodeBOOK,
417}
418
419impl ClearingChannel2Code {
420 pub fn validate(&self) -> Result<(), ValidationError> {
421 Ok(())
422 }
423}
424
425
426#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
428pub struct ClearingSystemIdentification2Choice {
429 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
430 pub cd: Option<String>,
431 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
432 pub prtry: Option<String>,
433}
434
435impl ClearingSystemIdentification2Choice {
436 pub fn validate(&self) -> Result<(), ValidationError> {
437 if let Some(ref val) = self.cd {
438 if val.chars().count() < 1 {
439 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
440 }
441 if val.chars().count() > 5 {
442 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 5".to_string()));
443 }
444 }
445 if let Some(ref val) = self.prtry {
446 if val.chars().count() < 1 {
447 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
448 }
449 if val.chars().count() > 35 {
450 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
451 }
452 }
453 Ok(())
454 }
455}
456
457
458#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
460pub struct ClearingSystemIdentification3Choice {
461 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
462 pub cd: Option<String>,
463 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
464 pub prtry: Option<String>,
465}
466
467impl ClearingSystemIdentification3Choice {
468 pub fn validate(&self) -> Result<(), ValidationError> {
469 if let Some(ref val) = self.cd {
470 if val.chars().count() < 1 {
471 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
472 }
473 if val.chars().count() > 3 {
474 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 3".to_string()));
475 }
476 }
477 if let Some(ref val) = self.prtry {
478 if val.chars().count() < 1 {
479 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
480 }
481 if val.chars().count() > 35 {
482 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
483 }
484 }
485 Ok(())
486 }
487}
488
489
490#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
492pub struct ClearingSystemMemberIdentification2 {
493 #[serde(rename = "ClrSysId", skip_serializing_if = "Option::is_none")]
494 pub clr_sys_id: Option<ClearingSystemIdentification2Choice>,
495 #[serde(rename = "MmbId")]
496 pub mmb_id: String,
497}
498
499impl ClearingSystemMemberIdentification2 {
500 pub fn validate(&self) -> Result<(), ValidationError> {
501 if let Some(ref val) = self.clr_sys_id { val.validate()? }
502 if self.mmb_id.chars().count() < 1 {
503 return Err(ValidationError::new(1001, "mmb_id is shorter than the minimum length of 1".to_string()));
504 }
505 if self.mmb_id.chars().count() > 35 {
506 return Err(ValidationError::new(1002, "mmb_id exceeds the maximum length of 35".to_string()));
507 }
508 Ok(())
509 }
510}
511
512
513#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
515pub struct Contact13 {
516 #[serde(rename = "NmPrfx", skip_serializing_if = "Option::is_none")]
517 pub nm_prfx: Option<NamePrefix2Code>,
518 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
519 pub nm: Option<String>,
520 #[serde(rename = "PhneNb", skip_serializing_if = "Option::is_none")]
521 pub phne_nb: Option<String>,
522 #[serde(rename = "MobNb", skip_serializing_if = "Option::is_none")]
523 pub mob_nb: Option<String>,
524 #[serde(rename = "FaxNb", skip_serializing_if = "Option::is_none")]
525 pub fax_nb: Option<String>,
526 #[serde(rename = "URLAdr", skip_serializing_if = "Option::is_none")]
527 pub url_adr: Option<String>,
528 #[serde(rename = "EmailAdr", skip_serializing_if = "Option::is_none")]
529 pub email_adr: Option<String>,
530 #[serde(rename = "EmailPurp", skip_serializing_if = "Option::is_none")]
531 pub email_purp: Option<String>,
532 #[serde(rename = "JobTitl", skip_serializing_if = "Option::is_none")]
533 pub job_titl: Option<String>,
534 #[serde(rename = "Rspnsblty", skip_serializing_if = "Option::is_none")]
535 pub rspnsblty: Option<String>,
536 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
537 pub dept: Option<String>,
538 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
539 pub othr: Option<Vec<OtherContact1>>,
540 #[serde(rename = "PrefrdMtd", skip_serializing_if = "Option::is_none")]
541 pub prefrd_mtd: Option<PreferredContactMethod2Code>,
542}
543
544impl Contact13 {
545 pub fn validate(&self) -> Result<(), ValidationError> {
546 if let Some(ref val) = self.nm_prfx { val.validate()? }
547 if let Some(ref val) = self.nm {
548 if val.chars().count() < 1 {
549 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
550 }
551 if val.chars().count() > 140 {
552 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
553 }
554 }
555 if let Some(ref val) = self.phne_nb {
556 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
557 if !pattern.is_match(val) {
558 return Err(ValidationError::new(1005, "phne_nb does not match the required pattern".to_string()));
559 }
560 }
561 if let Some(ref val) = self.mob_nb {
562 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
563 if !pattern.is_match(val) {
564 return Err(ValidationError::new(1005, "mob_nb does not match the required pattern".to_string()));
565 }
566 }
567 if let Some(ref val) = self.fax_nb {
568 let pattern = Regex::new("\\+[0-9]{1,3}-[0-9()+\\-]{1,30}").unwrap();
569 if !pattern.is_match(val) {
570 return Err(ValidationError::new(1005, "fax_nb does not match the required pattern".to_string()));
571 }
572 }
573 if let Some(ref val) = self.url_adr {
574 if val.chars().count() < 1 {
575 return Err(ValidationError::new(1001, "url_adr is shorter than the minimum length of 1".to_string()));
576 }
577 if val.chars().count() > 2048 {
578 return Err(ValidationError::new(1002, "url_adr exceeds the maximum length of 2048".to_string()));
579 }
580 }
581 if let Some(ref val) = self.email_adr {
582 if val.chars().count() < 1 {
583 return Err(ValidationError::new(1001, "email_adr is shorter than the minimum length of 1".to_string()));
584 }
585 if val.chars().count() > 256 {
586 return Err(ValidationError::new(1002, "email_adr exceeds the maximum length of 256".to_string()));
587 }
588 }
589 if let Some(ref val) = self.email_purp {
590 if val.chars().count() < 1 {
591 return Err(ValidationError::new(1001, "email_purp is shorter than the minimum length of 1".to_string()));
592 }
593 if val.chars().count() > 35 {
594 return Err(ValidationError::new(1002, "email_purp exceeds the maximum length of 35".to_string()));
595 }
596 }
597 if let Some(ref val) = self.job_titl {
598 if val.chars().count() < 1 {
599 return Err(ValidationError::new(1001, "job_titl is shorter than the minimum length of 1".to_string()));
600 }
601 if val.chars().count() > 35 {
602 return Err(ValidationError::new(1002, "job_titl exceeds the maximum length of 35".to_string()));
603 }
604 }
605 if let Some(ref val) = self.rspnsblty {
606 if val.chars().count() < 1 {
607 return Err(ValidationError::new(1001, "rspnsblty is shorter than the minimum length of 1".to_string()));
608 }
609 if val.chars().count() > 35 {
610 return Err(ValidationError::new(1002, "rspnsblty exceeds the maximum length of 35".to_string()));
611 }
612 }
613 if let Some(ref val) = self.dept {
614 if val.chars().count() < 1 {
615 return Err(ValidationError::new(1001, "dept is shorter than the minimum length of 1".to_string()));
616 }
617 if val.chars().count() > 70 {
618 return Err(ValidationError::new(1002, "dept exceeds the maximum length of 70".to_string()));
619 }
620 }
621 if let Some(ref vec) = self.othr { for item in vec { item.validate()? } }
622 if let Some(ref val) = self.prefrd_mtd { val.validate()? }
623 Ok(())
624 }
625}
626
627
628#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
630pub enum CreditDebitCode {
631 #[default]
632 #[serde(rename = "CRDT")]
633 CodeCRDT,
634 #[serde(rename = "DBIT")]
635 CodeDBIT,
636}
637
638impl CreditDebitCode {
639 pub fn validate(&self) -> Result<(), ValidationError> {
640 Ok(())
641 }
642}
643
644
645#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
647pub struct CreditTransferMandateData1 {
648 #[serde(rename = "MndtId", skip_serializing_if = "Option::is_none")]
649 pub mndt_id: Option<String>,
650 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
651 pub tp: Option<MandateTypeInformation2>,
652 #[serde(rename = "DtOfSgntr", skip_serializing_if = "Option::is_none")]
653 pub dt_of_sgntr: Option<String>,
654 #[serde(rename = "DtOfVrfctn", skip_serializing_if = "Option::is_none")]
655 pub dt_of_vrfctn: Option<String>,
656 #[serde(rename = "ElctrncSgntr", skip_serializing_if = "Option::is_none")]
657 pub elctrnc_sgntr: Option<String>,
658 #[serde(rename = "FrstPmtDt", skip_serializing_if = "Option::is_none")]
659 pub frst_pmt_dt: Option<String>,
660 #[serde(rename = "FnlPmtDt", skip_serializing_if = "Option::is_none")]
661 pub fnl_pmt_dt: Option<String>,
662 #[serde(rename = "Frqcy", skip_serializing_if = "Option::is_none")]
663 pub frqcy: Option<Frequency36Choice>,
664 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
665 pub rsn: Option<MandateSetupReason1Choice>,
666}
667
668impl CreditTransferMandateData1 {
669 pub fn validate(&self) -> Result<(), ValidationError> {
670 if let Some(ref val) = self.mndt_id {
671 if val.chars().count() < 1 {
672 return Err(ValidationError::new(1001, "mndt_id is shorter than the minimum length of 1".to_string()));
673 }
674 if val.chars().count() > 35 {
675 return Err(ValidationError::new(1002, "mndt_id exceeds the maximum length of 35".to_string()));
676 }
677 }
678 if let Some(ref val) = self.tp { val.validate()? }
679 if let Some(ref val) = self.elctrnc_sgntr {
680 if val.chars().count() < 1 {
681 return Err(ValidationError::new(1001, "elctrnc_sgntr is shorter than the minimum length of 1".to_string()));
682 }
683 if val.chars().count() > 10240 {
684 return Err(ValidationError::new(1002, "elctrnc_sgntr exceeds the maximum length of 10240".to_string()));
685 }
686 }
687 if let Some(ref val) = self.frqcy { val.validate()? }
688 if let Some(ref val) = self.rsn { val.validate()? }
689 Ok(())
690 }
691}
692
693
694#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
696pub struct CreditTransferTransaction70 {
697 #[serde(rename = "PmtId")]
698 pub pmt_id: PaymentIdentification13,
699 #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
700 pub pmt_tp_inf: Option<PaymentTypeInformation28>,
701 #[serde(rename = "IntrBkSttlmAmt")]
702 pub intr_bk_sttlm_amt: ActiveCurrencyAndAmount,
703 #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
704 pub intr_bk_sttlm_dt: Option<String>,
705 #[serde(rename = "SttlmPrty", skip_serializing_if = "Option::is_none")]
706 pub sttlm_prty: Option<Priority3Code>,
707 #[serde(rename = "SttlmTmIndctn", skip_serializing_if = "Option::is_none")]
708 pub sttlm_tm_indctn: Option<SettlementDateTimeIndication1>,
709 #[serde(rename = "SttlmTmReq", skip_serializing_if = "Option::is_none")]
710 pub sttlm_tm_req: Option<SettlementTimeRequest2>,
711 #[serde(rename = "AddtlDtTm", skip_serializing_if = "Option::is_none")]
712 pub addtl_dt_tm: Option<AdditionalDateTime1>,
713 #[serde(rename = "InstdAmt", skip_serializing_if = "Option::is_none")]
714 pub instd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
715 #[serde(rename = "XchgRate", skip_serializing_if = "Option::is_none")]
716 pub xchg_rate: Option<f64>,
717 #[serde(rename = "AgrdRate", skip_serializing_if = "Option::is_none")]
718 pub agrd_rate: Option<CurrencyExchange26>,
719 #[serde(rename = "ChrgBr")]
720 pub chrg_br: ChargeBearerType1Code,
721 #[serde(rename = "ChrgsInf", skip_serializing_if = "Option::is_none")]
722 pub chrgs_inf: Option<Vec<Charges16>>,
723 #[serde(rename = "MndtRltdInf", skip_serializing_if = "Option::is_none")]
724 pub mndt_rltd_inf: Option<CreditTransferMandateData1>,
725 #[serde(rename = "PmtSgntr", skip_serializing_if = "Option::is_none")]
726 pub pmt_sgntr: Option<CryptographicKey1Choice>,
727 #[serde(rename = "PrvsInstgAgt1", skip_serializing_if = "Option::is_none")]
728 pub prvs_instg_agt1: Option<BranchAndFinancialInstitutionIdentification8>,
729 #[serde(rename = "PrvsInstgAgt1Acct", skip_serializing_if = "Option::is_none")]
730 pub prvs_instg_agt1_acct: Option<CashAccount40>,
731 #[serde(rename = "PrvsInstgAgt2", skip_serializing_if = "Option::is_none")]
732 pub prvs_instg_agt2: Option<BranchAndFinancialInstitutionIdentification8>,
733 #[serde(rename = "PrvsInstgAgt2Acct", skip_serializing_if = "Option::is_none")]
734 pub prvs_instg_agt2_acct: Option<CashAccount40>,
735 #[serde(rename = "PrvsInstgAgt3", skip_serializing_if = "Option::is_none")]
736 pub prvs_instg_agt3: Option<BranchAndFinancialInstitutionIdentification8>,
737 #[serde(rename = "PrvsInstgAgt3Acct", skip_serializing_if = "Option::is_none")]
738 pub prvs_instg_agt3_acct: Option<CashAccount40>,
739 #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
740 pub instg_agt: Option<BranchAndFinancialInstitutionIdentification8>,
741 #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
742 pub instd_agt: Option<BranchAndFinancialInstitutionIdentification8>,
743 #[serde(rename = "IntrmyAgt1", skip_serializing_if = "Option::is_none")]
744 pub intrmy_agt1: Option<BranchAndFinancialInstitutionIdentification8>,
745 #[serde(rename = "IntrmyAgt1Acct", skip_serializing_if = "Option::is_none")]
746 pub intrmy_agt1_acct: Option<CashAccount40>,
747 #[serde(rename = "IntrmyAgt2", skip_serializing_if = "Option::is_none")]
748 pub intrmy_agt2: Option<BranchAndFinancialInstitutionIdentification8>,
749 #[serde(rename = "IntrmyAgt2Acct", skip_serializing_if = "Option::is_none")]
750 pub intrmy_agt2_acct: Option<CashAccount40>,
751 #[serde(rename = "IntrmyAgt3", skip_serializing_if = "Option::is_none")]
752 pub intrmy_agt3: Option<BranchAndFinancialInstitutionIdentification8>,
753 #[serde(rename = "IntrmyAgt3Acct", skip_serializing_if = "Option::is_none")]
754 pub intrmy_agt3_acct: Option<CashAccount40>,
755 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
756 pub ultmt_dbtr: Option<PartyIdentification272>,
757 #[serde(rename = "InitgPty", skip_serializing_if = "Option::is_none")]
758 pub initg_pty: Option<PartyIdentification272>,
759 #[serde(rename = "Dbtr")]
760 pub dbtr: PartyIdentification272,
761 #[serde(rename = "DbtrAcct", skip_serializing_if = "Option::is_none")]
762 pub dbtr_acct: Option<CashAccount40>,
763 #[serde(rename = "DbtrAgt")]
764 pub dbtr_agt: BranchAndFinancialInstitutionIdentification8,
765 #[serde(rename = "DbtrAgtAcct", skip_serializing_if = "Option::is_none")]
766 pub dbtr_agt_acct: Option<CashAccount40>,
767 #[serde(rename = "CdtrAgt")]
768 pub cdtr_agt: BranchAndFinancialInstitutionIdentification8,
769 #[serde(rename = "CdtrAgtAcct", skip_serializing_if = "Option::is_none")]
770 pub cdtr_agt_acct: Option<CashAccount40>,
771 #[serde(rename = "Cdtr")]
772 pub cdtr: PartyIdentification272,
773 #[serde(rename = "CdtrAcct", skip_serializing_if = "Option::is_none")]
774 pub cdtr_acct: Option<CashAccount40>,
775 #[serde(rename = "UltmtCdtr", skip_serializing_if = "Option::is_none")]
776 pub ultmt_cdtr: Option<PartyIdentification272>,
777 #[serde(rename = "InstrForCdtrAgt", skip_serializing_if = "Option::is_none")]
778 pub instr_for_cdtr_agt: Option<Vec<InstructionForCreditorAgent3>>,
779 #[serde(rename = "InstrForNxtAgt", skip_serializing_if = "Option::is_none")]
780 pub instr_for_nxt_agt: Option<Vec<InstructionForNextAgent1>>,
781 #[serde(rename = "Purp", skip_serializing_if = "Option::is_none")]
782 pub purp: Option<Purpose2Choice>,
783 #[serde(rename = "RgltryRptg", skip_serializing_if = "Option::is_none")]
784 pub rgltry_rptg: Option<Vec<RegulatoryReporting3>>,
785 #[serde(rename = "Tax", skip_serializing_if = "Option::is_none")]
786 pub tax: Option<TaxData1>,
787 #[serde(rename = "RltdRmtInf", skip_serializing_if = "Option::is_none")]
788 pub rltd_rmt_inf: Option<Vec<RemittanceLocation8>>,
789 #[serde(rename = "RmtInf", skip_serializing_if = "Option::is_none")]
790 pub rmt_inf: Option<RemittanceInformation22>,
791 #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
792 pub splmtry_data: Option<Vec<SupplementaryData1>>,
793}
794
795impl CreditTransferTransaction70 {
796 pub fn validate(&self) -> Result<(), ValidationError> {
797 self.pmt_id.validate()?;
798 if let Some(ref val) = self.pmt_tp_inf { val.validate()? }
799 self.intr_bk_sttlm_amt.validate()?;
800 if let Some(ref val) = self.sttlm_prty { val.validate()? }
801 if let Some(ref val) = self.sttlm_tm_indctn { val.validate()? }
802 if let Some(ref val) = self.sttlm_tm_req { val.validate()? }
803 if let Some(ref val) = self.addtl_dt_tm { val.validate()? }
804 if let Some(ref val) = self.instd_amt { val.validate()? }
805 if let Some(ref val) = self.agrd_rate { val.validate()? }
806 self.chrg_br.validate()?;
807 if let Some(ref vec) = self.chrgs_inf { for item in vec { item.validate()? } }
808 if let Some(ref val) = self.mndt_rltd_inf { val.validate()? }
809 if let Some(ref val) = self.pmt_sgntr { val.validate()? }
810 if let Some(ref val) = self.prvs_instg_agt1 { val.validate()? }
811 if let Some(ref val) = self.prvs_instg_agt1_acct { val.validate()? }
812 if let Some(ref val) = self.prvs_instg_agt2 { val.validate()? }
813 if let Some(ref val) = self.prvs_instg_agt2_acct { val.validate()? }
814 if let Some(ref val) = self.prvs_instg_agt3 { val.validate()? }
815 if let Some(ref val) = self.prvs_instg_agt3_acct { val.validate()? }
816 if let Some(ref val) = self.instg_agt { val.validate()? }
817 if let Some(ref val) = self.instd_agt { val.validate()? }
818 if let Some(ref val) = self.intrmy_agt1 { val.validate()? }
819 if let Some(ref val) = self.intrmy_agt1_acct { val.validate()? }
820 if let Some(ref val) = self.intrmy_agt2 { val.validate()? }
821 if let Some(ref val) = self.intrmy_agt2_acct { val.validate()? }
822 if let Some(ref val) = self.intrmy_agt3 { val.validate()? }
823 if let Some(ref val) = self.intrmy_agt3_acct { val.validate()? }
824 if let Some(ref val) = self.ultmt_dbtr { val.validate()? }
825 if let Some(ref val) = self.initg_pty { val.validate()? }
826 self.dbtr.validate()?;
827 if let Some(ref val) = self.dbtr_acct { val.validate()? }
828 self.dbtr_agt.validate()?;
829 if let Some(ref val) = self.dbtr_agt_acct { val.validate()? }
830 self.cdtr_agt.validate()?;
831 if let Some(ref val) = self.cdtr_agt_acct { val.validate()? }
832 self.cdtr.validate()?;
833 if let Some(ref val) = self.cdtr_acct { val.validate()? }
834 if let Some(ref val) = self.ultmt_cdtr { val.validate()? }
835 if let Some(ref vec) = self.instr_for_cdtr_agt { for item in vec { item.validate()? } }
836 if let Some(ref vec) = self.instr_for_nxt_agt { for item in vec { item.validate()? } }
837 if let Some(ref val) = self.purp { val.validate()? }
838 if let Some(ref vec) = self.rgltry_rptg { for item in vec { item.validate()? } }
839 if let Some(ref val) = self.tax { val.validate()? }
840 if let Some(ref vec) = self.rltd_rmt_inf { for item in vec { item.validate()? } }
841 if let Some(ref val) = self.rmt_inf { val.validate()? }
842 if let Some(ref vec) = self.splmtry_data { for item in vec { item.validate()? } }
843 Ok(())
844 }
845}
846
847
848#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
850pub struct CreditorReferenceInformation3 {
851 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
852 pub tp: Option<CreditorReferenceType3>,
853 #[serde(rename = "Ref", skip_serializing_if = "Option::is_none")]
854 pub ref_attr: Option<String>,
855}
856
857impl CreditorReferenceInformation3 {
858 pub fn validate(&self) -> Result<(), ValidationError> {
859 if let Some(ref val) = self.tp { val.validate()? }
860 if let Some(ref val) = self.ref_attr {
861 if val.chars().count() < 1 {
862 return Err(ValidationError::new(1001, "ref_attr is shorter than the minimum length of 1".to_string()));
863 }
864 if val.chars().count() > 35 {
865 return Err(ValidationError::new(1002, "ref_attr exceeds the maximum length of 35".to_string()));
866 }
867 }
868 Ok(())
869 }
870}
871
872
873#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
875pub struct CreditorReferenceType2Choice {
876 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
877 pub cd: Option<String>,
878 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
879 pub prtry: Option<String>,
880}
881
882impl CreditorReferenceType2Choice {
883 pub fn validate(&self) -> Result<(), ValidationError> {
884 if let Some(ref val) = self.cd {
885 if val.chars().count() < 1 {
886 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
887 }
888 if val.chars().count() > 4 {
889 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
890 }
891 }
892 if let Some(ref val) = self.prtry {
893 if val.chars().count() < 1 {
894 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
895 }
896 if val.chars().count() > 35 {
897 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
898 }
899 }
900 Ok(())
901 }
902}
903
904
905#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
907pub struct CreditorReferenceType3 {
908 #[serde(rename = "CdOrPrtry")]
909 pub cd_or_prtry: CreditorReferenceType2Choice,
910 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
911 pub issr: Option<String>,
912}
913
914impl CreditorReferenceType3 {
915 pub fn validate(&self) -> Result<(), ValidationError> {
916 self.cd_or_prtry.validate()?;
917 if let Some(ref val) = self.issr {
918 if val.chars().count() < 1 {
919 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
920 }
921 if val.chars().count() > 35 {
922 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
923 }
924 }
925 Ok(())
926 }
927}
928
929
930#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
932pub struct CryptographicKey1Choice {
933 #[serde(rename = "ILPV4", skip_serializing_if = "Option::is_none")]
934 pub ilpv4: Option<String>,
935 #[serde(rename = "Sgntr", skip_serializing_if = "Option::is_none")]
936 pub sgntr: Option<String>,
937}
938
939impl CryptographicKey1Choice {
940 pub fn validate(&self) -> Result<(), ValidationError> {
941 if let Some(ref val) = self.ilpv4 {
942 let pattern = Regex::new("[0-9a-fA-F]+").unwrap();
943 if !pattern.is_match(val) {
944 return Err(ValidationError::new(1005, "ilpv4 does not match the required pattern".to_string()));
945 }
946 }
947 if let Some(ref val) = self.sgntr {
948 let pattern = Regex::new("([0-9A-F][0-9A-F]){32}").unwrap();
949 if !pattern.is_match(val) {
950 return Err(ValidationError::new(1005, "sgntr does not match the required pattern".to_string()));
951 }
952 }
953 Ok(())
954 }
955}
956
957
958#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
960pub struct CurrencyExchange26 {
961 #[serde(rename = "UnitCcy", skip_serializing_if = "Option::is_none")]
962 pub unit_ccy: Option<String>,
963 #[serde(rename = "QtdCcy", skip_serializing_if = "Option::is_none")]
964 pub qtd_ccy: Option<String>,
965 #[serde(rename = "PreAgrdXchgRate")]
966 pub pre_agrd_xchg_rate: f64,
967 #[serde(rename = "QtnDtTm", skip_serializing_if = "Option::is_none")]
968 pub qtn_dt_tm: Option<String>,
969 #[serde(rename = "QtId", skip_serializing_if = "Option::is_none")]
970 pub qt_id: Option<String>,
971 #[serde(rename = "FXAgt", skip_serializing_if = "Option::is_none")]
972 pub fx_agt: Option<BranchAndFinancialInstitutionIdentification8>,
973}
974
975impl CurrencyExchange26 {
976 pub fn validate(&self) -> Result<(), ValidationError> {
977 if let Some(ref val) = self.unit_ccy {
978 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
979 if !pattern.is_match(val) {
980 return Err(ValidationError::new(1005, "unit_ccy does not match the required pattern".to_string()));
981 }
982 }
983 if let Some(ref val) = self.qtd_ccy {
984 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
985 if !pattern.is_match(val) {
986 return Err(ValidationError::new(1005, "qtd_ccy does not match the required pattern".to_string()));
987 }
988 }
989 if let Some(ref val) = self.qt_id {
990 let pattern = Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}").unwrap();
991 if !pattern.is_match(val) {
992 return Err(ValidationError::new(1005, "qt_id does not match the required pattern".to_string()));
993 }
994 }
995 if let Some(ref val) = self.fx_agt { val.validate()? }
996 Ok(())
997 }
998}
999
1000
1001#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1003pub struct DateAndPlaceOfBirth1 {
1004 #[serde(rename = "BirthDt")]
1005 pub birth_dt: String,
1006 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
1007 pub prvc_of_birth: Option<String>,
1008 #[serde(rename = "CityOfBirth")]
1009 pub city_of_birth: String,
1010 #[serde(rename = "CtryOfBirth")]
1011 pub ctry_of_birth: String,
1012}
1013
1014impl DateAndPlaceOfBirth1 {
1015 pub fn validate(&self) -> Result<(), ValidationError> {
1016 if let Some(ref val) = self.prvc_of_birth {
1017 if val.chars().count() < 1 {
1018 return Err(ValidationError::new(1001, "prvc_of_birth is shorter than the minimum length of 1".to_string()));
1019 }
1020 if val.chars().count() > 35 {
1021 return Err(ValidationError::new(1002, "prvc_of_birth exceeds the maximum length of 35".to_string()));
1022 }
1023 }
1024 if self.city_of_birth.chars().count() < 1 {
1025 return Err(ValidationError::new(1001, "city_of_birth is shorter than the minimum length of 1".to_string()));
1026 }
1027 if self.city_of_birth.chars().count() > 35 {
1028 return Err(ValidationError::new(1002, "city_of_birth exceeds the maximum length of 35".to_string()));
1029 }
1030 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1031 if !pattern.is_match(&self.ctry_of_birth) {
1032 return Err(ValidationError::new(1005, "ctry_of_birth does not match the required pattern".to_string()));
1033 }
1034 Ok(())
1035 }
1036}
1037
1038
1039#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1041pub struct DateAndType1 {
1042 #[serde(rename = "Tp")]
1043 pub tp: DateType2Choice,
1044 #[serde(rename = "Dt")]
1045 pub dt: String,
1046}
1047
1048impl DateAndType1 {
1049 pub fn validate(&self) -> Result<(), ValidationError> {
1050 self.tp.validate()?;
1051 Ok(())
1052 }
1053}
1054
1055
1056#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1058pub struct DatePeriod2 {
1059 #[serde(rename = "FrDt")]
1060 pub fr_dt: String,
1061 #[serde(rename = "ToDt")]
1062 pub to_dt: String,
1063}
1064
1065impl DatePeriod2 {
1066 pub fn validate(&self) -> Result<(), ValidationError> {
1067 Ok(())
1068 }
1069}
1070
1071
1072#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1074pub struct DateType2Choice {
1075 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1076 pub cd: Option<String>,
1077 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1078 pub prtry: Option<String>,
1079}
1080
1081impl DateType2Choice {
1082 pub fn validate(&self) -> Result<(), ValidationError> {
1083 if let Some(ref val) = self.cd {
1084 if val.chars().count() < 1 {
1085 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1086 }
1087 if val.chars().count() > 4 {
1088 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1089 }
1090 }
1091 if let Some(ref val) = self.prtry {
1092 if val.chars().count() < 1 {
1093 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1094 }
1095 if val.chars().count() > 35 {
1096 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1097 }
1098 }
1099 Ok(())
1100 }
1101}
1102
1103
1104#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1106pub struct DocumentAdjustment1 {
1107 #[serde(rename = "Amt")]
1108 pub amt: ActiveOrHistoricCurrencyAndAmount,
1109 #[serde(rename = "CdtDbtInd", skip_serializing_if = "Option::is_none")]
1110 pub cdt_dbt_ind: Option<CreditDebitCode>,
1111 #[serde(rename = "Rsn", skip_serializing_if = "Option::is_none")]
1112 pub rsn: Option<String>,
1113 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
1114 pub addtl_inf: Option<String>,
1115}
1116
1117impl DocumentAdjustment1 {
1118 pub fn validate(&self) -> Result<(), ValidationError> {
1119 self.amt.validate()?;
1120 if let Some(ref val) = self.cdt_dbt_ind { val.validate()? }
1121 if let Some(ref val) = self.rsn {
1122 if val.chars().count() < 1 {
1123 return Err(ValidationError::new(1001, "rsn is shorter than the minimum length of 1".to_string()));
1124 }
1125 if val.chars().count() > 4 {
1126 return Err(ValidationError::new(1002, "rsn exceeds the maximum length of 4".to_string()));
1127 }
1128 }
1129 if let Some(ref val) = self.addtl_inf {
1130 if val.chars().count() < 1 {
1131 return Err(ValidationError::new(1001, "addtl_inf is shorter than the minimum length of 1".to_string()));
1132 }
1133 if val.chars().count() > 140 {
1134 return Err(ValidationError::new(1002, "addtl_inf exceeds the maximum length of 140".to_string()));
1135 }
1136 }
1137 Ok(())
1138 }
1139}
1140
1141
1142#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1144pub struct DocumentAmount1 {
1145 #[serde(rename = "Tp")]
1146 pub tp: DocumentAmountType1Choice,
1147 #[serde(rename = "Amt")]
1148 pub amt: ActiveOrHistoricCurrencyAndAmount,
1149}
1150
1151impl DocumentAmount1 {
1152 pub fn validate(&self) -> Result<(), ValidationError> {
1153 self.tp.validate()?;
1154 self.amt.validate()?;
1155 Ok(())
1156 }
1157}
1158
1159
1160#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1162pub struct DocumentAmountType1Choice {
1163 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1164 pub cd: Option<String>,
1165 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1166 pub prtry: Option<String>,
1167}
1168
1169impl DocumentAmountType1Choice {
1170 pub fn validate(&self) -> Result<(), ValidationError> {
1171 if let Some(ref val) = self.cd {
1172 if val.chars().count() < 1 {
1173 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1174 }
1175 if val.chars().count() > 4 {
1176 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1177 }
1178 }
1179 if let Some(ref val) = self.prtry {
1180 if val.chars().count() < 1 {
1181 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1182 }
1183 if val.chars().count() > 35 {
1184 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1185 }
1186 }
1187 Ok(())
1188 }
1189}
1190
1191
1192#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1194pub struct DocumentLineIdentification1 {
1195 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1196 pub tp: Option<DocumentLineType1>,
1197 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
1198 pub nb: Option<String>,
1199 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
1200 pub rltd_dt: Option<String>,
1201}
1202
1203impl DocumentLineIdentification1 {
1204 pub fn validate(&self) -> Result<(), ValidationError> {
1205 if let Some(ref val) = self.tp { val.validate()? }
1206 if let Some(ref val) = self.nb {
1207 if val.chars().count() < 1 {
1208 return Err(ValidationError::new(1001, "nb is shorter than the minimum length of 1".to_string()));
1209 }
1210 if val.chars().count() > 35 {
1211 return Err(ValidationError::new(1002, "nb exceeds the maximum length of 35".to_string()));
1212 }
1213 }
1214 Ok(())
1215 }
1216}
1217
1218
1219#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1221pub struct DocumentLineInformation2 {
1222 #[serde(rename = "Id")]
1223 pub id: Vec<DocumentLineIdentification1>,
1224 #[serde(rename = "Desc", skip_serializing_if = "Option::is_none")]
1225 pub desc: Option<String>,
1226 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
1227 pub amt: Option<RemittanceAmount4>,
1228}
1229
1230impl DocumentLineInformation2 {
1231 pub fn validate(&self) -> Result<(), ValidationError> {
1232 for item in &self.id { item.validate()? }
1233 if let Some(ref val) = self.desc {
1234 if val.chars().count() < 1 {
1235 return Err(ValidationError::new(1001, "desc is shorter than the minimum length of 1".to_string()));
1236 }
1237 if val.chars().count() > 2048 {
1238 return Err(ValidationError::new(1002, "desc exceeds the maximum length of 2048".to_string()));
1239 }
1240 }
1241 if let Some(ref val) = self.amt { val.validate()? }
1242 Ok(())
1243 }
1244}
1245
1246
1247#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1249pub struct DocumentLineType1 {
1250 #[serde(rename = "CdOrPrtry")]
1251 pub cd_or_prtry: DocumentLineType1Choice,
1252 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1253 pub issr: Option<String>,
1254}
1255
1256impl DocumentLineType1 {
1257 pub fn validate(&self) -> Result<(), ValidationError> {
1258 self.cd_or_prtry.validate()?;
1259 if let Some(ref val) = self.issr {
1260 if val.chars().count() < 1 {
1261 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1262 }
1263 if val.chars().count() > 35 {
1264 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1265 }
1266 }
1267 Ok(())
1268 }
1269}
1270
1271
1272#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1274pub struct DocumentLineType1Choice {
1275 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1276 pub cd: Option<String>,
1277 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1278 pub prtry: Option<String>,
1279}
1280
1281impl DocumentLineType1Choice {
1282 pub fn validate(&self) -> Result<(), ValidationError> {
1283 if let Some(ref val) = self.cd {
1284 if val.chars().count() < 1 {
1285 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1286 }
1287 if val.chars().count() > 4 {
1288 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1289 }
1290 }
1291 if let Some(ref val) = self.prtry {
1292 if val.chars().count() < 1 {
1293 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1294 }
1295 if val.chars().count() > 35 {
1296 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1297 }
1298 }
1299 Ok(())
1300 }
1301}
1302
1303
1304#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1306pub struct DocumentType1 {
1307 #[serde(rename = "CdOrPrtry")]
1308 pub cd_or_prtry: DocumentType2Choice,
1309 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1310 pub issr: Option<String>,
1311}
1312
1313impl DocumentType1 {
1314 pub fn validate(&self) -> Result<(), ValidationError> {
1315 self.cd_or_prtry.validate()?;
1316 if let Some(ref val) = self.issr {
1317 if val.chars().count() < 1 {
1318 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1319 }
1320 if val.chars().count() > 35 {
1321 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1322 }
1323 }
1324 Ok(())
1325 }
1326}
1327
1328
1329#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1331pub struct DocumentType2Choice {
1332 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1333 pub cd: Option<String>,
1334 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1335 pub prtry: Option<String>,
1336}
1337
1338impl DocumentType2Choice {
1339 pub fn validate(&self) -> Result<(), ValidationError> {
1340 if let Some(ref val) = self.cd {
1341 if val.chars().count() < 1 {
1342 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1343 }
1344 if val.chars().count() > 4 {
1345 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1346 }
1347 }
1348 if let Some(ref val) = self.prtry {
1349 if val.chars().count() < 1 {
1350 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1351 }
1352 if val.chars().count() > 35 {
1353 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1354 }
1355 }
1356 Ok(())
1357 }
1358}
1359
1360
1361#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1363pub struct FIToFICustomerCreditTransferV13 {
1364 #[serde(rename = "GrpHdr")]
1365 pub grp_hdr: GroupHeader131,
1366 #[serde(rename = "CdtTrfTxInf")]
1367 pub cdt_trf_tx_inf: Vec<CreditTransferTransaction70>,
1368 #[serde(rename = "SplmtryData", skip_serializing_if = "Option::is_none")]
1369 pub splmtry_data: Option<Vec<SupplementaryData1>>,
1370}
1371
1372impl FIToFICustomerCreditTransferV13 {
1373 pub fn validate(&self) -> Result<(), ValidationError> {
1374 self.grp_hdr.validate()?;
1375 for item in &self.cdt_trf_tx_inf { item.validate()? }
1376 if let Some(ref vec) = self.splmtry_data { for item in vec { item.validate()? } }
1377 Ok(())
1378 }
1379}
1380
1381
1382#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1384pub struct FinancialIdentificationSchemeName1Choice {
1385 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1386 pub cd: Option<String>,
1387 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1388 pub prtry: Option<String>,
1389}
1390
1391impl FinancialIdentificationSchemeName1Choice {
1392 pub fn validate(&self) -> Result<(), ValidationError> {
1393 if let Some(ref val) = self.cd {
1394 if val.chars().count() < 1 {
1395 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1396 }
1397 if val.chars().count() > 4 {
1398 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1399 }
1400 }
1401 if let Some(ref val) = self.prtry {
1402 if val.chars().count() < 1 {
1403 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1404 }
1405 if val.chars().count() > 35 {
1406 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1407 }
1408 }
1409 Ok(())
1410 }
1411}
1412
1413
1414#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1416pub struct FinancialInstitutionIdentification23 {
1417 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
1418 pub bicfi: Option<String>,
1419 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
1420 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification2>,
1421 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
1422 pub lei: Option<String>,
1423 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
1424 pub nm: Option<String>,
1425 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
1426 pub pstl_adr: Option<PostalAddress27>,
1427 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1428 pub othr: Option<GenericFinancialIdentification1>,
1429}
1430
1431impl FinancialInstitutionIdentification23 {
1432 pub fn validate(&self) -> Result<(), ValidationError> {
1433 if let Some(ref val) = self.bicfi {
1434 let pattern = Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
1435 if !pattern.is_match(val) {
1436 return Err(ValidationError::new(1005, "bicfi does not match the required pattern".to_string()));
1437 }
1438 }
1439 if let Some(ref val) = self.clr_sys_mmb_id { val.validate()? }
1440 if let Some(ref val) = self.lei {
1441 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
1442 if !pattern.is_match(val) {
1443 return Err(ValidationError::new(1005, "lei does not match the required pattern".to_string()));
1444 }
1445 }
1446 if let Some(ref val) = self.nm {
1447 if val.chars().count() < 1 {
1448 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
1449 }
1450 if val.chars().count() > 140 {
1451 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
1452 }
1453 }
1454 if let Some(ref val) = self.pstl_adr { val.validate()? }
1455 if let Some(ref val) = self.othr { val.validate()? }
1456 Ok(())
1457 }
1458}
1459
1460
1461#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1463pub struct Frequency36Choice {
1464 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1465 pub tp: Option<Frequency6Code>,
1466 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
1467 pub prd: Option<FrequencyPeriod1>,
1468 #[serde(rename = "PtInTm", skip_serializing_if = "Option::is_none")]
1469 pub pt_in_tm: Option<FrequencyAndMoment1>,
1470}
1471
1472impl Frequency36Choice {
1473 pub fn validate(&self) -> Result<(), ValidationError> {
1474 if let Some(ref val) = self.tp { val.validate()? }
1475 if let Some(ref val) = self.prd { val.validate()? }
1476 if let Some(ref val) = self.pt_in_tm { val.validate()? }
1477 Ok(())
1478 }
1479}
1480
1481
1482#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1484pub enum Frequency6Code {
1485 #[default]
1486 #[serde(rename = "YEAR")]
1487 CodeYEAR,
1488 #[serde(rename = "MNTH")]
1489 CodeMNTH,
1490 #[serde(rename = "QURT")]
1491 CodeQURT,
1492 #[serde(rename = "MIAN")]
1493 CodeMIAN,
1494 #[serde(rename = "WEEK")]
1495 CodeWEEK,
1496 #[serde(rename = "DAIL")]
1497 CodeDAIL,
1498 #[serde(rename = "ADHO")]
1499 CodeADHO,
1500 #[serde(rename = "INDA")]
1501 CodeINDA,
1502 #[serde(rename = "FRTN")]
1503 CodeFRTN,
1504}
1505
1506impl Frequency6Code {
1507 pub fn validate(&self) -> Result<(), ValidationError> {
1508 Ok(())
1509 }
1510}
1511
1512
1513#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1515pub struct FrequencyAndMoment1 {
1516 #[serde(rename = "Tp")]
1517 pub tp: Frequency6Code,
1518 #[serde(rename = "PtInTm")]
1519 pub pt_in_tm: String,
1520}
1521
1522impl FrequencyAndMoment1 {
1523 pub fn validate(&self) -> Result<(), ValidationError> {
1524 self.tp.validate()?;
1525 let pattern = Regex::new("[0-9]{2}").unwrap();
1526 if !pattern.is_match(&self.pt_in_tm) {
1527 return Err(ValidationError::new(1005, "pt_in_tm does not match the required pattern".to_string()));
1528 }
1529 Ok(())
1530 }
1531}
1532
1533
1534#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1536pub struct FrequencyPeriod1 {
1537 #[serde(rename = "Tp")]
1538 pub tp: Frequency6Code,
1539 #[serde(rename = "CntPerPrd")]
1540 pub cnt_per_prd: f64,
1541}
1542
1543impl FrequencyPeriod1 {
1544 pub fn validate(&self) -> Result<(), ValidationError> {
1545 self.tp.validate()?;
1546 Ok(())
1547 }
1548}
1549
1550
1551#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1553pub struct Garnishment4 {
1554 #[serde(rename = "Tp")]
1555 pub tp: GarnishmentType1,
1556 #[serde(rename = "Grnshee", skip_serializing_if = "Option::is_none")]
1557 pub grnshee: Option<PartyIdentification272>,
1558 #[serde(rename = "GrnshmtAdmstr", skip_serializing_if = "Option::is_none")]
1559 pub grnshmt_admstr: Option<PartyIdentification272>,
1560 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
1561 pub ref_nb: Option<String>,
1562 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
1563 pub dt: Option<String>,
1564 #[serde(rename = "RmtdAmt", skip_serializing_if = "Option::is_none")]
1565 pub rmtd_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
1566 #[serde(rename = "FmlyMdclInsrncInd", skip_serializing_if = "Option::is_none")]
1567 pub fmly_mdcl_insrnc_ind: Option<bool>,
1568 #[serde(rename = "MplyeeTermntnInd", skip_serializing_if = "Option::is_none")]
1569 pub mplyee_termntn_ind: Option<bool>,
1570}
1571
1572impl Garnishment4 {
1573 pub fn validate(&self) -> Result<(), ValidationError> {
1574 self.tp.validate()?;
1575 if let Some(ref val) = self.grnshee { val.validate()? }
1576 if let Some(ref val) = self.grnshmt_admstr { val.validate()? }
1577 if let Some(ref val) = self.ref_nb {
1578 if val.chars().count() < 1 {
1579 return Err(ValidationError::new(1001, "ref_nb is shorter than the minimum length of 1".to_string()));
1580 }
1581 if val.chars().count() > 140 {
1582 return Err(ValidationError::new(1002, "ref_nb exceeds the maximum length of 140".to_string()));
1583 }
1584 }
1585 if let Some(ref val) = self.rmtd_amt { val.validate()? }
1586 Ok(())
1587 }
1588}
1589
1590
1591#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1593pub struct GarnishmentType1 {
1594 #[serde(rename = "CdOrPrtry")]
1595 pub cd_or_prtry: GarnishmentType1Choice,
1596 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1597 pub issr: Option<String>,
1598}
1599
1600impl GarnishmentType1 {
1601 pub fn validate(&self) -> Result<(), ValidationError> {
1602 self.cd_or_prtry.validate()?;
1603 if let Some(ref val) = self.issr {
1604 if val.chars().count() < 1 {
1605 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1606 }
1607 if val.chars().count() > 35 {
1608 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1609 }
1610 }
1611 Ok(())
1612 }
1613}
1614
1615
1616#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1618pub struct GarnishmentType1Choice {
1619 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1620 pub cd: Option<String>,
1621 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1622 pub prtry: Option<String>,
1623}
1624
1625impl GarnishmentType1Choice {
1626 pub fn validate(&self) -> Result<(), ValidationError> {
1627 if let Some(ref val) = self.cd {
1628 if val.chars().count() < 1 {
1629 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1630 }
1631 if val.chars().count() > 4 {
1632 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1633 }
1634 }
1635 if let Some(ref val) = self.prtry {
1636 if val.chars().count() < 1 {
1637 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1638 }
1639 if val.chars().count() > 35 {
1640 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1641 }
1642 }
1643 Ok(())
1644 }
1645}
1646
1647
1648#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1650pub struct GenericAccountIdentification1 {
1651 #[serde(rename = "Id")]
1652 pub id: String,
1653 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1654 pub schme_nm: Option<AccountSchemeName1Choice>,
1655 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1656 pub issr: Option<String>,
1657}
1658
1659impl GenericAccountIdentification1 {
1660 pub fn validate(&self) -> Result<(), ValidationError> {
1661 if self.id.chars().count() < 1 {
1662 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
1663 }
1664 if self.id.chars().count() > 34 {
1665 return Err(ValidationError::new(1002, "id exceeds the maximum length of 34".to_string()));
1666 }
1667 if let Some(ref val) = self.schme_nm { val.validate()? }
1668 if let Some(ref val) = self.issr {
1669 if val.chars().count() < 1 {
1670 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1671 }
1672 if val.chars().count() > 35 {
1673 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1674 }
1675 }
1676 Ok(())
1677 }
1678}
1679
1680
1681#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1683pub struct GenericFinancialIdentification1 {
1684 #[serde(rename = "Id")]
1685 pub id: String,
1686 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1687 pub schme_nm: Option<FinancialIdentificationSchemeName1Choice>,
1688 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1689 pub issr: Option<String>,
1690}
1691
1692impl GenericFinancialIdentification1 {
1693 pub fn validate(&self) -> Result<(), ValidationError> {
1694 if self.id.chars().count() < 1 {
1695 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
1696 }
1697 if self.id.chars().count() > 35 {
1698 return Err(ValidationError::new(1002, "id exceeds the maximum length of 35".to_string()));
1699 }
1700 if let Some(ref val) = self.schme_nm { val.validate()? }
1701 if let Some(ref val) = self.issr {
1702 if val.chars().count() < 1 {
1703 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1704 }
1705 if val.chars().count() > 35 {
1706 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1707 }
1708 }
1709 Ok(())
1710 }
1711}
1712
1713
1714#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1716pub struct GenericIdentification3 {
1717 #[serde(rename = "Id")]
1718 pub id: String,
1719 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1720 pub issr: Option<String>,
1721}
1722
1723impl GenericIdentification3 {
1724 pub fn validate(&self) -> Result<(), ValidationError> {
1725 if self.id.chars().count() < 1 {
1726 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
1727 }
1728 if self.id.chars().count() > 35 {
1729 return Err(ValidationError::new(1002, "id exceeds the maximum length of 35".to_string()));
1730 }
1731 if let Some(ref val) = self.issr {
1732 if val.chars().count() < 1 {
1733 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1734 }
1735 if val.chars().count() > 35 {
1736 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1737 }
1738 }
1739 Ok(())
1740 }
1741}
1742
1743
1744#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1746pub struct GenericIdentification30 {
1747 #[serde(rename = "Id")]
1748 pub id: String,
1749 #[serde(rename = "Issr")]
1750 pub issr: String,
1751 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1752 pub schme_nm: Option<String>,
1753}
1754
1755impl GenericIdentification30 {
1756 pub fn validate(&self) -> Result<(), ValidationError> {
1757 let pattern = Regex::new("[a-zA-Z0-9]{4}").unwrap();
1758 if !pattern.is_match(&self.id) {
1759 return Err(ValidationError::new(1005, "id does not match the required pattern".to_string()));
1760 }
1761 if self.issr.chars().count() < 1 {
1762 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1763 }
1764 if self.issr.chars().count() > 35 {
1765 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1766 }
1767 if let Some(ref val) = self.schme_nm {
1768 if val.chars().count() < 1 {
1769 return Err(ValidationError::new(1001, "schme_nm is shorter than the minimum length of 1".to_string()));
1770 }
1771 if val.chars().count() > 35 {
1772 return Err(ValidationError::new(1002, "schme_nm exceeds the maximum length of 35".to_string()));
1773 }
1774 }
1775 Ok(())
1776 }
1777}
1778
1779
1780#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1782pub struct GenericOrganisationIdentification3 {
1783 #[serde(rename = "Id")]
1784 pub id: String,
1785 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1786 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice>,
1787 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1788 pub issr: Option<String>,
1789}
1790
1791impl GenericOrganisationIdentification3 {
1792 pub fn validate(&self) -> Result<(), ValidationError> {
1793 if self.id.chars().count() < 1 {
1794 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
1795 }
1796 if self.id.chars().count() > 256 {
1797 return Err(ValidationError::new(1002, "id exceeds the maximum length of 256".to_string()));
1798 }
1799 if let Some(ref val) = self.schme_nm { val.validate()? }
1800 if let Some(ref val) = self.issr {
1801 if val.chars().count() < 1 {
1802 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1803 }
1804 if val.chars().count() > 35 {
1805 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1806 }
1807 }
1808 Ok(())
1809 }
1810}
1811
1812
1813#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1815pub struct GenericPersonIdentification2 {
1816 #[serde(rename = "Id")]
1817 pub id: String,
1818 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
1819 pub schme_nm: Option<PersonIdentificationSchemeName1Choice>,
1820 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
1821 pub issr: Option<String>,
1822}
1823
1824impl GenericPersonIdentification2 {
1825 pub fn validate(&self) -> Result<(), ValidationError> {
1826 if self.id.chars().count() < 1 {
1827 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
1828 }
1829 if self.id.chars().count() > 256 {
1830 return Err(ValidationError::new(1002, "id exceeds the maximum length of 256".to_string()));
1831 }
1832 if let Some(ref val) = self.schme_nm { val.validate()? }
1833 if let Some(ref val) = self.issr {
1834 if val.chars().count() < 1 {
1835 return Err(ValidationError::new(1001, "issr is shorter than the minimum length of 1".to_string()));
1836 }
1837 if val.chars().count() > 35 {
1838 return Err(ValidationError::new(1002, "issr exceeds the maximum length of 35".to_string()));
1839 }
1840 }
1841 Ok(())
1842 }
1843}
1844
1845
1846#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1848pub struct GroupHeader131 {
1849 #[serde(rename = "MsgId")]
1850 pub msg_id: String,
1851 #[serde(rename = "CreDtTm")]
1852 pub cre_dt_tm: String,
1853 #[serde(rename = "XpryDtTm", skip_serializing_if = "Option::is_none")]
1854 pub xpry_dt_tm: Option<String>,
1855 #[serde(rename = "BtchBookg", skip_serializing_if = "Option::is_none")]
1856 pub btch_bookg: Option<bool>,
1857 #[serde(rename = "NbOfTxs")]
1858 pub nb_of_txs: String,
1859 #[serde(rename = "CtrlSum", skip_serializing_if = "Option::is_none")]
1860 pub ctrl_sum: Option<f64>,
1861 #[serde(rename = "TtlIntrBkSttlmAmt", skip_serializing_if = "Option::is_none")]
1862 pub ttl_intr_bk_sttlm_amt: Option<ActiveCurrencyAndAmount>,
1863 #[serde(rename = "IntrBkSttlmDt", skip_serializing_if = "Option::is_none")]
1864 pub intr_bk_sttlm_dt: Option<String>,
1865 #[serde(rename = "SttlmInf")]
1866 pub sttlm_inf: SettlementInstruction15,
1867 #[serde(rename = "PmtTpInf", skip_serializing_if = "Option::is_none")]
1868 pub pmt_tp_inf: Option<PaymentTypeInformation28>,
1869 #[serde(rename = "InstgAgt", skip_serializing_if = "Option::is_none")]
1870 pub instg_agt: Option<BranchAndFinancialInstitutionIdentification8>,
1871 #[serde(rename = "InstdAgt", skip_serializing_if = "Option::is_none")]
1872 pub instd_agt: Option<BranchAndFinancialInstitutionIdentification8>,
1873}
1874
1875impl GroupHeader131 {
1876 pub fn validate(&self) -> Result<(), ValidationError> {
1877 if self.msg_id.chars().count() < 1 {
1878 return Err(ValidationError::new(1001, "msg_id is shorter than the minimum length of 1".to_string()));
1879 }
1880 if self.msg_id.chars().count() > 35 {
1881 return Err(ValidationError::new(1002, "msg_id exceeds the maximum length of 35".to_string()));
1882 }
1883 let pattern = Regex::new("[0-9]{1,15}").unwrap();
1884 if !pattern.is_match(&self.nb_of_txs) {
1885 return Err(ValidationError::new(1005, "nb_of_txs does not match the required pattern".to_string()));
1886 }
1887 if let Some(ref val) = self.ttl_intr_bk_sttlm_amt { val.validate()? }
1888 self.sttlm_inf.validate()?;
1889 if let Some(ref val) = self.pmt_tp_inf { val.validate()? }
1890 if let Some(ref val) = self.instg_agt { val.validate()? }
1891 if let Some(ref val) = self.instd_agt { val.validate()? }
1892 Ok(())
1893 }
1894}
1895
1896
1897#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1899pub enum Instruction4Code {
1900 #[default]
1901 #[serde(rename = "PHOA")]
1902 CodePHOA,
1903 #[serde(rename = "TELA")]
1904 CodeTELA,
1905}
1906
1907impl Instruction4Code {
1908 pub fn validate(&self) -> Result<(), ValidationError> {
1909 Ok(())
1910 }
1911}
1912
1913
1914#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1916pub struct InstructionForCreditorAgent3 {
1917 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1918 pub cd: Option<String>,
1919 #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
1920 pub instr_inf: Option<String>,
1921}
1922
1923impl InstructionForCreditorAgent3 {
1924 pub fn validate(&self) -> Result<(), ValidationError> {
1925 if let Some(ref val) = self.cd {
1926 if val.chars().count() < 1 {
1927 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1928 }
1929 if val.chars().count() > 4 {
1930 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
1931 }
1932 }
1933 if let Some(ref val) = self.instr_inf {
1934 if val.chars().count() < 1 {
1935 return Err(ValidationError::new(1001, "instr_inf is shorter than the minimum length of 1".to_string()));
1936 }
1937 if val.chars().count() > 140 {
1938 return Err(ValidationError::new(1002, "instr_inf exceeds the maximum length of 140".to_string()));
1939 }
1940 }
1941 Ok(())
1942 }
1943}
1944
1945
1946#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1948pub struct InstructionForNextAgent1 {
1949 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1950 pub cd: Option<Instruction4Code>,
1951 #[serde(rename = "InstrInf", skip_serializing_if = "Option::is_none")]
1952 pub instr_inf: Option<String>,
1953}
1954
1955impl InstructionForNextAgent1 {
1956 pub fn validate(&self) -> Result<(), ValidationError> {
1957 if let Some(ref val) = self.cd { val.validate()? }
1958 if let Some(ref val) = self.instr_inf {
1959 if val.chars().count() < 1 {
1960 return Err(ValidationError::new(1001, "instr_inf is shorter than the minimum length of 1".to_string()));
1961 }
1962 if val.chars().count() > 140 {
1963 return Err(ValidationError::new(1002, "instr_inf exceeds the maximum length of 140".to_string()));
1964 }
1965 }
1966 Ok(())
1967 }
1968}
1969
1970
1971#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1973pub struct LocalInstrument2Choice {
1974 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1975 pub cd: Option<String>,
1976 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1977 pub prtry: Option<String>,
1978}
1979
1980impl LocalInstrument2Choice {
1981 pub fn validate(&self) -> Result<(), ValidationError> {
1982 if let Some(ref val) = self.cd {
1983 if val.chars().count() < 1 {
1984 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
1985 }
1986 if val.chars().count() > 35 {
1987 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 35".to_string()));
1988 }
1989 }
1990 if let Some(ref val) = self.prtry {
1991 if val.chars().count() < 1 {
1992 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
1993 }
1994 if val.chars().count() > 35 {
1995 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
1996 }
1997 }
1998 Ok(())
1999 }
2000}
2001
2002
2003#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2005pub struct MandateClassification1Choice {
2006 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2007 pub cd: Option<MandateClassification1Code>,
2008 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2009 pub prtry: Option<String>,
2010}
2011
2012impl MandateClassification1Choice {
2013 pub fn validate(&self) -> Result<(), ValidationError> {
2014 if let Some(ref val) = self.cd { val.validate()? }
2015 if let Some(ref val) = self.prtry {
2016 if val.chars().count() < 1 {
2017 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2018 }
2019 if val.chars().count() > 35 {
2020 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
2021 }
2022 }
2023 Ok(())
2024 }
2025}
2026
2027
2028#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2030pub enum MandateClassification1Code {
2031 #[default]
2032 #[serde(rename = "FIXE")]
2033 CodeFIXE,
2034 #[serde(rename = "USGB")]
2035 CodeUSGB,
2036 #[serde(rename = "VARI")]
2037 CodeVARI,
2038}
2039
2040impl MandateClassification1Code {
2041 pub fn validate(&self) -> Result<(), ValidationError> {
2042 Ok(())
2043 }
2044}
2045
2046
2047#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2049pub struct MandateSetupReason1Choice {
2050 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2051 pub cd: Option<String>,
2052 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2053 pub prtry: Option<String>,
2054}
2055
2056impl MandateSetupReason1Choice {
2057 pub fn validate(&self) -> Result<(), ValidationError> {
2058 if let Some(ref val) = self.cd {
2059 if val.chars().count() < 1 {
2060 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
2061 }
2062 if val.chars().count() > 4 {
2063 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
2064 }
2065 }
2066 if let Some(ref val) = self.prtry {
2067 if val.chars().count() < 1 {
2068 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2069 }
2070 if val.chars().count() > 70 {
2071 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 70".to_string()));
2072 }
2073 }
2074 Ok(())
2075 }
2076}
2077
2078
2079#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2081pub struct MandateTypeInformation2 {
2082 #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
2083 pub svc_lvl: Option<ServiceLevel8Choice>,
2084 #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2085 pub lcl_instrm: Option<LocalInstrument2Choice>,
2086 #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
2087 pub ctgy_purp: Option<CategoryPurpose1Choice>,
2088 #[serde(rename = "Clssfctn", skip_serializing_if = "Option::is_none")]
2089 pub clssfctn: Option<MandateClassification1Choice>,
2090}
2091
2092impl MandateTypeInformation2 {
2093 pub fn validate(&self) -> Result<(), ValidationError> {
2094 if let Some(ref val) = self.svc_lvl { val.validate()? }
2095 if let Some(ref val) = self.lcl_instrm { val.validate()? }
2096 if let Some(ref val) = self.ctgy_purp { val.validate()? }
2097 if let Some(ref val) = self.clssfctn { val.validate()? }
2098 Ok(())
2099 }
2100}
2101
2102
2103#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2105pub struct NameAndAddress18 {
2106 #[serde(rename = "Nm")]
2107 pub nm: String,
2108 #[serde(rename = "Adr")]
2109 pub adr: PostalAddress27,
2110}
2111
2112impl NameAndAddress18 {
2113 pub fn validate(&self) -> Result<(), ValidationError> {
2114 if self.nm.chars().count() < 1 {
2115 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
2116 }
2117 if self.nm.chars().count() > 140 {
2118 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
2119 }
2120 self.adr.validate()?;
2121 Ok(())
2122 }
2123}
2124
2125
2126#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2128pub enum NamePrefix2Code {
2129 #[default]
2130 #[serde(rename = "DOCT")]
2131 CodeDOCT,
2132 #[serde(rename = "MADM")]
2133 CodeMADM,
2134 #[serde(rename = "MISS")]
2135 CodeMISS,
2136 #[serde(rename = "MIST")]
2137 CodeMIST,
2138 #[serde(rename = "MIKS")]
2139 CodeMIKS,
2140}
2141
2142impl NamePrefix2Code {
2143 pub fn validate(&self) -> Result<(), ValidationError> {
2144 Ok(())
2145 }
2146}
2147
2148
2149#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2151pub struct OrganisationIdentification39 {
2152 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
2153 pub any_bic: Option<String>,
2154 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
2155 pub lei: Option<String>,
2156 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2157 pub othr: Option<Vec<GenericOrganisationIdentification3>>,
2158}
2159
2160impl OrganisationIdentification39 {
2161 pub fn validate(&self) -> Result<(), ValidationError> {
2162 if let Some(ref val) = self.any_bic {
2163 let pattern = Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
2164 if !pattern.is_match(val) {
2165 return Err(ValidationError::new(1005, "any_bic does not match the required pattern".to_string()));
2166 }
2167 }
2168 if let Some(ref val) = self.lei {
2169 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
2170 if !pattern.is_match(val) {
2171 return Err(ValidationError::new(1005, "lei does not match the required pattern".to_string()));
2172 }
2173 }
2174 if let Some(ref vec) = self.othr { for item in vec { item.validate()? } }
2175 Ok(())
2176 }
2177}
2178
2179
2180#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2182pub struct OrganisationIdentificationSchemeName1Choice {
2183 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2184 pub cd: Option<String>,
2185 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2186 pub prtry: Option<String>,
2187}
2188
2189impl OrganisationIdentificationSchemeName1Choice {
2190 pub fn validate(&self) -> Result<(), ValidationError> {
2191 if let Some(ref val) = self.cd {
2192 if val.chars().count() < 1 {
2193 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
2194 }
2195 if val.chars().count() > 4 {
2196 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
2197 }
2198 }
2199 if let Some(ref val) = self.prtry {
2200 if val.chars().count() < 1 {
2201 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2202 }
2203 if val.chars().count() > 35 {
2204 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
2205 }
2206 }
2207 Ok(())
2208 }
2209}
2210
2211
2212#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2214pub struct OtherContact1 {
2215 #[serde(rename = "ChanlTp")]
2216 pub chanl_tp: String,
2217 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2218 pub id: Option<String>,
2219}
2220
2221impl OtherContact1 {
2222 pub fn validate(&self) -> Result<(), ValidationError> {
2223 if self.chanl_tp.chars().count() < 1 {
2224 return Err(ValidationError::new(1001, "chanl_tp is shorter than the minimum length of 1".to_string()));
2225 }
2226 if self.chanl_tp.chars().count() > 4 {
2227 return Err(ValidationError::new(1002, "chanl_tp exceeds the maximum length of 4".to_string()));
2228 }
2229 if let Some(ref val) = self.id {
2230 if val.chars().count() < 1 {
2231 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
2232 }
2233 if val.chars().count() > 128 {
2234 return Err(ValidationError::new(1002, "id exceeds the maximum length of 128".to_string()));
2235 }
2236 }
2237 Ok(())
2238 }
2239}
2240
2241
2242#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2244pub struct Party52Choice {
2245 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
2246 pub org_id: Option<OrganisationIdentification39>,
2247 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
2248 pub prvt_id: Option<PersonIdentification18>,
2249}
2250
2251impl Party52Choice {
2252 pub fn validate(&self) -> Result<(), ValidationError> {
2253 if let Some(ref val) = self.org_id { val.validate()? }
2254 if let Some(ref val) = self.prvt_id { val.validate()? }
2255 Ok(())
2256 }
2257}
2258
2259
2260#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2262pub struct PartyIdentification272 {
2263 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2264 pub nm: Option<String>,
2265 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2266 pub pstl_adr: Option<PostalAddress27>,
2267 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
2268 pub id: Option<Party52Choice>,
2269 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
2270 pub ctry_of_res: Option<String>,
2271 #[serde(rename = "CtctDtls", skip_serializing_if = "Option::is_none")]
2272 pub ctct_dtls: Option<Contact13>,
2273}
2274
2275impl PartyIdentification272 {
2276 pub fn validate(&self) -> Result<(), ValidationError> {
2277 if let Some(ref val) = self.nm {
2278 if val.chars().count() < 1 {
2279 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
2280 }
2281 if val.chars().count() > 140 {
2282 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
2283 }
2284 }
2285 if let Some(ref val) = self.pstl_adr { val.validate()? }
2286 if let Some(ref val) = self.id { val.validate()? }
2287 if let Some(ref val) = self.ctry_of_res {
2288 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2289 if !pattern.is_match(val) {
2290 return Err(ValidationError::new(1005, "ctry_of_res does not match the required pattern".to_string()));
2291 }
2292 }
2293 if let Some(ref val) = self.ctct_dtls { val.validate()? }
2294 Ok(())
2295 }
2296}
2297
2298
2299#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2301pub struct PaymentIdentification13 {
2302 #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
2303 pub instr_id: Option<String>,
2304 #[serde(rename = "EndToEndId")]
2305 pub end_to_end_id: String,
2306 #[serde(rename = "TxId", skip_serializing_if = "Option::is_none")]
2307 pub tx_id: Option<String>,
2308 #[serde(rename = "UETR", skip_serializing_if = "Option::is_none")]
2309 pub uetr: Option<String>,
2310 #[serde(rename = "ClrSysRef", skip_serializing_if = "Option::is_none")]
2311 pub clr_sys_ref: Option<String>,
2312}
2313
2314impl PaymentIdentification13 {
2315 pub fn validate(&self) -> Result<(), ValidationError> {
2316 if let Some(ref val) = self.instr_id {
2317 if val.chars().count() < 1 {
2318 return Err(ValidationError::new(1001, "instr_id is shorter than the minimum length of 1".to_string()));
2319 }
2320 if val.chars().count() > 35 {
2321 return Err(ValidationError::new(1002, "instr_id exceeds the maximum length of 35".to_string()));
2322 }
2323 }
2324 if self.end_to_end_id.chars().count() < 1 {
2325 return Err(ValidationError::new(1001, "end_to_end_id is shorter than the minimum length of 1".to_string()));
2326 }
2327 if self.end_to_end_id.chars().count() > 35 {
2328 return Err(ValidationError::new(1002, "end_to_end_id exceeds the maximum length of 35".to_string()));
2329 }
2330 if let Some(ref val) = self.tx_id {
2331 if val.chars().count() < 1 {
2332 return Err(ValidationError::new(1001, "tx_id is shorter than the minimum length of 1".to_string()));
2333 }
2334 if val.chars().count() > 35 {
2335 return Err(ValidationError::new(1002, "tx_id exceeds the maximum length of 35".to_string()));
2336 }
2337 }
2338 if let Some(ref val) = self.uetr {
2339 let pattern = Regex::new("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}").unwrap();
2340 if !pattern.is_match(val) {
2341 return Err(ValidationError::new(1005, "uetr does not match the required pattern".to_string()));
2342 }
2343 }
2344 if let Some(ref val) = self.clr_sys_ref {
2345 if val.chars().count() < 1 {
2346 return Err(ValidationError::new(1001, "clr_sys_ref is shorter than the minimum length of 1".to_string()));
2347 }
2348 if val.chars().count() > 35 {
2349 return Err(ValidationError::new(1002, "clr_sys_ref exceeds the maximum length of 35".to_string()));
2350 }
2351 }
2352 Ok(())
2353 }
2354}
2355
2356
2357#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2359pub struct PaymentTypeInformation28 {
2360 #[serde(rename = "InstrPrty", skip_serializing_if = "Option::is_none")]
2361 pub instr_prty: Option<Priority2Code>,
2362 #[serde(rename = "ClrChanl", skip_serializing_if = "Option::is_none")]
2363 pub clr_chanl: Option<ClearingChannel2Code>,
2364 #[serde(rename = "SvcLvl", skip_serializing_if = "Option::is_none")]
2365 pub svc_lvl: Option<Vec<ServiceLevel8Choice>>,
2366 #[serde(rename = "LclInstrm", skip_serializing_if = "Option::is_none")]
2367 pub lcl_instrm: Option<LocalInstrument2Choice>,
2368 #[serde(rename = "CtgyPurp", skip_serializing_if = "Option::is_none")]
2369 pub ctgy_purp: Option<CategoryPurpose1Choice>,
2370}
2371
2372impl PaymentTypeInformation28 {
2373 pub fn validate(&self) -> Result<(), ValidationError> {
2374 if let Some(ref val) = self.instr_prty { val.validate()? }
2375 if let Some(ref val) = self.clr_chanl { val.validate()? }
2376 if let Some(ref vec) = self.svc_lvl { for item in vec { item.validate()? } }
2377 if let Some(ref val) = self.lcl_instrm { val.validate()? }
2378 if let Some(ref val) = self.ctgy_purp { val.validate()? }
2379 Ok(())
2380 }
2381}
2382
2383
2384#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2386pub struct PersonIdentification18 {
2387 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
2388 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth1>,
2389 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
2390 pub othr: Option<Vec<GenericPersonIdentification2>>,
2391}
2392
2393impl PersonIdentification18 {
2394 pub fn validate(&self) -> Result<(), ValidationError> {
2395 if let Some(ref val) = self.dt_and_plc_of_birth { val.validate()? }
2396 if let Some(ref vec) = self.othr { for item in vec { item.validate()? } }
2397 Ok(())
2398 }
2399}
2400
2401
2402#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2404pub struct PersonIdentificationSchemeName1Choice {
2405 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2406 pub cd: Option<String>,
2407 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2408 pub prtry: Option<String>,
2409}
2410
2411impl PersonIdentificationSchemeName1Choice {
2412 pub fn validate(&self) -> Result<(), ValidationError> {
2413 if let Some(ref val) = self.cd {
2414 if val.chars().count() < 1 {
2415 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
2416 }
2417 if val.chars().count() > 4 {
2418 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
2419 }
2420 }
2421 if let Some(ref val) = self.prtry {
2422 if val.chars().count() < 1 {
2423 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2424 }
2425 if val.chars().count() > 35 {
2426 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
2427 }
2428 }
2429 Ok(())
2430 }
2431}
2432
2433
2434#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2436pub struct PostalAddress27 {
2437 #[serde(rename = "AdrTp", skip_serializing_if = "Option::is_none")]
2438 pub adr_tp: Option<AddressType3Choice>,
2439 #[serde(rename = "CareOf", skip_serializing_if = "Option::is_none")]
2440 pub care_of: Option<String>,
2441 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
2442 pub dept: Option<String>,
2443 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
2444 pub sub_dept: Option<String>,
2445 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
2446 pub strt_nm: Option<String>,
2447 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
2448 pub bldg_nb: Option<String>,
2449 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
2450 pub bldg_nm: Option<String>,
2451 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
2452 pub flr: Option<String>,
2453 #[serde(rename = "UnitNb", skip_serializing_if = "Option::is_none")]
2454 pub unit_nb: Option<String>,
2455 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
2456 pub pst_bx: Option<String>,
2457 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
2458 pub room: Option<String>,
2459 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
2460 pub pst_cd: Option<String>,
2461 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
2462 pub twn_nm: Option<String>,
2463 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
2464 pub twn_lctn_nm: Option<String>,
2465 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
2466 pub dstrct_nm: Option<String>,
2467 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
2468 pub ctry_sub_dvsn: Option<String>,
2469 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
2470 pub ctry: Option<String>,
2471 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
2472 pub adr_line: Option<Vec<String>>,
2473}
2474
2475impl PostalAddress27 {
2476 pub fn validate(&self) -> Result<(), ValidationError> {
2477 if let Some(ref val) = self.adr_tp { val.validate()? }
2478 if let Some(ref val) = self.care_of {
2479 if val.chars().count() < 1 {
2480 return Err(ValidationError::new(1001, "care_of is shorter than the minimum length of 1".to_string()));
2481 }
2482 if val.chars().count() > 140 {
2483 return Err(ValidationError::new(1002, "care_of exceeds the maximum length of 140".to_string()));
2484 }
2485 }
2486 if let Some(ref val) = self.dept {
2487 if val.chars().count() < 1 {
2488 return Err(ValidationError::new(1001, "dept is shorter than the minimum length of 1".to_string()));
2489 }
2490 if val.chars().count() > 70 {
2491 return Err(ValidationError::new(1002, "dept exceeds the maximum length of 70".to_string()));
2492 }
2493 }
2494 if let Some(ref val) = self.sub_dept {
2495 if val.chars().count() < 1 {
2496 return Err(ValidationError::new(1001, "sub_dept is shorter than the minimum length of 1".to_string()));
2497 }
2498 if val.chars().count() > 70 {
2499 return Err(ValidationError::new(1002, "sub_dept exceeds the maximum length of 70".to_string()));
2500 }
2501 }
2502 if let Some(ref val) = self.strt_nm {
2503 if val.chars().count() < 1 {
2504 return Err(ValidationError::new(1001, "strt_nm is shorter than the minimum length of 1".to_string()));
2505 }
2506 if val.chars().count() > 140 {
2507 return Err(ValidationError::new(1002, "strt_nm exceeds the maximum length of 140".to_string()));
2508 }
2509 }
2510 if let Some(ref val) = self.bldg_nb {
2511 if val.chars().count() < 1 {
2512 return Err(ValidationError::new(1001, "bldg_nb is shorter than the minimum length of 1".to_string()));
2513 }
2514 if val.chars().count() > 16 {
2515 return Err(ValidationError::new(1002, "bldg_nb exceeds the maximum length of 16".to_string()));
2516 }
2517 }
2518 if let Some(ref val) = self.bldg_nm {
2519 if val.chars().count() < 1 {
2520 return Err(ValidationError::new(1001, "bldg_nm is shorter than the minimum length of 1".to_string()));
2521 }
2522 if val.chars().count() > 140 {
2523 return Err(ValidationError::new(1002, "bldg_nm exceeds the maximum length of 140".to_string()));
2524 }
2525 }
2526 if let Some(ref val) = self.flr {
2527 if val.chars().count() < 1 {
2528 return Err(ValidationError::new(1001, "flr is shorter than the minimum length of 1".to_string()));
2529 }
2530 if val.chars().count() > 70 {
2531 return Err(ValidationError::new(1002, "flr exceeds the maximum length of 70".to_string()));
2532 }
2533 }
2534 if let Some(ref val) = self.unit_nb {
2535 if val.chars().count() < 1 {
2536 return Err(ValidationError::new(1001, "unit_nb is shorter than the minimum length of 1".to_string()));
2537 }
2538 if val.chars().count() > 16 {
2539 return Err(ValidationError::new(1002, "unit_nb exceeds the maximum length of 16".to_string()));
2540 }
2541 }
2542 if let Some(ref val) = self.pst_bx {
2543 if val.chars().count() < 1 {
2544 return Err(ValidationError::new(1001, "pst_bx is shorter than the minimum length of 1".to_string()));
2545 }
2546 if val.chars().count() > 16 {
2547 return Err(ValidationError::new(1002, "pst_bx exceeds the maximum length of 16".to_string()));
2548 }
2549 }
2550 if let Some(ref val) = self.room {
2551 if val.chars().count() < 1 {
2552 return Err(ValidationError::new(1001, "room is shorter than the minimum length of 1".to_string()));
2553 }
2554 if val.chars().count() > 70 {
2555 return Err(ValidationError::new(1002, "room exceeds the maximum length of 70".to_string()));
2556 }
2557 }
2558 if let Some(ref val) = self.pst_cd {
2559 if val.chars().count() < 1 {
2560 return Err(ValidationError::new(1001, "pst_cd is shorter than the minimum length of 1".to_string()));
2561 }
2562 if val.chars().count() > 16 {
2563 return Err(ValidationError::new(1002, "pst_cd exceeds the maximum length of 16".to_string()));
2564 }
2565 }
2566 if let Some(ref val) = self.twn_nm {
2567 if val.chars().count() < 1 {
2568 return Err(ValidationError::new(1001, "twn_nm is shorter than the minimum length of 1".to_string()));
2569 }
2570 if val.chars().count() > 140 {
2571 return Err(ValidationError::new(1002, "twn_nm exceeds the maximum length of 140".to_string()));
2572 }
2573 }
2574 if let Some(ref val) = self.twn_lctn_nm {
2575 if val.chars().count() < 1 {
2576 return Err(ValidationError::new(1001, "twn_lctn_nm is shorter than the minimum length of 1".to_string()));
2577 }
2578 if val.chars().count() > 140 {
2579 return Err(ValidationError::new(1002, "twn_lctn_nm exceeds the maximum length of 140".to_string()));
2580 }
2581 }
2582 if let Some(ref val) = self.dstrct_nm {
2583 if val.chars().count() < 1 {
2584 return Err(ValidationError::new(1001, "dstrct_nm is shorter than the minimum length of 1".to_string()));
2585 }
2586 if val.chars().count() > 140 {
2587 return Err(ValidationError::new(1002, "dstrct_nm exceeds the maximum length of 140".to_string()));
2588 }
2589 }
2590 if let Some(ref val) = self.ctry_sub_dvsn {
2591 if val.chars().count() < 1 {
2592 return Err(ValidationError::new(1001, "ctry_sub_dvsn is shorter than the minimum length of 1".to_string()));
2593 }
2594 if val.chars().count() > 35 {
2595 return Err(ValidationError::new(1002, "ctry_sub_dvsn exceeds the maximum length of 35".to_string()));
2596 }
2597 }
2598 if let Some(ref val) = self.ctry {
2599 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2600 if !pattern.is_match(val) {
2601 return Err(ValidationError::new(1005, "ctry does not match the required pattern".to_string()));
2602 }
2603 }
2604 if let Some(ref vec) = self.adr_line {
2605 for item in vec {
2606 if item.chars().count() < 1 {
2607 return Err(ValidationError::new(1001, "adr_line is shorter than the minimum length of 1".to_string()));
2608 }
2609 if item.chars().count() > 70 {
2610 return Err(ValidationError::new(1002, "adr_line exceeds the maximum length of 70".to_string()));
2611 }
2612 }
2613 }
2614 Ok(())
2615 }
2616}
2617
2618
2619#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2621pub enum PreferredContactMethod2Code {
2622 #[default]
2623 #[serde(rename = "MAIL")]
2624 CodeMAIL,
2625 #[serde(rename = "FAXX")]
2626 CodeFAXX,
2627 #[serde(rename = "LETT")]
2628 CodeLETT,
2629 #[serde(rename = "CELL")]
2630 CodeCELL,
2631 #[serde(rename = "ONLI")]
2632 CodeONLI,
2633 #[serde(rename = "PHON")]
2634 CodePHON,
2635}
2636
2637impl PreferredContactMethod2Code {
2638 pub fn validate(&self) -> Result<(), ValidationError> {
2639 Ok(())
2640 }
2641}
2642
2643
2644#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2646pub enum Priority2Code {
2647 #[default]
2648 #[serde(rename = "HIGH")]
2649 CodeHIGH,
2650 #[serde(rename = "NORM")]
2651 CodeNORM,
2652}
2653
2654impl Priority2Code {
2655 pub fn validate(&self) -> Result<(), ValidationError> {
2656 Ok(())
2657 }
2658}
2659
2660
2661#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2663pub enum Priority3Code {
2664 #[default]
2665 #[serde(rename = "URGT")]
2666 CodeURGT,
2667 #[serde(rename = "HIGH")]
2668 CodeHIGH,
2669 #[serde(rename = "NORM")]
2670 CodeNORM,
2671}
2672
2673impl Priority3Code {
2674 pub fn validate(&self) -> Result<(), ValidationError> {
2675 Ok(())
2676 }
2677}
2678
2679
2680#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2682pub struct ProxyAccountIdentification1 {
2683 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2684 pub tp: Option<ProxyAccountType1Choice>,
2685 #[serde(rename = "Id")]
2686 pub id: String,
2687}
2688
2689impl ProxyAccountIdentification1 {
2690 pub fn validate(&self) -> Result<(), ValidationError> {
2691 if let Some(ref val) = self.tp { val.validate()? }
2692 if self.id.chars().count() < 1 {
2693 return Err(ValidationError::new(1001, "id is shorter than the minimum length of 1".to_string()));
2694 }
2695 if self.id.chars().count() > 2048 {
2696 return Err(ValidationError::new(1002, "id exceeds the maximum length of 2048".to_string()));
2697 }
2698 Ok(())
2699 }
2700}
2701
2702
2703#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2705pub struct ProxyAccountType1Choice {
2706 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2707 pub cd: Option<String>,
2708 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2709 pub prtry: Option<String>,
2710}
2711
2712impl ProxyAccountType1Choice {
2713 pub fn validate(&self) -> Result<(), ValidationError> {
2714 if let Some(ref val) = self.cd {
2715 if val.chars().count() < 1 {
2716 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
2717 }
2718 if val.chars().count() > 4 {
2719 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
2720 }
2721 }
2722 if let Some(ref val) = self.prtry {
2723 if val.chars().count() < 1 {
2724 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2725 }
2726 if val.chars().count() > 35 {
2727 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
2728 }
2729 }
2730 Ok(())
2731 }
2732}
2733
2734
2735#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2737pub struct Purpose2Choice {
2738 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2739 pub cd: Option<String>,
2740 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2741 pub prtry: Option<String>,
2742}
2743
2744impl Purpose2Choice {
2745 pub fn validate(&self) -> Result<(), ValidationError> {
2746 if let Some(ref val) = self.cd {
2747 if val.chars().count() < 1 {
2748 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
2749 }
2750 if val.chars().count() > 4 {
2751 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
2752 }
2753 }
2754 if let Some(ref val) = self.prtry {
2755 if val.chars().count() < 1 {
2756 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
2757 }
2758 if val.chars().count() > 35 {
2759 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
2760 }
2761 }
2762 Ok(())
2763 }
2764}
2765
2766
2767#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2769pub struct ReferredDocumentInformation8 {
2770 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
2771 pub tp: Option<DocumentType1>,
2772 #[serde(rename = "Nb", skip_serializing_if = "Option::is_none")]
2773 pub nb: Option<String>,
2774 #[serde(rename = "RltdDt", skip_serializing_if = "Option::is_none")]
2775 pub rltd_dt: Option<DateAndType1>,
2776 #[serde(rename = "LineDtls", skip_serializing_if = "Option::is_none")]
2777 pub line_dtls: Option<Vec<DocumentLineInformation2>>,
2778}
2779
2780impl ReferredDocumentInformation8 {
2781 pub fn validate(&self) -> Result<(), ValidationError> {
2782 if let Some(ref val) = self.tp { val.validate()? }
2783 if let Some(ref val) = self.nb {
2784 if val.chars().count() < 1 {
2785 return Err(ValidationError::new(1001, "nb is shorter than the minimum length of 1".to_string()));
2786 }
2787 if val.chars().count() > 35 {
2788 return Err(ValidationError::new(1002, "nb exceeds the maximum length of 35".to_string()));
2789 }
2790 }
2791 if let Some(ref val) = self.rltd_dt { val.validate()? }
2792 if let Some(ref vec) = self.line_dtls { for item in vec { item.validate()? } }
2793 Ok(())
2794 }
2795}
2796
2797
2798#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2800pub struct RegulatoryAuthority2 {
2801 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
2802 pub nm: Option<String>,
2803 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
2804 pub ctry: Option<String>,
2805}
2806
2807impl RegulatoryAuthority2 {
2808 pub fn validate(&self) -> Result<(), ValidationError> {
2809 if let Some(ref val) = self.nm {
2810 if val.chars().count() < 1 {
2811 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
2812 }
2813 if val.chars().count() > 140 {
2814 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
2815 }
2816 }
2817 if let Some(ref val) = self.ctry {
2818 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
2819 if !pattern.is_match(val) {
2820 return Err(ValidationError::new(1005, "ctry does not match the required pattern".to_string()));
2821 }
2822 }
2823 Ok(())
2824 }
2825}
2826
2827
2828#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2830pub struct RegulatoryReporting3 {
2831 #[serde(rename = "DbtCdtRptgInd", skip_serializing_if = "Option::is_none")]
2832 pub dbt_cdt_rptg_ind: Option<RegulatoryReportingType1Code>,
2833 #[serde(rename = "Authrty", skip_serializing_if = "Option::is_none")]
2834 pub authrty: Option<RegulatoryAuthority2>,
2835 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
2836 pub dtls: Option<Vec<StructuredRegulatoryReporting3>>,
2837}
2838
2839impl RegulatoryReporting3 {
2840 pub fn validate(&self) -> Result<(), ValidationError> {
2841 if let Some(ref val) = self.dbt_cdt_rptg_ind { val.validate()? }
2842 if let Some(ref val) = self.authrty { val.validate()? }
2843 if let Some(ref vec) = self.dtls { for item in vec { item.validate()? } }
2844 Ok(())
2845 }
2846}
2847
2848
2849#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2851pub enum RegulatoryReportingType1Code {
2852 #[default]
2853 #[serde(rename = "CRED")]
2854 CodeCRED,
2855 #[serde(rename = "DEBT")]
2856 CodeDEBT,
2857 #[serde(rename = "BOTH")]
2858 CodeBOTH,
2859}
2860
2861impl RegulatoryReportingType1Code {
2862 pub fn validate(&self) -> Result<(), ValidationError> {
2863 Ok(())
2864 }
2865}
2866
2867
2868#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2870pub struct RemittanceAmount4 {
2871 #[serde(rename = "RmtAmtAndTp", skip_serializing_if = "Option::is_none")]
2872 pub rmt_amt_and_tp: Option<Vec<DocumentAmount1>>,
2873 #[serde(rename = "AdjstmntAmtAndRsn", skip_serializing_if = "Option::is_none")]
2874 pub adjstmnt_amt_and_rsn: Option<Vec<DocumentAdjustment1>>,
2875}
2876
2877impl RemittanceAmount4 {
2878 pub fn validate(&self) -> Result<(), ValidationError> {
2879 if let Some(ref vec) = self.rmt_amt_and_tp { for item in vec { item.validate()? } }
2880 if let Some(ref vec) = self.adjstmnt_amt_and_rsn { for item in vec { item.validate()? } }
2881 Ok(())
2882 }
2883}
2884
2885
2886#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2888pub struct RemittanceInformation22 {
2889 #[serde(rename = "Ustrd", skip_serializing_if = "Option::is_none")]
2890 pub ustrd: Option<Vec<String>>,
2891 #[serde(rename = "Strd", skip_serializing_if = "Option::is_none")]
2892 pub strd: Option<Vec<StructuredRemittanceInformation18>>,
2893}
2894
2895impl RemittanceInformation22 {
2896 pub fn validate(&self) -> Result<(), ValidationError> {
2897 if let Some(ref vec) = self.ustrd {
2898 for item in vec {
2899 if item.chars().count() < 1 {
2900 return Err(ValidationError::new(1001, "ustrd is shorter than the minimum length of 1".to_string()));
2901 }
2902 if item.chars().count() > 140 {
2903 return Err(ValidationError::new(1002, "ustrd exceeds the maximum length of 140".to_string()));
2904 }
2905 }
2906 }
2907 if let Some(ref vec) = self.strd { for item in vec { item.validate()? } }
2908 Ok(())
2909 }
2910}
2911
2912
2913#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2915pub struct RemittanceLocation8 {
2916 #[serde(rename = "RmtId", skip_serializing_if = "Option::is_none")]
2917 pub rmt_id: Option<String>,
2918 #[serde(rename = "RmtLctnDtls", skip_serializing_if = "Option::is_none")]
2919 pub rmt_lctn_dtls: Option<Vec<RemittanceLocationData2>>,
2920}
2921
2922impl RemittanceLocation8 {
2923 pub fn validate(&self) -> Result<(), ValidationError> {
2924 if let Some(ref val) = self.rmt_id {
2925 if val.chars().count() < 1 {
2926 return Err(ValidationError::new(1001, "rmt_id is shorter than the minimum length of 1".to_string()));
2927 }
2928 if val.chars().count() > 35 {
2929 return Err(ValidationError::new(1002, "rmt_id exceeds the maximum length of 35".to_string()));
2930 }
2931 }
2932 if let Some(ref vec) = self.rmt_lctn_dtls { for item in vec { item.validate()? } }
2933 Ok(())
2934 }
2935}
2936
2937
2938#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2940pub struct RemittanceLocationData2 {
2941 #[serde(rename = "Mtd")]
2942 pub mtd: RemittanceLocationMethod2Code,
2943 #[serde(rename = "ElctrncAdr", skip_serializing_if = "Option::is_none")]
2944 pub elctrnc_adr: Option<String>,
2945 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
2946 pub pstl_adr: Option<NameAndAddress18>,
2947}
2948
2949impl RemittanceLocationData2 {
2950 pub fn validate(&self) -> Result<(), ValidationError> {
2951 self.mtd.validate()?;
2952 if let Some(ref val) = self.elctrnc_adr {
2953 if val.chars().count() < 1 {
2954 return Err(ValidationError::new(1001, "elctrnc_adr is shorter than the minimum length of 1".to_string()));
2955 }
2956 if val.chars().count() > 2048 {
2957 return Err(ValidationError::new(1002, "elctrnc_adr exceeds the maximum length of 2048".to_string()));
2958 }
2959 }
2960 if let Some(ref val) = self.pstl_adr { val.validate()? }
2961 Ok(())
2962 }
2963}
2964
2965
2966#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2968pub enum RemittanceLocationMethod2Code {
2969 #[default]
2970 #[serde(rename = "FAXI")]
2971 CodeFAXI,
2972 #[serde(rename = "EDIC")]
2973 CodeEDIC,
2974 #[serde(rename = "URID")]
2975 CodeURID,
2976 #[serde(rename = "EMAL")]
2977 CodeEMAL,
2978 #[serde(rename = "POST")]
2979 CodePOST,
2980 #[serde(rename = "SMSM")]
2981 CodeSMSM,
2982}
2983
2984impl RemittanceLocationMethod2Code {
2985 pub fn validate(&self) -> Result<(), ValidationError> {
2986 Ok(())
2987 }
2988}
2989
2990
2991#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
2993pub struct ServiceLevel8Choice {
2994 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
2995 pub cd: Option<String>,
2996 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
2997 pub prtry: Option<String>,
2998}
2999
3000impl ServiceLevel8Choice {
3001 pub fn validate(&self) -> Result<(), ValidationError> {
3002 if let Some(ref val) = self.cd {
3003 if val.chars().count() < 1 {
3004 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
3005 }
3006 if val.chars().count() > 4 {
3007 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 4".to_string()));
3008 }
3009 }
3010 if let Some(ref val) = self.prtry {
3011 if val.chars().count() < 1 {
3012 return Err(ValidationError::new(1001, "prtry is shorter than the minimum length of 1".to_string()));
3013 }
3014 if val.chars().count() > 35 {
3015 return Err(ValidationError::new(1002, "prtry exceeds the maximum length of 35".to_string()));
3016 }
3017 }
3018 Ok(())
3019 }
3020}
3021
3022
3023#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3025pub struct SettlementDateTimeIndication1 {
3026 #[serde(rename = "DbtDtTm", skip_serializing_if = "Option::is_none")]
3027 pub dbt_dt_tm: Option<String>,
3028 #[serde(rename = "CdtDtTm", skip_serializing_if = "Option::is_none")]
3029 pub cdt_dt_tm: Option<String>,
3030}
3031
3032impl SettlementDateTimeIndication1 {
3033 pub fn validate(&self) -> Result<(), ValidationError> {
3034 Ok(())
3035 }
3036}
3037
3038
3039#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3041pub struct SettlementInstruction15 {
3042 #[serde(rename = "SttlmMtd")]
3043 pub sttlm_mtd: SettlementMethod1Code,
3044 #[serde(rename = "SttlmAcct", skip_serializing_if = "Option::is_none")]
3045 pub sttlm_acct: Option<CashAccount40>,
3046 #[serde(rename = "ClrSys", skip_serializing_if = "Option::is_none")]
3047 pub clr_sys: Option<ClearingSystemIdentification3Choice>,
3048 #[serde(rename = "InstgRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3049 pub instg_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification8>,
3050 #[serde(rename = "InstgRmbrsmntAgtAcct", skip_serializing_if = "Option::is_none")]
3051 pub instg_rmbrsmnt_agt_acct: Option<CashAccount40>,
3052 #[serde(rename = "InstdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3053 pub instd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification8>,
3054 #[serde(rename = "InstdRmbrsmntAgtAcct", skip_serializing_if = "Option::is_none")]
3055 pub instd_rmbrsmnt_agt_acct: Option<CashAccount40>,
3056 #[serde(rename = "ThrdRmbrsmntAgt", skip_serializing_if = "Option::is_none")]
3057 pub thrd_rmbrsmnt_agt: Option<BranchAndFinancialInstitutionIdentification8>,
3058 #[serde(rename = "ThrdRmbrsmntAgtAcct", skip_serializing_if = "Option::is_none")]
3059 pub thrd_rmbrsmnt_agt_acct: Option<CashAccount40>,
3060}
3061
3062impl SettlementInstruction15 {
3063 pub fn validate(&self) -> Result<(), ValidationError> {
3064 self.sttlm_mtd.validate()?;
3065 if let Some(ref val) = self.sttlm_acct { val.validate()? }
3066 if let Some(ref val) = self.clr_sys { val.validate()? }
3067 if let Some(ref val) = self.instg_rmbrsmnt_agt { val.validate()? }
3068 if let Some(ref val) = self.instg_rmbrsmnt_agt_acct { val.validate()? }
3069 if let Some(ref val) = self.instd_rmbrsmnt_agt { val.validate()? }
3070 if let Some(ref val) = self.instd_rmbrsmnt_agt_acct { val.validate()? }
3071 if let Some(ref val) = self.thrd_rmbrsmnt_agt { val.validate()? }
3072 if let Some(ref val) = self.thrd_rmbrsmnt_agt_acct { val.validate()? }
3073 Ok(())
3074 }
3075}
3076
3077
3078#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3080pub enum SettlementMethod1Code {
3081 #[default]
3082 #[serde(rename = "INDA")]
3083 CodeINDA,
3084 #[serde(rename = "INGA")]
3085 CodeINGA,
3086 #[serde(rename = "COVE")]
3087 CodeCOVE,
3088 #[serde(rename = "CLRG")]
3089 CodeCLRG,
3090}
3091
3092impl SettlementMethod1Code {
3093 pub fn validate(&self) -> Result<(), ValidationError> {
3094 Ok(())
3095 }
3096}
3097
3098
3099#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3101pub struct SettlementTimeRequest2 {
3102 #[serde(rename = "CLSTm", skip_serializing_if = "Option::is_none")]
3103 pub cls_tm: Option<String>,
3104 #[serde(rename = "TillTm", skip_serializing_if = "Option::is_none")]
3105 pub till_tm: Option<String>,
3106 #[serde(rename = "FrTm", skip_serializing_if = "Option::is_none")]
3107 pub fr_tm: Option<String>,
3108 #[serde(rename = "RjctTm", skip_serializing_if = "Option::is_none")]
3109 pub rjct_tm: Option<String>,
3110}
3111
3112impl SettlementTimeRequest2 {
3113 pub fn validate(&self) -> Result<(), ValidationError> {
3114 Ok(())
3115 }
3116}
3117
3118
3119#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3121pub struct StructuredRegulatoryReporting3 {
3122 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3123 pub tp: Option<String>,
3124 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3125 pub dt: Option<String>,
3126 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
3127 pub ctry: Option<String>,
3128 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
3129 pub cd: Option<String>,
3130 #[serde(rename = "Amt", skip_serializing_if = "Option::is_none")]
3131 pub amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3132 #[serde(rename = "Inf", skip_serializing_if = "Option::is_none")]
3133 pub inf: Option<Vec<String>>,
3134}
3135
3136impl StructuredRegulatoryReporting3 {
3137 pub fn validate(&self) -> Result<(), ValidationError> {
3138 if let Some(ref val) = self.tp {
3139 if val.chars().count() < 1 {
3140 return Err(ValidationError::new(1001, "tp is shorter than the minimum length of 1".to_string()));
3141 }
3142 if val.chars().count() > 35 {
3143 return Err(ValidationError::new(1002, "tp exceeds the maximum length of 35".to_string()));
3144 }
3145 }
3146 if let Some(ref val) = self.ctry {
3147 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
3148 if !pattern.is_match(val) {
3149 return Err(ValidationError::new(1005, "ctry does not match the required pattern".to_string()));
3150 }
3151 }
3152 if let Some(ref val) = self.cd {
3153 if val.chars().count() < 1 {
3154 return Err(ValidationError::new(1001, "cd is shorter than the minimum length of 1".to_string()));
3155 }
3156 if val.chars().count() > 10 {
3157 return Err(ValidationError::new(1002, "cd exceeds the maximum length of 10".to_string()));
3158 }
3159 }
3160 if let Some(ref val) = self.amt { val.validate()? }
3161 if let Some(ref vec) = self.inf {
3162 for item in vec {
3163 if item.chars().count() < 1 {
3164 return Err(ValidationError::new(1001, "inf is shorter than the minimum length of 1".to_string()));
3165 }
3166 if item.chars().count() > 35 {
3167 return Err(ValidationError::new(1002, "inf exceeds the maximum length of 35".to_string()));
3168 }
3169 }
3170 }
3171 Ok(())
3172 }
3173}
3174
3175
3176#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3178pub struct StructuredRemittanceInformation18 {
3179 #[serde(rename = "RfrdDocInf", skip_serializing_if = "Option::is_none")]
3180 pub rfrd_doc_inf: Option<Vec<ReferredDocumentInformation8>>,
3181 #[serde(rename = "RfrdDocAmt", skip_serializing_if = "Option::is_none")]
3182 pub rfrd_doc_amt: Option<RemittanceAmount4>,
3183 #[serde(rename = "CdtrRefInf", skip_serializing_if = "Option::is_none")]
3184 pub cdtr_ref_inf: Option<CreditorReferenceInformation3>,
3185 #[serde(rename = "Invcr", skip_serializing_if = "Option::is_none")]
3186 pub invcr: Option<PartyIdentification272>,
3187 #[serde(rename = "Invcee", skip_serializing_if = "Option::is_none")]
3188 pub invcee: Option<PartyIdentification272>,
3189 #[serde(rename = "TaxRmt", skip_serializing_if = "Option::is_none")]
3190 pub tax_rmt: Option<TaxData1>,
3191 #[serde(rename = "GrnshmtRmt", skip_serializing_if = "Option::is_none")]
3192 pub grnshmt_rmt: Option<Garnishment4>,
3193 #[serde(rename = "AddtlRmtInf", skip_serializing_if = "Option::is_none")]
3194 pub addtl_rmt_inf: Option<Vec<String>>,
3195}
3196
3197impl StructuredRemittanceInformation18 {
3198 pub fn validate(&self) -> Result<(), ValidationError> {
3199 if let Some(ref vec) = self.rfrd_doc_inf { for item in vec { item.validate()? } }
3200 if let Some(ref val) = self.rfrd_doc_amt { val.validate()? }
3201 if let Some(ref val) = self.cdtr_ref_inf { val.validate()? }
3202 if let Some(ref val) = self.invcr { val.validate()? }
3203 if let Some(ref val) = self.invcee { val.validate()? }
3204 if let Some(ref val) = self.tax_rmt { val.validate()? }
3205 if let Some(ref val) = self.grnshmt_rmt { val.validate()? }
3206 if let Some(ref vec) = self.addtl_rmt_inf {
3207 for item in vec {
3208 if item.chars().count() < 1 {
3209 return Err(ValidationError::new(1001, "addtl_rmt_inf is shorter than the minimum length of 1".to_string()));
3210 }
3211 if item.chars().count() > 140 {
3212 return Err(ValidationError::new(1002, "addtl_rmt_inf exceeds the maximum length of 140".to_string()));
3213 }
3214 }
3215 }
3216 Ok(())
3217 }
3218}
3219
3220
3221#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3223pub struct SupplementaryData1 {
3224 #[serde(rename = "PlcAndNm", skip_serializing_if = "Option::is_none")]
3225 pub plc_and_nm: Option<String>,
3226 #[serde(rename = "Envlp")]
3227 pub envlp: SupplementaryDataEnvelope1,
3228}
3229
3230impl SupplementaryData1 {
3231 pub fn validate(&self) -> Result<(), ValidationError> {
3232 if let Some(ref val) = self.plc_and_nm {
3233 if val.chars().count() < 1 {
3234 return Err(ValidationError::new(1001, "plc_and_nm is shorter than the minimum length of 1".to_string()));
3235 }
3236 if val.chars().count() > 350 {
3237 return Err(ValidationError::new(1002, "plc_and_nm exceeds the maximum length of 350".to_string()));
3238 }
3239 }
3240 self.envlp.validate()?;
3241 Ok(())
3242 }
3243}
3244
3245
3246#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3248pub struct SupplementaryDataEnvelope1 {
3249}
3250
3251impl SupplementaryDataEnvelope1 {
3252 pub fn validate(&self) -> Result<(), ValidationError> {
3253 Ok(())
3254 }
3255}
3256
3257
3258#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3260pub struct TaxAmount3 {
3261 #[serde(rename = "Rate", skip_serializing_if = "Option::is_none")]
3262 pub rate: Option<f64>,
3263 #[serde(rename = "TaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3264 pub taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3265 #[serde(rename = "TtlAmt", skip_serializing_if = "Option::is_none")]
3266 pub ttl_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3267 #[serde(rename = "Dtls", skip_serializing_if = "Option::is_none")]
3268 pub dtls: Option<Vec<TaxRecordDetails3>>,
3269}
3270
3271impl TaxAmount3 {
3272 pub fn validate(&self) -> Result<(), ValidationError> {
3273 if let Some(ref val) = self.taxbl_base_amt { val.validate()? }
3274 if let Some(ref val) = self.ttl_amt { val.validate()? }
3275 if let Some(ref vec) = self.dtls { for item in vec { item.validate()? } }
3276 Ok(())
3277 }
3278}
3279
3280
3281#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3283pub struct TaxAuthorisation1 {
3284 #[serde(rename = "Titl", skip_serializing_if = "Option::is_none")]
3285 pub titl: Option<String>,
3286 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
3287 pub nm: Option<String>,
3288}
3289
3290impl TaxAuthorisation1 {
3291 pub fn validate(&self) -> Result<(), ValidationError> {
3292 if let Some(ref val) = self.titl {
3293 if val.chars().count() < 1 {
3294 return Err(ValidationError::new(1001, "titl is shorter than the minimum length of 1".to_string()));
3295 }
3296 if val.chars().count() > 35 {
3297 return Err(ValidationError::new(1002, "titl exceeds the maximum length of 35".to_string()));
3298 }
3299 }
3300 if let Some(ref val) = self.nm {
3301 if val.chars().count() < 1 {
3302 return Err(ValidationError::new(1001, "nm is shorter than the minimum length of 1".to_string()));
3303 }
3304 if val.chars().count() > 140 {
3305 return Err(ValidationError::new(1002, "nm exceeds the maximum length of 140".to_string()));
3306 }
3307 }
3308 Ok(())
3309 }
3310}
3311
3312
3313#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3315pub struct TaxData1 {
3316 #[serde(rename = "Cdtr", skip_serializing_if = "Option::is_none")]
3317 pub cdtr: Option<TaxParty1>,
3318 #[serde(rename = "Dbtr", skip_serializing_if = "Option::is_none")]
3319 pub dbtr: Option<TaxParty2>,
3320 #[serde(rename = "UltmtDbtr", skip_serializing_if = "Option::is_none")]
3321 pub ultmt_dbtr: Option<TaxParty2>,
3322 #[serde(rename = "AdmstnZone", skip_serializing_if = "Option::is_none")]
3323 pub admstn_zone: Option<String>,
3324 #[serde(rename = "RefNb", skip_serializing_if = "Option::is_none")]
3325 pub ref_nb: Option<String>,
3326 #[serde(rename = "Mtd", skip_serializing_if = "Option::is_none")]
3327 pub mtd: Option<String>,
3328 #[serde(rename = "TtlTaxblBaseAmt", skip_serializing_if = "Option::is_none")]
3329 pub ttl_taxbl_base_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3330 #[serde(rename = "TtlTaxAmt", skip_serializing_if = "Option::is_none")]
3331 pub ttl_tax_amt: Option<ActiveOrHistoricCurrencyAndAmount>,
3332 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
3333 pub dt: Option<String>,
3334 #[serde(rename = "SeqNb", skip_serializing_if = "Option::is_none")]
3335 pub seq_nb: Option<f64>,
3336 #[serde(rename = "Rcrd", skip_serializing_if = "Option::is_none")]
3337 pub rcrd: Option<Vec<TaxRecord3>>,
3338}
3339
3340impl TaxData1 {
3341 pub fn validate(&self) -> Result<(), ValidationError> {
3342 if let Some(ref val) = self.cdtr { val.validate()? }
3343 if let Some(ref val) = self.dbtr { val.validate()? }
3344 if let Some(ref val) = self.ultmt_dbtr { val.validate()? }
3345 if let Some(ref val) = self.admstn_zone {
3346 if val.chars().count() < 1 {
3347 return Err(ValidationError::new(1001, "admstn_zone is shorter than the minimum length of 1".to_string()));
3348 }
3349 if val.chars().count() > 35 {
3350 return Err(ValidationError::new(1002, "admstn_zone exceeds the maximum length of 35".to_string()));
3351 }
3352 }
3353 if let Some(ref val) = self.ref_nb {
3354 if val.chars().count() < 1 {
3355 return Err(ValidationError::new(1001, "ref_nb is shorter than the minimum length of 1".to_string()));
3356 }
3357 if val.chars().count() > 140 {
3358 return Err(ValidationError::new(1002, "ref_nb exceeds the maximum length of 140".to_string()));
3359 }
3360 }
3361 if let Some(ref val) = self.mtd {
3362 if val.chars().count() < 1 {
3363 return Err(ValidationError::new(1001, "mtd is shorter than the minimum length of 1".to_string()));
3364 }
3365 if val.chars().count() > 35 {
3366 return Err(ValidationError::new(1002, "mtd exceeds the maximum length of 35".to_string()));
3367 }
3368 }
3369 if let Some(ref val) = self.ttl_taxbl_base_amt { val.validate()? }
3370 if let Some(ref val) = self.ttl_tax_amt { val.validate()? }
3371 if let Some(ref vec) = self.rcrd { for item in vec { item.validate()? } }
3372 Ok(())
3373 }
3374}
3375
3376
3377#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3379pub struct TaxParty1 {
3380 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
3381 pub tax_id: Option<String>,
3382 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
3383 pub regn_id: Option<String>,
3384 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
3385 pub tax_tp: Option<String>,
3386}
3387
3388impl TaxParty1 {
3389 pub fn validate(&self) -> Result<(), ValidationError> {
3390 if let Some(ref val) = self.tax_id {
3391 if val.chars().count() < 1 {
3392 return Err(ValidationError::new(1001, "tax_id is shorter than the minimum length of 1".to_string()));
3393 }
3394 if val.chars().count() > 35 {
3395 return Err(ValidationError::new(1002, "tax_id exceeds the maximum length of 35".to_string()));
3396 }
3397 }
3398 if let Some(ref val) = self.regn_id {
3399 if val.chars().count() < 1 {
3400 return Err(ValidationError::new(1001, "regn_id is shorter than the minimum length of 1".to_string()));
3401 }
3402 if val.chars().count() > 35 {
3403 return Err(ValidationError::new(1002, "regn_id exceeds the maximum length of 35".to_string()));
3404 }
3405 }
3406 if let Some(ref val) = self.tax_tp {
3407 if val.chars().count() < 1 {
3408 return Err(ValidationError::new(1001, "tax_tp is shorter than the minimum length of 1".to_string()));
3409 }
3410 if val.chars().count() > 35 {
3411 return Err(ValidationError::new(1002, "tax_tp exceeds the maximum length of 35".to_string()));
3412 }
3413 }
3414 Ok(())
3415 }
3416}
3417
3418
3419#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3421pub struct TaxParty2 {
3422 #[serde(rename = "TaxId", skip_serializing_if = "Option::is_none")]
3423 pub tax_id: Option<String>,
3424 #[serde(rename = "RegnId", skip_serializing_if = "Option::is_none")]
3425 pub regn_id: Option<String>,
3426 #[serde(rename = "TaxTp", skip_serializing_if = "Option::is_none")]
3427 pub tax_tp: Option<String>,
3428 #[serde(rename = "Authstn", skip_serializing_if = "Option::is_none")]
3429 pub authstn: Option<TaxAuthorisation1>,
3430}
3431
3432impl TaxParty2 {
3433 pub fn validate(&self) -> Result<(), ValidationError> {
3434 if let Some(ref val) = self.tax_id {
3435 if val.chars().count() < 1 {
3436 return Err(ValidationError::new(1001, "tax_id is shorter than the minimum length of 1".to_string()));
3437 }
3438 if val.chars().count() > 35 {
3439 return Err(ValidationError::new(1002, "tax_id exceeds the maximum length of 35".to_string()));
3440 }
3441 }
3442 if let Some(ref val) = self.regn_id {
3443 if val.chars().count() < 1 {
3444 return Err(ValidationError::new(1001, "regn_id is shorter than the minimum length of 1".to_string()));
3445 }
3446 if val.chars().count() > 35 {
3447 return Err(ValidationError::new(1002, "regn_id exceeds the maximum length of 35".to_string()));
3448 }
3449 }
3450 if let Some(ref val) = self.tax_tp {
3451 if val.chars().count() < 1 {
3452 return Err(ValidationError::new(1001, "tax_tp is shorter than the minimum length of 1".to_string()));
3453 }
3454 if val.chars().count() > 35 {
3455 return Err(ValidationError::new(1002, "tax_tp exceeds the maximum length of 35".to_string()));
3456 }
3457 }
3458 if let Some(ref val) = self.authstn { val.validate()? }
3459 Ok(())
3460 }
3461}
3462
3463
3464#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3466pub struct TaxPeriod3 {
3467 #[serde(rename = "Yr", skip_serializing_if = "Option::is_none")]
3468 pub yr: Option<String>,
3469 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3470 pub tp: Option<TaxRecordPeriod1Code>,
3471 #[serde(rename = "FrToDt", skip_serializing_if = "Option::is_none")]
3472 pub fr_to_dt: Option<DatePeriod2>,
3473}
3474
3475impl TaxPeriod3 {
3476 pub fn validate(&self) -> Result<(), ValidationError> {
3477 if let Some(ref val) = self.tp { val.validate()? }
3478 if let Some(ref val) = self.fr_to_dt { val.validate()? }
3479 Ok(())
3480 }
3481}
3482
3483
3484#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3486pub struct TaxRecord3 {
3487 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
3488 pub tp: Option<String>,
3489 #[serde(rename = "Ctgy", skip_serializing_if = "Option::is_none")]
3490 pub ctgy: Option<String>,
3491 #[serde(rename = "CtgyDtls", skip_serializing_if = "Option::is_none")]
3492 pub ctgy_dtls: Option<String>,
3493 #[serde(rename = "DbtrSts", skip_serializing_if = "Option::is_none")]
3494 pub dbtr_sts: Option<String>,
3495 #[serde(rename = "CertId", skip_serializing_if = "Option::is_none")]
3496 pub cert_id: Option<String>,
3497 #[serde(rename = "FrmsCd", skip_serializing_if = "Option::is_none")]
3498 pub frms_cd: Option<String>,
3499 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
3500 pub prd: Option<TaxPeriod3>,
3501 #[serde(rename = "TaxAmt", skip_serializing_if = "Option::is_none")]
3502 pub tax_amt: Option<TaxAmount3>,
3503 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
3504 pub addtl_inf: Option<String>,
3505}
3506
3507impl TaxRecord3 {
3508 pub fn validate(&self) -> Result<(), ValidationError> {
3509 if let Some(ref val) = self.tp {
3510 if val.chars().count() < 1 {
3511 return Err(ValidationError::new(1001, "tp is shorter than the minimum length of 1".to_string()));
3512 }
3513 if val.chars().count() > 35 {
3514 return Err(ValidationError::new(1002, "tp exceeds the maximum length of 35".to_string()));
3515 }
3516 }
3517 if let Some(ref val) = self.ctgy {
3518 if val.chars().count() < 1 {
3519 return Err(ValidationError::new(1001, "ctgy is shorter than the minimum length of 1".to_string()));
3520 }
3521 if val.chars().count() > 35 {
3522 return Err(ValidationError::new(1002, "ctgy exceeds the maximum length of 35".to_string()));
3523 }
3524 }
3525 if let Some(ref val) = self.ctgy_dtls {
3526 if val.chars().count() < 1 {
3527 return Err(ValidationError::new(1001, "ctgy_dtls is shorter than the minimum length of 1".to_string()));
3528 }
3529 if val.chars().count() > 35 {
3530 return Err(ValidationError::new(1002, "ctgy_dtls exceeds the maximum length of 35".to_string()));
3531 }
3532 }
3533 if let Some(ref val) = self.dbtr_sts {
3534 if val.chars().count() < 1 {
3535 return Err(ValidationError::new(1001, "dbtr_sts is shorter than the minimum length of 1".to_string()));
3536 }
3537 if val.chars().count() > 35 {
3538 return Err(ValidationError::new(1002, "dbtr_sts exceeds the maximum length of 35".to_string()));
3539 }
3540 }
3541 if let Some(ref val) = self.cert_id {
3542 if val.chars().count() < 1 {
3543 return Err(ValidationError::new(1001, "cert_id is shorter than the minimum length of 1".to_string()));
3544 }
3545 if val.chars().count() > 35 {
3546 return Err(ValidationError::new(1002, "cert_id exceeds the maximum length of 35".to_string()));
3547 }
3548 }
3549 if let Some(ref val) = self.frms_cd {
3550 if val.chars().count() < 1 {
3551 return Err(ValidationError::new(1001, "frms_cd is shorter than the minimum length of 1".to_string()));
3552 }
3553 if val.chars().count() > 35 {
3554 return Err(ValidationError::new(1002, "frms_cd exceeds the maximum length of 35".to_string()));
3555 }
3556 }
3557 if let Some(ref val) = self.prd { val.validate()? }
3558 if let Some(ref val) = self.tax_amt { val.validate()? }
3559 if let Some(ref val) = self.addtl_inf {
3560 if val.chars().count() < 1 {
3561 return Err(ValidationError::new(1001, "addtl_inf is shorter than the minimum length of 1".to_string()));
3562 }
3563 if val.chars().count() > 140 {
3564 return Err(ValidationError::new(1002, "addtl_inf exceeds the maximum length of 140".to_string()));
3565 }
3566 }
3567 Ok(())
3568 }
3569}
3570
3571
3572#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3574pub struct TaxRecordDetails3 {
3575 #[serde(rename = "Prd", skip_serializing_if = "Option::is_none")]
3576 pub prd: Option<TaxPeriod3>,
3577 #[serde(rename = "Amt")]
3578 pub amt: ActiveOrHistoricCurrencyAndAmount,
3579}
3580
3581impl TaxRecordDetails3 {
3582 pub fn validate(&self) -> Result<(), ValidationError> {
3583 if let Some(ref val) = self.prd { val.validate()? }
3584 self.amt.validate()?;
3585 Ok(())
3586 }
3587}
3588
3589
3590#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
3592pub enum TaxRecordPeriod1Code {
3593 #[default]
3594 #[serde(rename = "MM01")]
3595 CodeMM01,
3596 #[serde(rename = "MM02")]
3597 CodeMM02,
3598 #[serde(rename = "MM03")]
3599 CodeMM03,
3600 #[serde(rename = "MM04")]
3601 CodeMM04,
3602 #[serde(rename = "MM05")]
3603 CodeMM05,
3604 #[serde(rename = "MM06")]
3605 CodeMM06,
3606 #[serde(rename = "MM07")]
3607 CodeMM07,
3608 #[serde(rename = "MM08")]
3609 CodeMM08,
3610 #[serde(rename = "MM09")]
3611 CodeMM09,
3612 #[serde(rename = "MM10")]
3613 CodeMM10,
3614 #[serde(rename = "MM11")]
3615 CodeMM11,
3616 #[serde(rename = "MM12")]
3617 CodeMM12,
3618 #[serde(rename = "QTR1")]
3619 CodeQTR1,
3620 #[serde(rename = "QTR2")]
3621 CodeQTR2,
3622 #[serde(rename = "QTR3")]
3623 CodeQTR3,
3624 #[serde(rename = "QTR4")]
3625 CodeQTR4,
3626 #[serde(rename = "HLF1")]
3627 CodeHLF1,
3628 #[serde(rename = "HLF2")]
3629 CodeHLF2,
3630}
3631
3632impl TaxRecordPeriod1Code {
3633 pub fn validate(&self) -> Result<(), ValidationError> {
3634 Ok(())
3635 }
3636}