1use crate::error::*;
21use regex::Regex;
22use serde::{Deserialize, Serialize};
23
24#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
26pub struct AccountIdentification4Choice1 {
27 #[serde(rename = "IBAN", skip_serializing_if = "Option::is_none")]
28 pub iban: Option<String>,
29 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
30 pub othr: Option<GenericAccountIdentification11>,
31}
32
33impl AccountIdentification4Choice1 {
34 pub fn validate(&self) -> Result<(), ValidationError> {
35 if let Some(ref val) = self.iban {
36 let pattern = Regex::new("[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}").unwrap();
37 if !pattern.is_match(val) {
38 return Err(ValidationError::new(
39 1005,
40 "iban does not match the required pattern".to_string(),
41 ));
42 }
43 }
44 if let Some(ref val) = self.othr {
45 val.validate()?
46 }
47 Ok(())
48 }
49}
50
51#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
53pub struct AccountSchemeName1Choice1 {
54 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
55 pub cd: Option<String>,
56 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
57 pub prtry: Option<String>,
58}
59
60impl AccountSchemeName1Choice1 {
61 pub fn validate(&self) -> Result<(), ValidationError> {
62 if let Some(ref val) = self.cd {
63 if val.chars().count() < 1 {
64 return Err(ValidationError::new(
65 1001,
66 "cd is shorter than the minimum length of 1".to_string(),
67 ));
68 }
69 if val.chars().count() > 4 {
70 return Err(ValidationError::new(
71 1002,
72 "cd exceeds the maximum length of 4".to_string(),
73 ));
74 }
75 }
76 if let Some(ref val) = self.prtry {
77 if val.chars().count() < 1 {
78 return Err(ValidationError::new(
79 1001,
80 "prtry is shorter than the minimum length of 1".to_string(),
81 ));
82 }
83 if val.chars().count() > 35 {
84 return Err(ValidationError::new(
85 1002,
86 "prtry exceeds the maximum length of 35".to_string(),
87 ));
88 }
89 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
90 if !pattern.is_match(val) {
91 return Err(ValidationError::new(
92 1005,
93 "prtry does not match the required pattern".to_string(),
94 ));
95 }
96 }
97 Ok(())
98 }
99}
100
101#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
103pub struct BranchAndFinancialInstitutionIdentification61 {
104 #[serde(rename = "FinInstnId")]
105 pub fin_instn_id: FinancialInstitutionIdentification181,
106}
107
108impl BranchAndFinancialInstitutionIdentification61 {
109 pub fn validate(&self) -> Result<(), ValidationError> {
110 self.fin_instn_id.validate()?;
111 Ok(())
112 }
113}
114
115#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
117pub struct CBPRAmount {
118 #[serde(rename = "@Ccy")]
119 pub ccy: String,
120 #[serde(rename = "$value")]
121 pub value: f64,
122}
123
124impl CBPRAmount {
125 pub fn validate(&self) -> Result<(), ValidationError> {
126 Ok(())
127 }
128}
129
130#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
132pub enum CBPRChequeCancellationReasonCode {
133 #[default]
134 #[serde(rename = "DUPL")]
135 CodeDUPL,
136 #[serde(rename = "CUST")]
137 CodeCUST,
138 #[serde(rename = "FRAD")]
139 CodeFRAD,
140 #[serde(rename = "LOST")]
141 CodeLOST,
142 #[serde(rename = "NARR")]
143 CodeNARR,
144}
145
146impl CBPRChequeCancellationReasonCode {
147 pub fn validate(&self) -> Result<(), ValidationError> {
148 Ok(())
149 }
150}
151
152#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
154pub struct CashAccount401 {
155 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
156 pub id: Option<AccountIdentification4Choice1>,
157 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
158 pub tp: Option<CashAccountType2Choice1>,
159 #[serde(rename = "Ccy", skip_serializing_if = "Option::is_none")]
160 pub ccy: Option<String>,
161 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
162 pub nm: Option<String>,
163 #[serde(rename = "Prxy", skip_serializing_if = "Option::is_none")]
164 pub prxy: Option<ProxyAccountIdentification11>,
165}
166
167impl CashAccount401 {
168 pub fn validate(&self) -> Result<(), ValidationError> {
169 if let Some(ref val) = self.id {
170 val.validate()?
171 }
172 if let Some(ref val) = self.tp {
173 val.validate()?
174 }
175 if let Some(ref val) = self.ccy {
176 let pattern = Regex::new("[A-Z]{3,3}").unwrap();
177 if !pattern.is_match(val) {
178 return Err(ValidationError::new(
179 1005,
180 "ccy does not match the required pattern".to_string(),
181 ));
182 }
183 }
184 if let Some(ref val) = self.nm {
185 if val.chars().count() < 1 {
186 return Err(ValidationError::new(
187 1001,
188 "nm is shorter than the minimum length of 1".to_string(),
189 ));
190 }
191 if val.chars().count() > 70 {
192 return Err(ValidationError::new(
193 1002,
194 "nm exceeds the maximum length of 70".to_string(),
195 ));
196 }
197 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
198 if !pattern.is_match(val) {
199 return Err(ValidationError::new(
200 1005,
201 "nm does not match the required pattern".to_string(),
202 ));
203 }
204 }
205 if let Some(ref val) = self.prxy {
206 val.validate()?
207 }
208 Ok(())
209 }
210}
211
212#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
214pub struct CashAccountType2Choice1 {
215 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
216 pub cd: Option<String>,
217 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
218 pub prtry: Option<String>,
219}
220
221impl CashAccountType2Choice1 {
222 pub fn validate(&self) -> Result<(), ValidationError> {
223 if let Some(ref val) = self.cd {
224 if val.chars().count() < 1 {
225 return Err(ValidationError::new(
226 1001,
227 "cd is shorter than the minimum length of 1".to_string(),
228 ));
229 }
230 if val.chars().count() > 4 {
231 return Err(ValidationError::new(
232 1002,
233 "cd exceeds the maximum length of 4".to_string(),
234 ));
235 }
236 }
237 if let Some(ref val) = self.prtry {
238 if val.chars().count() < 1 {
239 return Err(ValidationError::new(
240 1001,
241 "prtry is shorter than the minimum length of 1".to_string(),
242 ));
243 }
244 if val.chars().count() > 35 {
245 return Err(ValidationError::new(
246 1002,
247 "prtry exceeds the maximum length of 35".to_string(),
248 ));
249 }
250 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
251 if !pattern.is_match(val) {
252 return Err(ValidationError::new(
253 1005,
254 "prtry does not match the required pattern".to_string(),
255 ));
256 }
257 }
258 Ok(())
259 }
260}
261
262#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
264pub struct Cheque151 {
265 #[serde(rename = "InstrId", skip_serializing_if = "Option::is_none")]
266 pub instr_id: Option<String>,
267 #[serde(rename = "OrgnlInstrId")]
268 pub orgnl_instr_id: String,
269 #[serde(rename = "ChqNb")]
270 pub chq_nb: String,
271 #[serde(rename = "IsseDt")]
272 pub isse_dt: String,
273 #[serde(rename = "StlDt", skip_serializing_if = "Option::is_none")]
274 pub stl_dt: Option<String>,
275 #[serde(rename = "Amt")]
276 pub amt: CBPRAmount,
277 #[serde(rename = "FctvDt", skip_serializing_if = "Option::is_none")]
278 pub fctv_dt: Option<DateAndDateTime2Choice1>,
279 #[serde(rename = "DrwrAgt", skip_serializing_if = "Option::is_none")]
280 pub drwr_agt: Option<BranchAndFinancialInstitutionIdentification61>,
281 #[serde(rename = "DrwrAgtAcct", skip_serializing_if = "Option::is_none")]
282 pub drwr_agt_acct: Option<CashAccount401>,
283 #[serde(rename = "Pyee", skip_serializing_if = "Option::is_none")]
284 pub pyee: Option<PartyIdentification1351>,
285 #[serde(rename = "ChqCxlOrStopRsn")]
286 pub chq_cxl_or_stop_rsn: ChequeCancellationReason11,
287}
288
289impl Cheque151 {
290 pub fn validate(&self) -> Result<(), ValidationError> {
291 if let Some(ref val) = self.instr_id {
292 if val.chars().count() < 1 {
293 return Err(ValidationError::new(
294 1001,
295 "instr_id is shorter than the minimum length of 1".to_string(),
296 ));
297 }
298 if val.chars().count() > 35 {
299 return Err(ValidationError::new(
300 1002,
301 "instr_id exceeds the maximum length of 35".to_string(),
302 ));
303 }
304 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
305 if !pattern.is_match(val) {
306 return Err(ValidationError::new(
307 1005,
308 "instr_id does not match the required pattern".to_string(),
309 ));
310 }
311 }
312 if self.orgnl_instr_id.chars().count() < 1 {
313 return Err(ValidationError::new(
314 1001,
315 "orgnl_instr_id is shorter than the minimum length of 1".to_string(),
316 ));
317 }
318 if self.orgnl_instr_id.chars().count() > 35 {
319 return Err(ValidationError::new(
320 1002,
321 "orgnl_instr_id exceeds the maximum length of 35".to_string(),
322 ));
323 }
324 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
325 if !pattern.is_match(&self.orgnl_instr_id) {
326 return Err(ValidationError::new(
327 1005,
328 "orgnl_instr_id does not match the required pattern".to_string(),
329 ));
330 }
331 if self.chq_nb.chars().count() < 1 {
332 return Err(ValidationError::new(
333 1001,
334 "chq_nb is shorter than the minimum length of 1".to_string(),
335 ));
336 }
337 if self.chq_nb.chars().count() > 16 {
338 return Err(ValidationError::new(
339 1002,
340 "chq_nb exceeds the maximum length of 16".to_string(),
341 ));
342 }
343 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
344 if !pattern.is_match(&self.chq_nb) {
345 return Err(ValidationError::new(
346 1005,
347 "chq_nb does not match the required pattern".to_string(),
348 ));
349 }
350 self.amt.validate()?;
351 if let Some(ref val) = self.fctv_dt {
352 val.validate()?
353 }
354 if let Some(ref val) = self.drwr_agt {
355 val.validate()?
356 }
357 if let Some(ref val) = self.drwr_agt_acct {
358 val.validate()?
359 }
360 if let Some(ref val) = self.pyee {
361 val.validate()?
362 }
363 self.chq_cxl_or_stop_rsn.validate()?;
364 Ok(())
365 }
366}
367
368#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
370pub struct ChequeCancellationOrStopRequestV01 {
371 #[serde(rename = "GrpHdr")]
372 pub grp_hdr: GroupHeader1031,
373 #[serde(rename = "Chq")]
374 pub chq: Cheque151,
375}
376
377impl ChequeCancellationOrStopRequestV01 {
378 pub fn validate(&self) -> Result<(), ValidationError> {
379 self.grp_hdr.validate()?;
380 self.chq.validate()?;
381 Ok(())
382 }
383}
384
385#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
387pub struct ChequeCancellationReason1Choice1 {
388 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
389 pub cd: Option<CBPRChequeCancellationReasonCode>,
390}
391
392impl ChequeCancellationReason1Choice1 {
393 pub fn validate(&self) -> Result<(), ValidationError> {
394 if let Some(ref val) = self.cd {
395 val.validate()?
396 }
397 Ok(())
398 }
399}
400
401#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
403pub struct ChequeCancellationReason11 {
404 #[serde(rename = "Orgtr", skip_serializing_if = "Option::is_none")]
405 pub orgtr: Option<ChequePartyRole1Code>,
406 #[serde(rename = "Rsn")]
407 pub rsn: ChequeCancellationReason1Choice1,
408 #[serde(rename = "AddtlInf", skip_serializing_if = "Option::is_none")]
409 pub addtl_inf: Option<String>,
410}
411
412impl ChequeCancellationReason11 {
413 pub fn validate(&self) -> Result<(), ValidationError> {
414 if let Some(ref val) = self.orgtr {
415 val.validate()?
416 }
417 self.rsn.validate()?;
418 if let Some(ref val) = self.addtl_inf {
419 if val.chars().count() < 1 {
420 return Err(ValidationError::new(
421 1001,
422 "addtl_inf is shorter than the minimum length of 1".to_string(),
423 ));
424 }
425 if val.chars().count() > 140 {
426 return Err(ValidationError::new(
427 1002,
428 "addtl_inf exceeds the maximum length of 140".to_string(),
429 ));
430 }
431 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
432 if !pattern.is_match(val) {
433 return Err(ValidationError::new(
434 1005,
435 "addtl_inf does not match the required pattern".to_string(),
436 ));
437 }
438 }
439 Ok(())
440 }
441}
442
443#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
445pub enum ChequePartyRole1Code {
446 #[default]
447 #[serde(rename = "DWEA")]
448 CodeDWEA,
449 #[serde(rename = "DWRA")]
450 CodeDWRA,
451 #[serde(rename = "PAYE")]
452 CodePAYE,
453 #[serde(rename = "PAYR")]
454 CodePAYR,
455}
456
457impl ChequePartyRole1Code {
458 pub fn validate(&self) -> Result<(), ValidationError> {
459 Ok(())
460 }
461}
462
463#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
465pub struct ClearingSystemIdentification2Choice1 {
466 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
467 pub cd: Option<String>,
468}
469
470impl ClearingSystemIdentification2Choice1 {
471 pub fn validate(&self) -> Result<(), ValidationError> {
472 if let Some(ref val) = self.cd {
473 if val.chars().count() < 1 {
474 return Err(ValidationError::new(
475 1001,
476 "cd is shorter than the minimum length of 1".to_string(),
477 ));
478 }
479 if val.chars().count() > 5 {
480 return Err(ValidationError::new(
481 1002,
482 "cd exceeds the maximum length of 5".to_string(),
483 ));
484 }
485 }
486 Ok(())
487 }
488}
489
490#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
492pub struct ClearingSystemMemberIdentification21 {
493 #[serde(rename = "ClrSysId")]
494 pub clr_sys_id: ClearingSystemIdentification2Choice1,
495 #[serde(rename = "MmbId")]
496 pub mmb_id: String,
497}
498
499impl ClearingSystemMemberIdentification21 {
500 pub fn validate(&self) -> Result<(), ValidationError> {
501 self.clr_sys_id.validate()?;
502 if self.mmb_id.chars().count() < 1 {
503 return Err(ValidationError::new(
504 1001,
505 "mmb_id is shorter than the minimum length of 1".to_string(),
506 ));
507 }
508 if self.mmb_id.chars().count() > 28 {
509 return Err(ValidationError::new(
510 1002,
511 "mmb_id exceeds the maximum length of 28".to_string(),
512 ));
513 }
514 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
515 if !pattern.is_match(&self.mmb_id) {
516 return Err(ValidationError::new(
517 1005,
518 "mmb_id does not match the required pattern".to_string(),
519 ));
520 }
521 Ok(())
522 }
523}
524
525#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
527pub struct DateAndDateTime2Choice1 {
528 #[serde(rename = "Dt", skip_serializing_if = "Option::is_none")]
529 pub dt: Option<String>,
530}
531
532impl DateAndDateTime2Choice1 {
533 pub fn validate(&self) -> Result<(), ValidationError> {
534 Ok(())
535 }
536}
537
538#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
540pub struct DateAndPlaceOfBirth11 {
541 #[serde(rename = "BirthDt")]
542 pub birth_dt: String,
543 #[serde(rename = "PrvcOfBirth", skip_serializing_if = "Option::is_none")]
544 pub prvc_of_birth: Option<String>,
545 #[serde(rename = "CityOfBirth")]
546 pub city_of_birth: String,
547 #[serde(rename = "CtryOfBirth")]
548 pub ctry_of_birth: String,
549}
550
551impl DateAndPlaceOfBirth11 {
552 pub fn validate(&self) -> Result<(), ValidationError> {
553 if let Some(ref val) = self.prvc_of_birth {
554 if val.chars().count() < 1 {
555 return Err(ValidationError::new(
556 1001,
557 "prvc_of_birth is shorter than the minimum length of 1".to_string(),
558 ));
559 }
560 if val.chars().count() > 35 {
561 return Err(ValidationError::new(
562 1002,
563 "prvc_of_birth exceeds the maximum length of 35".to_string(),
564 ));
565 }
566 let pattern = Regex::new(
567 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
568 )
569 .unwrap();
570 if !pattern.is_match(val) {
571 return Err(ValidationError::new(
572 1005,
573 "prvc_of_birth does not match the required pattern".to_string(),
574 ));
575 }
576 }
577 if self.city_of_birth.chars().count() < 1 {
578 return Err(ValidationError::new(
579 1001,
580 "city_of_birth is shorter than the minimum length of 1".to_string(),
581 ));
582 }
583 if self.city_of_birth.chars().count() > 35 {
584 return Err(ValidationError::new(
585 1002,
586 "city_of_birth exceeds the maximum length of 35".to_string(),
587 ));
588 }
589 let pattern =
590 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
591 .unwrap();
592 if !pattern.is_match(&self.city_of_birth) {
593 return Err(ValidationError::new(
594 1005,
595 "city_of_birth does not match the required pattern".to_string(),
596 ));
597 }
598 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
599 if !pattern.is_match(&self.ctry_of_birth) {
600 return Err(ValidationError::new(
601 1005,
602 "ctry_of_birth does not match the required pattern".to_string(),
603 ));
604 }
605 Ok(())
606 }
607}
608
609#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
611pub struct FinancialInstitutionIdentification181 {
612 #[serde(rename = "BICFI", skip_serializing_if = "Option::is_none")]
613 pub bicfi: Option<String>,
614 #[serde(rename = "ClrSysMmbId", skip_serializing_if = "Option::is_none")]
615 pub clr_sys_mmb_id: Option<ClearingSystemMemberIdentification21>,
616 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
617 pub lei: Option<String>,
618 #[serde(rename = "Nm", skip_serializing_if = "Option::is_none")]
619 pub nm: Option<String>,
620 #[serde(rename = "PstlAdr", skip_serializing_if = "Option::is_none")]
621 pub pstl_adr: Option<PostalAddress241>,
622}
623
624impl FinancialInstitutionIdentification181 {
625 pub fn validate(&self) -> Result<(), ValidationError> {
626 if let Some(ref val) = self.bicfi {
627 let pattern =
628 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
629 if !pattern.is_match(val) {
630 return Err(ValidationError::new(
631 1005,
632 "bicfi does not match the required pattern".to_string(),
633 ));
634 }
635 }
636 if let Some(ref val) = self.clr_sys_mmb_id {
637 val.validate()?
638 }
639 if let Some(ref val) = self.lei {
640 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
641 if !pattern.is_match(val) {
642 return Err(ValidationError::new(
643 1005,
644 "lei does not match the required pattern".to_string(),
645 ));
646 }
647 }
648 if let Some(ref val) = self.nm {
649 if val.chars().count() < 1 {
650 return Err(ValidationError::new(
651 1001,
652 "nm is shorter than the minimum length of 1".to_string(),
653 ));
654 }
655 if val.chars().count() > 140 {
656 return Err(ValidationError::new(
657 1002,
658 "nm exceeds the maximum length of 140".to_string(),
659 ));
660 }
661 let pattern = Regex::new(
662 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
663 )
664 .unwrap();
665 if !pattern.is_match(val) {
666 return Err(ValidationError::new(
667 1005,
668 "nm does not match the required pattern".to_string(),
669 ));
670 }
671 }
672 if let Some(ref val) = self.pstl_adr {
673 val.validate()?
674 }
675 Ok(())
676 }
677}
678
679#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
681pub struct GenericAccountIdentification11 {
682 #[serde(rename = "Id")]
683 pub id: String,
684 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
685 pub schme_nm: Option<AccountSchemeName1Choice1>,
686 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
687 pub issr: Option<String>,
688}
689
690impl GenericAccountIdentification11 {
691 pub fn validate(&self) -> Result<(), ValidationError> {
692 if self.id.chars().count() < 1 {
693 return Err(ValidationError::new(
694 1001,
695 "id is shorter than the minimum length of 1".to_string(),
696 ));
697 }
698 if self.id.chars().count() > 34 {
699 return Err(ValidationError::new(
700 1002,
701 "id exceeds the maximum length of 34".to_string(),
702 ));
703 }
704 let pattern = Regex::new("([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]([0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ]*(/[0-9a-zA-Z\\-\\?:\\(\\)\\.,'\\+ ])?)*)").unwrap();
705 if !pattern.is_match(&self.id) {
706 return Err(ValidationError::new(
707 1005,
708 "id does not match the required pattern".to_string(),
709 ));
710 }
711 if let Some(ref val) = self.schme_nm {
712 val.validate()?
713 }
714 if let Some(ref val) = self.issr {
715 if val.chars().count() < 1 {
716 return Err(ValidationError::new(
717 1001,
718 "issr is shorter than the minimum length of 1".to_string(),
719 ));
720 }
721 if val.chars().count() > 35 {
722 return Err(ValidationError::new(
723 1002,
724 "issr exceeds the maximum length of 35".to_string(),
725 ));
726 }
727 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
728 if !pattern.is_match(val) {
729 return Err(ValidationError::new(
730 1005,
731 "issr does not match the required pattern".to_string(),
732 ));
733 }
734 }
735 Ok(())
736 }
737}
738
739#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
741pub struct GenericOrganisationIdentification11 {
742 #[serde(rename = "Id")]
743 pub id: String,
744 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
745 pub schme_nm: Option<OrganisationIdentificationSchemeName1Choice1>,
746 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
747 pub issr: Option<String>,
748}
749
750impl GenericOrganisationIdentification11 {
751 pub fn validate(&self) -> Result<(), ValidationError> {
752 if self.id.chars().count() < 1 {
753 return Err(ValidationError::new(
754 1001,
755 "id is shorter than the minimum length of 1".to_string(),
756 ));
757 }
758 if self.id.chars().count() > 35 {
759 return Err(ValidationError::new(
760 1002,
761 "id exceeds the maximum length of 35".to_string(),
762 ));
763 }
764 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
765 if !pattern.is_match(&self.id) {
766 return Err(ValidationError::new(
767 1005,
768 "id does not match the required pattern".to_string(),
769 ));
770 }
771 if let Some(ref val) = self.schme_nm {
772 val.validate()?
773 }
774 if let Some(ref val) = self.issr {
775 if val.chars().count() < 1 {
776 return Err(ValidationError::new(
777 1001,
778 "issr is shorter than the minimum length of 1".to_string(),
779 ));
780 }
781 if val.chars().count() > 35 {
782 return Err(ValidationError::new(
783 1002,
784 "issr exceeds the maximum length of 35".to_string(),
785 ));
786 }
787 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
788 if !pattern.is_match(val) {
789 return Err(ValidationError::new(
790 1005,
791 "issr does not match the required pattern".to_string(),
792 ));
793 }
794 }
795 Ok(())
796 }
797}
798
799#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
801pub struct GenericPersonIdentification11 {
802 #[serde(rename = "Id")]
803 pub id: String,
804 #[serde(rename = "SchmeNm", skip_serializing_if = "Option::is_none")]
805 pub schme_nm: Option<PersonIdentificationSchemeName1Choice1>,
806 #[serde(rename = "Issr", skip_serializing_if = "Option::is_none")]
807 pub issr: Option<String>,
808}
809
810impl GenericPersonIdentification11 {
811 pub fn validate(&self) -> Result<(), ValidationError> {
812 if self.id.chars().count() < 1 {
813 return Err(ValidationError::new(
814 1001,
815 "id is shorter than the minimum length of 1".to_string(),
816 ));
817 }
818 if self.id.chars().count() > 35 {
819 return Err(ValidationError::new(
820 1002,
821 "id exceeds the maximum length of 35".to_string(),
822 ));
823 }
824 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
825 if !pattern.is_match(&self.id) {
826 return Err(ValidationError::new(
827 1005,
828 "id does not match the required pattern".to_string(),
829 ));
830 }
831 if let Some(ref val) = self.schme_nm {
832 val.validate()?
833 }
834 if let Some(ref val) = self.issr {
835 if val.chars().count() < 1 {
836 return Err(ValidationError::new(
837 1001,
838 "issr is shorter than the minimum length of 1".to_string(),
839 ));
840 }
841 if val.chars().count() > 35 {
842 return Err(ValidationError::new(
843 1002,
844 "issr exceeds the maximum length of 35".to_string(),
845 ));
846 }
847 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
848 if !pattern.is_match(val) {
849 return Err(ValidationError::new(
850 1005,
851 "issr does not match the required pattern".to_string(),
852 ));
853 }
854 }
855 Ok(())
856 }
857}
858
859#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
861pub struct GroupHeader1031 {
862 #[serde(rename = "MsgId")]
863 pub msg_id: String,
864 #[serde(rename = "CreDtTm")]
865 pub cre_dt_tm: String,
866 #[serde(rename = "NbOfChqs")]
867 pub nb_of_chqs: Max15NumericTextfixed,
868}
869
870impl GroupHeader1031 {
871 pub fn validate(&self) -> Result<(), ValidationError> {
872 if self.msg_id.chars().count() < 1 {
873 return Err(ValidationError::new(
874 1001,
875 "msg_id is shorter than the minimum length of 1".to_string(),
876 ));
877 }
878 if self.msg_id.chars().count() > 16 {
879 return Err(ValidationError::new(
880 1002,
881 "msg_id exceeds the maximum length of 16".to_string(),
882 ));
883 }
884 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
885 if !pattern.is_match(&self.msg_id) {
886 return Err(ValidationError::new(
887 1005,
888 "msg_id does not match the required pattern".to_string(),
889 ));
890 }
891 let pattern = Regex::new(".*(\\+|-)((0[0-9])|(1[0-4])):[0-5][0-9]").unwrap();
892 if !pattern.is_match(&self.cre_dt_tm) {
893 return Err(ValidationError::new(
894 1005,
895 "cre_dt_tm does not match the required pattern".to_string(),
896 ));
897 }
898 self.nb_of_chqs.validate()?;
899 Ok(())
900 }
901}
902
903#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
905pub enum Max15NumericTextfixed {
906 #[default]
907 #[serde(rename = "1")]
908 Code1,
909}
910
911impl Max15NumericTextfixed {
912 pub fn validate(&self) -> Result<(), ValidationError> {
913 Ok(())
914 }
915}
916
917#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
919pub struct OrganisationIdentification291 {
920 #[serde(rename = "AnyBIC", skip_serializing_if = "Option::is_none")]
921 pub any_bic: Option<String>,
922 #[serde(rename = "LEI", skip_serializing_if = "Option::is_none")]
923 pub lei: Option<String>,
924 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
925 pub othr: Option<Vec<GenericOrganisationIdentification11>>,
926}
927
928impl OrganisationIdentification291 {
929 pub fn validate(&self) -> Result<(), ValidationError> {
930 if let Some(ref val) = self.any_bic {
931 let pattern =
932 Regex::new("[A-Z0-9]{4,4}[A-Z]{2,2}[A-Z0-9]{2,2}([A-Z0-9]{3,3}){0,1}").unwrap();
933 if !pattern.is_match(val) {
934 return Err(ValidationError::new(
935 1005,
936 "any_bic does not match the required pattern".to_string(),
937 ));
938 }
939 }
940 if let Some(ref val) = self.lei {
941 let pattern = Regex::new("[A-Z0-9]{18,18}[0-9]{2,2}").unwrap();
942 if !pattern.is_match(val) {
943 return Err(ValidationError::new(
944 1005,
945 "lei does not match the required pattern".to_string(),
946 ));
947 }
948 }
949 if let Some(ref vec) = self.othr {
950 for item in vec {
951 item.validate()?
952 }
953 }
954 Ok(())
955 }
956}
957
958#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
960pub struct OrganisationIdentificationSchemeName1Choice1 {
961 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
962 pub cd: Option<String>,
963 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
964 pub prtry: Option<String>,
965}
966
967impl OrganisationIdentificationSchemeName1Choice1 {
968 pub fn validate(&self) -> Result<(), ValidationError> {
969 if let Some(ref val) = self.cd {
970 if val.chars().count() < 1 {
971 return Err(ValidationError::new(
972 1001,
973 "cd is shorter than the minimum length of 1".to_string(),
974 ));
975 }
976 if val.chars().count() > 4 {
977 return Err(ValidationError::new(
978 1002,
979 "cd exceeds the maximum length of 4".to_string(),
980 ));
981 }
982 }
983 if let Some(ref val) = self.prtry {
984 if val.chars().count() < 1 {
985 return Err(ValidationError::new(
986 1001,
987 "prtry is shorter than the minimum length of 1".to_string(),
988 ));
989 }
990 if val.chars().count() > 35 {
991 return Err(ValidationError::new(
992 1002,
993 "prtry exceeds the maximum length of 35".to_string(),
994 ));
995 }
996 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
997 if !pattern.is_match(val) {
998 return Err(ValidationError::new(
999 1005,
1000 "prtry does not match the required pattern".to_string(),
1001 ));
1002 }
1003 }
1004 Ok(())
1005 }
1006}
1007
1008#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1010pub struct Party38Choice1 {
1011 #[serde(rename = "OrgId", skip_serializing_if = "Option::is_none")]
1012 pub org_id: Option<OrganisationIdentification291>,
1013 #[serde(rename = "PrvtId", skip_serializing_if = "Option::is_none")]
1014 pub prvt_id: Option<PersonIdentification131>,
1015}
1016
1017impl Party38Choice1 {
1018 pub fn validate(&self) -> Result<(), ValidationError> {
1019 if let Some(ref val) = self.org_id {
1020 val.validate()?
1021 }
1022 if let Some(ref val) = self.prvt_id {
1023 val.validate()?
1024 }
1025 Ok(())
1026 }
1027}
1028
1029#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1031pub struct PartyIdentification1351 {
1032 #[serde(rename = "Nm")]
1033 pub nm: String,
1034 #[serde(rename = "PstlAdr")]
1035 pub pstl_adr: PostalAddress241,
1036 #[serde(rename = "Id", skip_serializing_if = "Option::is_none")]
1037 pub id: Option<Party38Choice1>,
1038 #[serde(rename = "CtryOfRes", skip_serializing_if = "Option::is_none")]
1039 pub ctry_of_res: Option<String>,
1040}
1041
1042impl PartyIdentification1351 {
1043 pub fn validate(&self) -> Result<(), ValidationError> {
1044 if self.nm.chars().count() < 1 {
1045 return Err(ValidationError::new(
1046 1001,
1047 "nm is shorter than the minimum length of 1".to_string(),
1048 ));
1049 }
1050 if self.nm.chars().count() > 140 {
1051 return Err(ValidationError::new(
1052 1002,
1053 "nm exceeds the maximum length of 140".to_string(),
1054 ));
1055 }
1056 let pattern =
1057 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
1058 .unwrap();
1059 if !pattern.is_match(&self.nm) {
1060 return Err(ValidationError::new(
1061 1005,
1062 "nm does not match the required pattern".to_string(),
1063 ));
1064 }
1065 self.pstl_adr.validate()?;
1066 if let Some(ref val) = self.id {
1067 val.validate()?
1068 }
1069 if let Some(ref val) = self.ctry_of_res {
1070 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1071 if !pattern.is_match(val) {
1072 return Err(ValidationError::new(
1073 1005,
1074 "ctry_of_res does not match the required pattern".to_string(),
1075 ));
1076 }
1077 }
1078 Ok(())
1079 }
1080}
1081
1082#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1084pub struct PersonIdentification131 {
1085 #[serde(rename = "DtAndPlcOfBirth", skip_serializing_if = "Option::is_none")]
1086 pub dt_and_plc_of_birth: Option<DateAndPlaceOfBirth11>,
1087 #[serde(rename = "Othr", skip_serializing_if = "Option::is_none")]
1088 pub othr: Option<Vec<GenericPersonIdentification11>>,
1089}
1090
1091impl PersonIdentification131 {
1092 pub fn validate(&self) -> Result<(), ValidationError> {
1093 if let Some(ref val) = self.dt_and_plc_of_birth {
1094 val.validate()?
1095 }
1096 if let Some(ref vec) = self.othr {
1097 for item in vec {
1098 item.validate()?
1099 }
1100 }
1101 Ok(())
1102 }
1103}
1104
1105#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1107pub struct PersonIdentificationSchemeName1Choice1 {
1108 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1109 pub cd: Option<String>,
1110 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1111 pub prtry: Option<String>,
1112}
1113
1114impl PersonIdentificationSchemeName1Choice1 {
1115 pub fn validate(&self) -> Result<(), ValidationError> {
1116 if let Some(ref val) = self.cd {
1117 if val.chars().count() < 1 {
1118 return Err(ValidationError::new(
1119 1001,
1120 "cd is shorter than the minimum length of 1".to_string(),
1121 ));
1122 }
1123 if val.chars().count() > 4 {
1124 return Err(ValidationError::new(
1125 1002,
1126 "cd exceeds the maximum length of 4".to_string(),
1127 ));
1128 }
1129 }
1130 if let Some(ref val) = self.prtry {
1131 if val.chars().count() < 1 {
1132 return Err(ValidationError::new(
1133 1001,
1134 "prtry is shorter than the minimum length of 1".to_string(),
1135 ));
1136 }
1137 if val.chars().count() > 35 {
1138 return Err(ValidationError::new(
1139 1002,
1140 "prtry exceeds the maximum length of 35".to_string(),
1141 ));
1142 }
1143 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1144 if !pattern.is_match(val) {
1145 return Err(ValidationError::new(
1146 1005,
1147 "prtry does not match the required pattern".to_string(),
1148 ));
1149 }
1150 }
1151 Ok(())
1152 }
1153}
1154
1155#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1157pub struct PostalAddress241 {
1158 #[serde(rename = "Dept", skip_serializing_if = "Option::is_none")]
1159 pub dept: Option<String>,
1160 #[serde(rename = "SubDept", skip_serializing_if = "Option::is_none")]
1161 pub sub_dept: Option<String>,
1162 #[serde(rename = "StrtNm", skip_serializing_if = "Option::is_none")]
1163 pub strt_nm: Option<String>,
1164 #[serde(rename = "BldgNb", skip_serializing_if = "Option::is_none")]
1165 pub bldg_nb: Option<String>,
1166 #[serde(rename = "BldgNm", skip_serializing_if = "Option::is_none")]
1167 pub bldg_nm: Option<String>,
1168 #[serde(rename = "Flr", skip_serializing_if = "Option::is_none")]
1169 pub flr: Option<String>,
1170 #[serde(rename = "PstBx", skip_serializing_if = "Option::is_none")]
1171 pub pst_bx: Option<String>,
1172 #[serde(rename = "Room", skip_serializing_if = "Option::is_none")]
1173 pub room: Option<String>,
1174 #[serde(rename = "PstCd", skip_serializing_if = "Option::is_none")]
1175 pub pst_cd: Option<String>,
1176 #[serde(rename = "TwnNm", skip_serializing_if = "Option::is_none")]
1177 pub twn_nm: Option<String>,
1178 #[serde(rename = "TwnLctnNm", skip_serializing_if = "Option::is_none")]
1179 pub twn_lctn_nm: Option<String>,
1180 #[serde(rename = "DstrctNm", skip_serializing_if = "Option::is_none")]
1181 pub dstrct_nm: Option<String>,
1182 #[serde(rename = "CtrySubDvsn", skip_serializing_if = "Option::is_none")]
1183 pub ctry_sub_dvsn: Option<String>,
1184 #[serde(rename = "Ctry", skip_serializing_if = "Option::is_none")]
1185 pub ctry: Option<String>,
1186 #[serde(rename = "AdrLine", skip_serializing_if = "Option::is_none")]
1187 pub adr_line: Option<Vec<String>>,
1188}
1189
1190impl PostalAddress241 {
1191 pub fn validate(&self) -> Result<(), ValidationError> {
1192 if let Some(ref val) = self.dept {
1193 if val.chars().count() < 1 {
1194 return Err(ValidationError::new(
1195 1001,
1196 "dept is shorter than the minimum length of 1".to_string(),
1197 ));
1198 }
1199 if val.chars().count() > 70 {
1200 return Err(ValidationError::new(
1201 1002,
1202 "dept exceeds the maximum length of 70".to_string(),
1203 ));
1204 }
1205 let pattern = Regex::new(
1206 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1207 )
1208 .unwrap();
1209 if !pattern.is_match(val) {
1210 return Err(ValidationError::new(
1211 1005,
1212 "dept does not match the required pattern".to_string(),
1213 ));
1214 }
1215 }
1216 if let Some(ref val) = self.sub_dept {
1217 if val.chars().count() < 1 {
1218 return Err(ValidationError::new(
1219 1001,
1220 "sub_dept is shorter than the minimum length of 1".to_string(),
1221 ));
1222 }
1223 if val.chars().count() > 70 {
1224 return Err(ValidationError::new(
1225 1002,
1226 "sub_dept exceeds the maximum length of 70".to_string(),
1227 ));
1228 }
1229 let pattern = Regex::new(
1230 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1231 )
1232 .unwrap();
1233 if !pattern.is_match(val) {
1234 return Err(ValidationError::new(
1235 1005,
1236 "sub_dept does not match the required pattern".to_string(),
1237 ));
1238 }
1239 }
1240 if let Some(ref val) = self.strt_nm {
1241 if val.chars().count() < 1 {
1242 return Err(ValidationError::new(
1243 1001,
1244 "strt_nm is shorter than the minimum length of 1".to_string(),
1245 ));
1246 }
1247 if val.chars().count() > 70 {
1248 return Err(ValidationError::new(
1249 1002,
1250 "strt_nm exceeds the maximum length of 70".to_string(),
1251 ));
1252 }
1253 let pattern = Regex::new(
1254 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1255 )
1256 .unwrap();
1257 if !pattern.is_match(val) {
1258 return Err(ValidationError::new(
1259 1005,
1260 "strt_nm does not match the required pattern".to_string(),
1261 ));
1262 }
1263 }
1264 if let Some(ref val) = self.bldg_nb {
1265 if val.chars().count() < 1 {
1266 return Err(ValidationError::new(
1267 1001,
1268 "bldg_nb is shorter than the minimum length of 1".to_string(),
1269 ));
1270 }
1271 if val.chars().count() > 16 {
1272 return Err(ValidationError::new(
1273 1002,
1274 "bldg_nb exceeds the maximum length of 16".to_string(),
1275 ));
1276 }
1277 let pattern = Regex::new(
1278 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1279 )
1280 .unwrap();
1281 if !pattern.is_match(val) {
1282 return Err(ValidationError::new(
1283 1005,
1284 "bldg_nb does not match the required pattern".to_string(),
1285 ));
1286 }
1287 }
1288 if let Some(ref val) = self.bldg_nm {
1289 if val.chars().count() < 1 {
1290 return Err(ValidationError::new(
1291 1001,
1292 "bldg_nm is shorter than the minimum length of 1".to_string(),
1293 ));
1294 }
1295 if val.chars().count() > 35 {
1296 return Err(ValidationError::new(
1297 1002,
1298 "bldg_nm exceeds the maximum length of 35".to_string(),
1299 ));
1300 }
1301 let pattern = Regex::new(
1302 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1303 )
1304 .unwrap();
1305 if !pattern.is_match(val) {
1306 return Err(ValidationError::new(
1307 1005,
1308 "bldg_nm does not match the required pattern".to_string(),
1309 ));
1310 }
1311 }
1312 if let Some(ref val) = self.flr {
1313 if val.chars().count() < 1 {
1314 return Err(ValidationError::new(
1315 1001,
1316 "flr is shorter than the minimum length of 1".to_string(),
1317 ));
1318 }
1319 if val.chars().count() > 70 {
1320 return Err(ValidationError::new(
1321 1002,
1322 "flr exceeds the maximum length of 70".to_string(),
1323 ));
1324 }
1325 let pattern = Regex::new(
1326 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1327 )
1328 .unwrap();
1329 if !pattern.is_match(val) {
1330 return Err(ValidationError::new(
1331 1005,
1332 "flr does not match the required pattern".to_string(),
1333 ));
1334 }
1335 }
1336 if let Some(ref val) = self.pst_bx {
1337 if val.chars().count() < 1 {
1338 return Err(ValidationError::new(
1339 1001,
1340 "pst_bx is shorter than the minimum length of 1".to_string(),
1341 ));
1342 }
1343 if val.chars().count() > 16 {
1344 return Err(ValidationError::new(
1345 1002,
1346 "pst_bx exceeds the maximum length of 16".to_string(),
1347 ));
1348 }
1349 let pattern = Regex::new(
1350 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1351 )
1352 .unwrap();
1353 if !pattern.is_match(val) {
1354 return Err(ValidationError::new(
1355 1005,
1356 "pst_bx does not match the required pattern".to_string(),
1357 ));
1358 }
1359 }
1360 if let Some(ref val) = self.room {
1361 if val.chars().count() < 1 {
1362 return Err(ValidationError::new(
1363 1001,
1364 "room is shorter than the minimum length of 1".to_string(),
1365 ));
1366 }
1367 if val.chars().count() > 70 {
1368 return Err(ValidationError::new(
1369 1002,
1370 "room exceeds the maximum length of 70".to_string(),
1371 ));
1372 }
1373 let pattern = Regex::new(
1374 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1375 )
1376 .unwrap();
1377 if !pattern.is_match(val) {
1378 return Err(ValidationError::new(
1379 1005,
1380 "room does not match the required pattern".to_string(),
1381 ));
1382 }
1383 }
1384 if let Some(ref val) = self.pst_cd {
1385 if val.chars().count() < 1 {
1386 return Err(ValidationError::new(
1387 1001,
1388 "pst_cd is shorter than the minimum length of 1".to_string(),
1389 ));
1390 }
1391 if val.chars().count() > 16 {
1392 return Err(ValidationError::new(
1393 1002,
1394 "pst_cd exceeds the maximum length of 16".to_string(),
1395 ));
1396 }
1397 let pattern = Regex::new(
1398 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1399 )
1400 .unwrap();
1401 if !pattern.is_match(val) {
1402 return Err(ValidationError::new(
1403 1005,
1404 "pst_cd does not match the required pattern".to_string(),
1405 ));
1406 }
1407 }
1408 if let Some(ref val) = self.twn_nm {
1409 if val.chars().count() < 1 {
1410 return Err(ValidationError::new(
1411 1001,
1412 "twn_nm is shorter than the minimum length of 1".to_string(),
1413 ));
1414 }
1415 if val.chars().count() > 35 {
1416 return Err(ValidationError::new(
1417 1002,
1418 "twn_nm exceeds the maximum length of 35".to_string(),
1419 ));
1420 }
1421 let pattern = Regex::new(
1422 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1423 )
1424 .unwrap();
1425 if !pattern.is_match(val) {
1426 return Err(ValidationError::new(
1427 1005,
1428 "twn_nm does not match the required pattern".to_string(),
1429 ));
1430 }
1431 }
1432 if let Some(ref val) = self.twn_lctn_nm {
1433 if val.chars().count() < 1 {
1434 return Err(ValidationError::new(
1435 1001,
1436 "twn_lctn_nm is shorter than the minimum length of 1".to_string(),
1437 ));
1438 }
1439 if val.chars().count() > 35 {
1440 return Err(ValidationError::new(
1441 1002,
1442 "twn_lctn_nm exceeds the maximum length of 35".to_string(),
1443 ));
1444 }
1445 let pattern = Regex::new(
1446 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1447 )
1448 .unwrap();
1449 if !pattern.is_match(val) {
1450 return Err(ValidationError::new(
1451 1005,
1452 "twn_lctn_nm does not match the required pattern".to_string(),
1453 ));
1454 }
1455 }
1456 if let Some(ref val) = self.dstrct_nm {
1457 if val.chars().count() < 1 {
1458 return Err(ValidationError::new(
1459 1001,
1460 "dstrct_nm is shorter than the minimum length of 1".to_string(),
1461 ));
1462 }
1463 if val.chars().count() > 35 {
1464 return Err(ValidationError::new(
1465 1002,
1466 "dstrct_nm exceeds the maximum length of 35".to_string(),
1467 ));
1468 }
1469 let pattern = Regex::new(
1470 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1471 )
1472 .unwrap();
1473 if !pattern.is_match(val) {
1474 return Err(ValidationError::new(
1475 1005,
1476 "dstrct_nm does not match the required pattern".to_string(),
1477 ));
1478 }
1479 }
1480 if let Some(ref val) = self.ctry_sub_dvsn {
1481 if val.chars().count() < 1 {
1482 return Err(ValidationError::new(
1483 1001,
1484 "ctry_sub_dvsn is shorter than the minimum length of 1".to_string(),
1485 ));
1486 }
1487 if val.chars().count() > 35 {
1488 return Err(ValidationError::new(
1489 1002,
1490 "ctry_sub_dvsn exceeds the maximum length of 35".to_string(),
1491 ));
1492 }
1493 let pattern = Regex::new(
1494 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1495 )
1496 .unwrap();
1497 if !pattern.is_match(val) {
1498 return Err(ValidationError::new(
1499 1005,
1500 "ctry_sub_dvsn does not match the required pattern".to_string(),
1501 ));
1502 }
1503 }
1504 if let Some(ref val) = self.ctry {
1505 let pattern = Regex::new("[A-Z]{2,2}").unwrap();
1506 if !pattern.is_match(val) {
1507 return Err(ValidationError::new(
1508 1005,
1509 "ctry does not match the required pattern".to_string(),
1510 ));
1511 }
1512 }
1513 if let Some(ref vec) = self.adr_line {
1514 for item in vec {
1515 if item.chars().count() < 1 {
1516 return Err(ValidationError::new(
1517 1001,
1518 "adr_line is shorter than the minimum length of 1".to_string(),
1519 ));
1520 }
1521 if item.chars().count() > 70 {
1522 return Err(ValidationError::new(
1523 1002,
1524 "adr_line exceeds the maximum length of 70".to_string(),
1525 ));
1526 }
1527 let pattern = Regex::new(
1528 "[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+",
1529 )
1530 .unwrap();
1531 if !pattern.is_match(&item) {
1532 return Err(ValidationError::new(
1533 1005,
1534 "adr_line does not match the required pattern".to_string(),
1535 ));
1536 }
1537 }
1538 }
1539 Ok(())
1540 }
1541}
1542
1543#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1545pub struct ProxyAccountIdentification11 {
1546 #[serde(rename = "Tp", skip_serializing_if = "Option::is_none")]
1547 pub tp: Option<ProxyAccountType1Choice1>,
1548 #[serde(rename = "Id")]
1549 pub id: String,
1550}
1551
1552impl ProxyAccountIdentification11 {
1553 pub fn validate(&self) -> Result<(), ValidationError> {
1554 if let Some(ref val) = self.tp {
1555 val.validate()?
1556 }
1557 if self.id.chars().count() < 1 {
1558 return Err(ValidationError::new(
1559 1001,
1560 "id is shorter than the minimum length of 1".to_string(),
1561 ));
1562 }
1563 if self.id.chars().count() > 320 {
1564 return Err(ValidationError::new(
1565 1002,
1566 "id exceeds the maximum length of 320".to_string(),
1567 ));
1568 }
1569 let pattern =
1570 Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ !#$%&\\*=^_`\\{\\|\\}~\";<>@\\[\\\\\\]]+")
1571 .unwrap();
1572 if !pattern.is_match(&self.id) {
1573 return Err(ValidationError::new(
1574 1005,
1575 "id does not match the required pattern".to_string(),
1576 ));
1577 }
1578 Ok(())
1579 }
1580}
1581
1582#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
1584pub struct ProxyAccountType1Choice1 {
1585 #[serde(rename = "Cd", skip_serializing_if = "Option::is_none")]
1586 pub cd: Option<String>,
1587 #[serde(rename = "Prtry", skip_serializing_if = "Option::is_none")]
1588 pub prtry: Option<String>,
1589}
1590
1591impl ProxyAccountType1Choice1 {
1592 pub fn validate(&self) -> Result<(), ValidationError> {
1593 if let Some(ref val) = self.cd {
1594 if val.chars().count() < 1 {
1595 return Err(ValidationError::new(
1596 1001,
1597 "cd is shorter than the minimum length of 1".to_string(),
1598 ));
1599 }
1600 if val.chars().count() > 4 {
1601 return Err(ValidationError::new(
1602 1002,
1603 "cd exceeds the maximum length of 4".to_string(),
1604 ));
1605 }
1606 }
1607 if let Some(ref val) = self.prtry {
1608 if val.chars().count() < 1 {
1609 return Err(ValidationError::new(
1610 1001,
1611 "prtry is shorter than the minimum length of 1".to_string(),
1612 ));
1613 }
1614 if val.chars().count() > 35 {
1615 return Err(ValidationError::new(
1616 1002,
1617 "prtry exceeds the maximum length of 35".to_string(),
1618 ));
1619 }
1620 let pattern = Regex::new("[0-9a-zA-Z/\\-\\?:\\(\\)\\.,'\\+ ]+").unwrap();
1621 if !pattern.is_match(val) {
1622 return Err(ValidationError::new(
1623 1005,
1624 "prtry does not match the required pattern".to_string(),
1625 ));
1626 }
1627 }
1628 Ok(())
1629 }
1630}