rust_iso20022 0.1.1

ISO 20022 message definitions and external code sets for Rust, generated from the official XSD schemas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
// @generated by src/bin/codegen.rs from the ISO 20022 XSD schema. Do not edit.
#![allow(clippy::all)]
#![allow(non_snake_case, non_camel_case_types, dead_code, unused_imports)]
// yaserde_derive 0.7 emits trait impls inside nested choice submodules, which
// trips the `non_local_definitions` lint on recent rustc. The generated code is
// correct; silence the lint here.
#![allow(non_local_definitions)]
use std::str::FromStr;
use crate::validate::Validate;
use yaserde_derive::{YaDeserialize, YaSerialize};

// pub type Document = Document;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct ActiveCurrencyCode (pub String);
crate::simple_type!(ActiveCurrencyCode);

impl Validate for ActiveCurrencyCode {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct ActiveOrHistoricCurrencyCode (pub String);
crate::simple_type!(ActiveOrHistoricCurrencyCode);

impl Validate for ActiveOrHistoricCurrencyCode {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct AmountAndDirection67 {
    #[yaserde(rename = "Amt")]
    #[cfg_attr(feature = "serde", serde(rename = "Amt"))]
    pub amt: RestrictedFINActiveCurrencyAndAmount,

    #[yaserde(rename = "CdtDbtInd")]
    #[cfg_attr(feature = "serde", serde(rename = "CdtDbtInd"))]
    pub cdt_dbt_ind: CreditDebitCode,

    #[yaserde(rename = "OrgnlCcyAndOrdrdAmt")]
    #[cfg_attr(feature = "serde", serde(rename = "OrgnlCcyAndOrdrdAmt"))]
    pub orgnl_ccy_and_ordrd_amt: RestrictedFINActiveOrHistoricCurrencyAndAmount,
}

impl Validate for AmountAndDirection67 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct AnyBICDec2014Identifier (pub String);
crate::simple_type!(AnyBICDec2014Identifier);

impl Validate for AnyBICDec2014Identifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct BlockChainAddressWallet7 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: RestrictedFINXMax140Text,

    #[yaserde(rename = "Tp")]
    #[cfg_attr(feature = "serde", serde(rename = "Tp"))]
    pub tp: GenericIdentification47,

    #[yaserde(rename = "Nm")]
    #[cfg_attr(feature = "serde", serde(rename = "Nm"))]
    pub nm: RestrictedFINXMax70Text,
}

impl Validate for BlockChainAddressWallet7 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct ConsentOrRejectionReason5Choice {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: Option<CounterpartyResponseStatusReason1Code>,
    #[yaserde(rename = "Prtry")]
    #[cfg_attr(feature = "serde", serde(rename = "Prtry"))]
    pub prtry: Option<GenericIdentification47>,
}

impl Validate for ConsentOrRejectionReason5Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct ConsentReason5 {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: ConsentOrRejectionReason5Choice,

    #[yaserde(rename = "AddtlRsnInf")]
    #[cfg_attr(feature = "serde", serde(rename = "AddtlRsnInf"))]
    pub addtl_rsn_inf: RestrictedFINXMax210Text,
}

impl Validate for ConsentReason5 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct ConsentStatus5Choice {
    #[yaserde(rename = "NoSpcfdRsn")]
    #[cfg_attr(feature = "serde", serde(rename = "NoSpcfdRsn"))]
    pub no_spcfd_rsn: Option<NoReasonCode>,
    #[yaserde(rename = "Rsn")]
    #[cfg_attr(feature = "serde", serde(rename = "Rsn"))]
    pub rsn: Vec<ConsentReason5>,
}

impl Validate for ConsentStatus5Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum CounterpartyResponseStatusReason1Code {
    #[yaserde(rename = "CPTR")]
    #[cfg_attr(feature = "serde", serde(rename = "CPTR"))]
    Cptr,
    #[yaserde(rename = "CPCX")]
    #[cfg_attr(feature = "serde", serde(rename = "CPCX"))]
    Cpcx,
    #[yaserde(rename = "CPMD")]
    #[cfg_attr(feature = "serde", serde(rename = "CPMD"))]
    Cpmd,
    __Unknown__(String),
}

impl Default for CounterpartyResponseStatusReason1Code {
    fn default() -> CounterpartyResponseStatusReason1Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for CounterpartyResponseStatusReason1Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct CountryCode (pub String);
crate::simple_type!(CountryCode);

impl Validate for CountryCode {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum CreditDebitCode {
    #[yaserde(rename = "CRDT")]
    #[cfg_attr(feature = "serde", serde(rename = "CRDT"))]
    Crdt,
    #[yaserde(rename = "DBIT")]
    #[cfg_attr(feature = "serde", serde(rename = "DBIT"))]
    Dbit,
    __Unknown__(String),
}

impl Default for CreditDebitCode {
    fn default() -> CreditDebitCode {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for CreditDebitCode {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct DateAndDateTime2Choice {
    #[yaserde(rename = "Dt")]
    #[cfg_attr(feature = "serde", serde(rename = "Dt"))]
    pub dt: Option<Isodate>,
    #[yaserde(rename = "DtTm")]
    #[cfg_attr(feature = "serde", serde(rename = "DtTm"))]
    pub dt_tm: Option<IsodateTime>,
}

impl Validate for DateAndDateTime2Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum DateType3Code {
    #[yaserde(rename = "VARI")]
    #[cfg_attr(feature = "serde", serde(rename = "VARI"))]
    Vari,
    __Unknown__(String),
}

impl Default for DateType3Code {
    fn default() -> DateType3Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for DateType3Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum DateType4Code {
    #[yaserde(rename = "OPEN")]
    #[cfg_attr(feature = "serde", serde(rename = "OPEN"))]
    Open,
    #[yaserde(rename = "UKWN")]
    #[cfg_attr(feature = "serde", serde(rename = "UKWN"))]
    Ukwn,
    __Unknown__(String),
}

impl Default for DateType4Code {
    fn default() -> DateType4Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for DateType4Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum DeliveryReceiptType2Code {
    #[yaserde(rename = "FREE")]
    #[cfg_attr(feature = "serde", serde(rename = "FREE"))]
    Free,
    #[yaserde(rename = "APMT")]
    #[cfg_attr(feature = "serde", serde(rename = "APMT"))]
    Apmt,
    __Unknown__(String),
}

impl Default for DeliveryReceiptType2Code {
    fn default() -> DeliveryReceiptType2Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for DeliveryReceiptType2Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct Document {
    #[yaserde(rename = "SctiesSttlmTxCtrPtyRspn")]
    #[cfg_attr(feature = "serde", serde(rename = "SctiesSttlmTxCtrPtyRspn"))]
    pub scties_sttlm_tx_ctr_pty_rspn: SecuritiesSettlementTransactionCounterpartyResponse002V04,
}

impl Validate for Document {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Exact4AlphaNumericText (pub String);
crate::simple_type!(Exact4AlphaNumericText);

impl Validate for Exact4AlphaNumericText {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct ExternalFinancialInstrumentIdentificationType1Code (pub String);
crate::simple_type!(ExternalFinancialInstrumentIdentificationType1Code);

impl Validate for ExternalFinancialInstrumentIdentificationType1Code {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 4 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 4 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct FinancialInstrumentQuantity36Choice {
    #[yaserde(rename = "Unit")]
    #[cfg_attr(feature = "serde", serde(rename = "Unit"))]
    pub unit: Option<RestrictedFINDecimalNumber>,
    #[yaserde(rename = "FaceAmt")]
    #[cfg_attr(feature = "serde", serde(rename = "FaceAmt"))]
    pub face_amt: Option<RestrictedFINImpliedCurrencyAndAmount>,
    #[yaserde(rename = "AmtsdVal")]
    #[cfg_attr(feature = "serde", serde(rename = "AmtsdVal"))]
    pub amtsd_val: Option<RestrictedFINImpliedCurrencyAndAmount>,
    #[yaserde(rename = "DgtlTknUnit")]
    #[cfg_attr(feature = "serde", serde(rename = "DgtlTknUnit"))]
    pub dgtl_tkn_unit: Option<Max30DecimalNumber>,
}

impl Validate for FinancialInstrumentQuantity36Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct GenericIdentification47 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: Exact4AlphaNumericText,

    #[yaserde(rename = "Issr")]
    #[cfg_attr(feature = "serde", serde(rename = "Issr"))]
    pub issr: Max4AlphaNumericText,

    #[yaserde(rename = "SchmeNm")]
    #[cfg_attr(feature = "serde", serde(rename = "SchmeNm"))]
    pub schme_nm: Max4AlphaNumericText,
}

impl Validate for GenericIdentification47 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct GenericIdentification84 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: RestrictedFINXMax34Text,

    #[yaserde(rename = "Issr")]
    #[cfg_attr(feature = "serde", serde(rename = "Issr"))]
    pub issr: Max4AlphaNumericText,

    #[yaserde(rename = "SchmeNm")]
    #[cfg_attr(feature = "serde", serde(rename = "SchmeNm"))]
    pub schme_nm: Max4AlphaNumericText,
}

impl Validate for GenericIdentification84 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Isinoct2015Identifier (pub String);
crate::simple_type!(Isinoct2015Identifier);

impl Validate for Isinoct2015Identifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Isodate (pub String);
crate::simple_type!(Isodate);

impl Validate for Isodate {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct IsodateTime (pub String);
crate::simple_type!(IsodateTime);

impl Validate for IsodateTime {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct IdentificationSource4Choice {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: Option<ExternalFinancialInstrumentIdentificationType1Code>,
    #[yaserde(rename = "Prtry")]
    #[cfg_attr(feature = "serde", serde(rename = "Prtry"))]
    pub prtry: Option<RestrictedFINExact2Text>,
}

impl Validate for IdentificationSource4Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Leiidentifier (pub String);
crate::simple_type!(Leiidentifier);

impl Validate for Leiidentifier {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max16Text (pub String);
crate::simple_type!(Max16Text);

impl Validate for Max16Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 16 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 16 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max30DecimalNumber (pub String);
crate::simple_type!(Max30DecimalNumber);

impl Validate for Max30DecimalNumber {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max350Text (pub String);
crate::simple_type!(Max350Text);

impl Validate for Max350Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 350 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 350 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max4AlphaNumericText (pub String);
crate::simple_type!(Max4AlphaNumericText);

impl Validate for Max4AlphaNumericText {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 4 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 4 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct Max70Text (pub String);
crate::simple_type!(Max70Text);

impl Validate for Max70Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 70 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 70 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct NameAndAddress12 {
    #[yaserde(rename = "Nm")]
    #[cfg_attr(feature = "serde", serde(rename = "Nm"))]
    pub nm: RestrictedFINXMax140Text,
}

impl Validate for NameAndAddress12 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum NoReasonCode {
    #[yaserde(rename = "NORE")]
    #[cfg_attr(feature = "serde", serde(rename = "NORE"))]
    Nore,
    __Unknown__(String),
}

impl Default for NoReasonCode {
    fn default() -> NoReasonCode {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for NoReasonCode {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct NoSpecifiedReason1 {
    #[yaserde(rename = "NoSpcfdRsn")]
    #[cfg_attr(feature = "serde", serde(rename = "NoSpcfdRsn"))]
    pub no_spcfd_rsn: NoReasonCode,
}

impl Validate for NoSpecifiedReason1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct OriginalAndCurrentQuantities4 {
    #[yaserde(rename = "FaceAmt")]
    #[cfg_attr(feature = "serde", serde(rename = "FaceAmt"))]
    pub face_amt: RestrictedFINImpliedCurrencyAndAmount,

    #[yaserde(rename = "AmtsdVal")]
    #[cfg_attr(feature = "serde", serde(rename = "AmtsdVal"))]
    pub amtsd_val: RestrictedFINImpliedCurrencyAndAmount,
}

impl Validate for OriginalAndCurrentQuantities4 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct OtherIdentification2 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: RestrictedFINXMax31Text,

    #[yaserde(rename = "Sfx")]
    #[cfg_attr(feature = "serde", serde(rename = "Sfx"))]
    pub sfx: Max16Text,

    #[yaserde(rename = "Tp")]
    #[cfg_attr(feature = "serde", serde(rename = "Tp"))]
    pub tp: IdentificationSource4Choice,
}

impl Validate for OtherIdentification2 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentification137Choice {
    #[yaserde(rename = "AnyBIC")]
    #[cfg_attr(feature = "serde", serde(rename = "AnyBIC"))]
    pub any_b_i_c: Option<AnyBICDec2014Identifier>,
    #[yaserde(rename = "PrtryId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrtryId"))]
    pub prtry_id: Option<GenericIdentification84>,
    #[yaserde(rename = "NmAndAdr")]
    #[cfg_attr(feature = "serde", serde(rename = "NmAndAdr"))]
    pub nm_and_adr: Option<NameAndAddress12>,
}

impl Validate for PartyIdentification137Choice {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentification145Choice {
    #[yaserde(rename = "AnyBIC")]
    #[cfg_attr(feature = "serde", serde(rename = "AnyBIC"))]
    pub any_b_i_c: Option<AnyBICDec2014Identifier>,
    #[yaserde(rename = "NmAndAdr")]
    #[cfg_attr(feature = "serde", serde(rename = "NmAndAdr"))]
    pub nm_and_adr: Option<NameAndAddress12>,
    #[yaserde(rename = "Ctry")]
    #[cfg_attr(feature = "serde", serde(rename = "Ctry"))]
    pub ctry: Option<CountryCode>,
}

impl Validate for PartyIdentification145Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentification170 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: PartyIdentification176Choice,

    #[yaserde(rename = "LEI")]
    #[cfg_attr(feature = "serde", serde(rename = "LEI"))]
    pub lei: Leiidentifier,
}

impl Validate for PartyIdentification170 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentification176Choice {
    #[yaserde(rename = "AnyBIC")]
    #[cfg_attr(feature = "serde", serde(rename = "AnyBIC"))]
    pub any_b_i_c: Option<AnyBICDec2014Identifier>,
    #[yaserde(rename = "PrtryId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrtryId"))]
    pub prtry_id: Option<GenericIdentification84>,
    #[yaserde(rename = "NmAndAdr")]
    #[cfg_attr(feature = "serde", serde(rename = "NmAndAdr"))]
    pub nm_and_adr: Option<NameAndAddress12>,
    #[yaserde(rename = "Ctry")]
    #[cfg_attr(feature = "serde", serde(rename = "Ctry"))]
    pub ctry: Option<CountryCode>,
}

impl Validate for PartyIdentification176Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentification191 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: PartyIdentification145Choice,

    #[yaserde(rename = "LEI")]
    #[cfg_attr(feature = "serde", serde(rename = "LEI"))]
    pub lei: Leiidentifier,

    #[yaserde(rename = "PrcgId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrcgId"))]
    pub prcg_id: RestrictedFINXMax16Text,
}

impl Validate for PartyIdentification191 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PartyIdentificationAndAccount215 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: PartyIdentification137Choice,

    #[yaserde(rename = "LEI")]
    #[cfg_attr(feature = "serde", serde(rename = "LEI"))]
    pub lei: Leiidentifier,

    #[yaserde(rename = "SfkpgAcct")]
    #[cfg_attr(feature = "serde", serde(rename = "SfkpgAcct"))]
    pub sfkpg_acct: SecuritiesAccount30,

    #[yaserde(rename = "BlckChainAdrOrWllt")]
    #[cfg_attr(feature = "serde", serde(rename = "BlckChainAdrOrWllt"))]
    pub blck_chain_adr_or_wllt: BlockChainAddressWallet7,

    #[yaserde(rename = "PrcgId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrcgId"))]
    pub prcg_id: RestrictedFINXMax16Text,
}

impl Validate for PartyIdentificationAndAccount215 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct PendingStatus20Choice {
    #[yaserde(rename = "Fwdd")]
    #[cfg_attr(feature = "serde", serde(rename = "Fwdd"))]
    pub fwdd: Option<NoSpecifiedReason1>,
    #[yaserde(rename = "UdrInvstgtn")]
    #[cfg_attr(feature = "serde", serde(rename = "UdrInvstgtn"))]
    pub udr_invstgtn: Option<NoSpecifiedReason1>,
}

impl Validate for PendingStatus20Choice {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct Quantity54Choice {
    #[yaserde(rename = "Qty")]
    #[cfg_attr(feature = "serde", serde(rename = "Qty"))]
    pub qty: Option<FinancialInstrumentQuantity36Choice>,
    #[yaserde(rename = "OrgnlAndCurFace")]
    #[cfg_attr(feature = "serde", serde(rename = "OrgnlAndCurFace"))]
    pub orgnl_and_cur_face: Option<OriginalAndCurrentQuantities4>,
}

impl Validate for Quantity54Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Debug, Clone, YaSerialize, YaDeserialize)]#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]

pub enum ReceiveDelivery1Code {
    #[yaserde(rename = "DELI")]
    #[cfg_attr(feature = "serde", serde(rename = "DELI"))]
    Deli,
    #[yaserde(rename = "RECE")]
    #[cfg_attr(feature = "serde", serde(rename = "RECE"))]
    Rece,
    __Unknown__(String),
}

impl Default for ReceiveDelivery1Code {
    fn default() -> ReceiveDelivery1Code {
        Self::__Unknown__("No valid variants".into())
    }
}

impl Validate for ReceiveDelivery1Code {}



#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct RejectionReason40 {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: ConsentOrRejectionReason5Choice,

    #[yaserde(rename = "AddtlRsnInf")]
    #[cfg_attr(feature = "serde", serde(rename = "AddtlRsnInf"))]
    pub addtl_rsn_inf: RestrictedFINXMax210Text,
}

impl Validate for RejectionReason40 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct RejectionStatus27Choice {
    #[yaserde(rename = "NoSpcfdRsn")]
    #[cfg_attr(feature = "serde", serde(rename = "NoSpcfdRsn"))]
    pub no_spcfd_rsn: Option<NoReasonCode>,
    #[yaserde(rename = "Rsn")]
    #[cfg_attr(feature = "serde", serde(rename = "Rsn"))]
    pub rsn: Option<RejectionReason40>,
}

impl Validate for RejectionStatus27Choice {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct ResponseStatus8Choice {
    #[yaserde(rename = "Cnsntd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cnsntd"))]
    pub cnsntd: Option<ConsentStatus5Choice>,
    #[yaserde(rename = "Rjctd")]
    #[cfg_attr(feature = "serde", serde(rename = "Rjctd"))]
    pub rjctd: Option<RejectionStatus27Choice>,
    #[yaserde(rename = "Pdg")]
    #[cfg_attr(feature = "serde", serde(rename = "Pdg"))]
    pub pdg: Option<PendingStatus20Choice>,
}

impl Validate for ResponseStatus8Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINActiveCurrencyAndAmountSimpleType (pub String);
crate::simple_type!(RestrictedFINActiveCurrencyAndAmountSimpleType);

impl Validate for RestrictedFINActiveCurrencyAndAmountSimpleType {
    fn validate(&self) -> Result<(), String> { 
        if self.0 < "0".parse::<String>().unwrap() {
            return Err(format!("MinInclusive validation error: invalid value of 0! \nExpected: 0 >= 0.\nActual: 0 == {}", self.0));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct RestrictedFINActiveCurrencyAndAmount {
    #[yaserde(text)]
    pub value: String,
    #[yaserde(attribute, rename = "Ccy")]
    #[cfg_attr(feature = "serde", serde(rename = "Ccy"))]
    pub ccy: ActiveCurrencyCode,
}

impl Validate for RestrictedFINActiveCurrencyAndAmount {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINActiveOrHistoricCurrencyAndAmountSimpleType (pub String);
crate::simple_type!(RestrictedFINActiveOrHistoricCurrencyAndAmountSimpleType);

impl Validate for RestrictedFINActiveOrHistoricCurrencyAndAmountSimpleType {
    fn validate(&self) -> Result<(), String> { 
        if self.0 < "0".parse::<String>().unwrap() {
            return Err(format!("MinInclusive validation error: invalid value of 0! \nExpected: 0 >= 0.\nActual: 0 == {}", self.0));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct RestrictedFINActiveOrHistoricCurrencyAndAmount {
    #[yaserde(text)]
    pub value: String,
    #[yaserde(attribute, rename = "Ccy")]
    #[cfg_attr(feature = "serde", serde(rename = "Ccy"))]
    pub ccy: ActiveOrHistoricCurrencyCode,
}

impl Validate for RestrictedFINActiveOrHistoricCurrencyAndAmount {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINDecimalNumber (pub String);
crate::simple_type!(RestrictedFINDecimalNumber);

impl Validate for RestrictedFINDecimalNumber {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINExact2Text (pub String);
crate::simple_type!(RestrictedFINExact2Text);

impl Validate for RestrictedFINExact2Text {
    fn validate(&self) -> Result<(), String> { 
        if self.0.len() != 2 {
            return Err(format!("Length validation error. \nExpected: 0 length == 2 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINImpliedCurrencyAndAmount (pub String);
crate::simple_type!(RestrictedFINImpliedCurrencyAndAmount);

impl Validate for RestrictedFINImpliedCurrencyAndAmount {
    fn validate(&self) -> Result<(), String> { 
        if self.0 < "0".parse::<String>().unwrap() {
            return Err(format!("MinInclusive validation error: invalid value of 0! \nExpected: 0 >= 0.\nActual: 0 == {}", self.0));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax140Text (pub String);
crate::simple_type!(RestrictedFINXMax140Text);

impl Validate for RestrictedFINXMax140Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 140 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 140 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax16Text (pub String);
crate::simple_type!(RestrictedFINXMax16Text);

impl Validate for RestrictedFINXMax16Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 16 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 16 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax210Text (pub String);
crate::simple_type!(RestrictedFINXMax210Text);

impl Validate for RestrictedFINXMax210Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 210 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 210 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax31Text (pub String);
crate::simple_type!(RestrictedFINXMax31Text);

impl Validate for RestrictedFINXMax31Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 31 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 31 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax34Text (pub String);
crate::simple_type!(RestrictedFINXMax34Text);

impl Validate for RestrictedFINXMax34Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 34 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 34 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax35Text (pub String);
crate::simple_type!(RestrictedFINXMax35Text);

impl Validate for RestrictedFINXMax35Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 35 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 35 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug)]
pub struct RestrictedFINXMax70Text (pub String);
crate::simple_type!(RestrictedFINXMax70Text);

impl Validate for RestrictedFINXMax70Text {
    fn validate(&self) -> Result<(), String> { 
        #[allow(clippy::len_zero)]
        if self.0.len() < 1 {
            return Err(format!("MinLength validation error. \nExpected: 0 length >= 1 \nActual: 0 length == {}", self.0.len()));
        }
        if self.0.len() > 70 {
            return Err(format!("MaxLength validation error. \nExpected: 0 length <= 70 \nActual: 0 length == {}", self.0.len()));
        }
        Ok(())
    }
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SecuritiesAccount30 {
    #[yaserde(rename = "Id")]
    #[cfg_attr(feature = "serde", serde(rename = "Id"))]
    pub id: RestrictedFINXMax35Text,

    #[yaserde(rename = "Tp")]
    #[cfg_attr(feature = "serde", serde(rename = "Tp"))]
    pub tp: GenericIdentification47,

    #[yaserde(rename = "Nm")]
    #[cfg_attr(feature = "serde", serde(rename = "Nm"))]
    pub nm: Max70Text,
}

impl Validate for SecuritiesAccount30 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SecuritiesSettlementTransactionCounterpartyResponse002V04 {
    #[yaserde(rename = "TxId")]
    #[cfg_attr(feature = "serde", serde(rename = "TxId"))]
    pub tx_id: TransactionIdentification7,

    #[yaserde(rename = "RspnSts")]
    #[cfg_attr(feature = "serde", serde(rename = "RspnSts"))]
    pub rspn_sts: ResponseStatus8Choice,

    #[yaserde(rename = "TxDtls")]
    #[cfg_attr(feature = "serde", serde(rename = "TxDtls"))]
    pub tx_dtls: TransactionDetails157,

    #[yaserde(rename = "SplmtryData")]
    #[cfg_attr(feature = "serde", serde(rename = "SplmtryData"))]
    pub splmtry_data: Vec<SupplementaryData1>,
}

impl Validate for SecuritiesSettlementTransactionCounterpartyResponse002V04 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SecurityIdentification20 {
    #[yaserde(rename = "ISIN")]
    #[cfg_attr(feature = "serde", serde(rename = "ISIN"))]
    pub isin: Isinoct2015Identifier,

    #[yaserde(rename = "OthrId")]
    #[cfg_attr(feature = "serde", serde(rename = "OthrId"))]
    pub othr_id: Vec<OtherIdentification2>,

    #[yaserde(rename = "Desc")]
    #[cfg_attr(feature = "serde", serde(rename = "Desc"))]
    pub desc: RestrictedFINXMax140Text,
}

impl Validate for SecurityIdentification20 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SettlementDate32Choice {
    #[yaserde(rename = "Dt")]
    #[cfg_attr(feature = "serde", serde(rename = "Dt"))]
    pub dt: Option<DateAndDateTime2Choice>,
    #[yaserde(rename = "DtCd")]
    #[cfg_attr(feature = "serde", serde(rename = "DtCd"))]
    pub dt_cd: Option<SettlementDateCode11Choice>,
}

impl Validate for SettlementDate32Choice {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SettlementDateCode11Choice {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: Option<DateType4Code>,
    #[yaserde(rename = "Prtry")]
    #[cfg_attr(feature = "serde", serde(rename = "Prtry"))]
    pub prtry: Option<GenericIdentification47>,
}

impl Validate for SettlementDateCode11Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SettlementParties109 {
    #[yaserde(rename = "Dpstry")]
    #[cfg_attr(feature = "serde", serde(rename = "Dpstry"))]
    pub dpstry: PartyIdentification191,

    #[yaserde(rename = "Pty1")]
    #[cfg_attr(feature = "serde", serde(rename = "Pty1"))]
    pub pty_1: PartyIdentificationAndAccount215,

    #[yaserde(rename = "Pty2")]
    #[cfg_attr(feature = "serde", serde(rename = "Pty2"))]
    pub pty_2: PartyIdentificationAndAccount215,

    #[yaserde(rename = "Pty3")]
    #[cfg_attr(feature = "serde", serde(rename = "Pty3"))]
    pub pty_3: PartyIdentificationAndAccount215,

    #[yaserde(rename = "Pty4")]
    #[cfg_attr(feature = "serde", serde(rename = "Pty4"))]
    pub pty_4: PartyIdentificationAndAccount215,

    #[yaserde(rename = "Pty5")]
    #[cfg_attr(feature = "serde", serde(rename = "Pty5"))]
    pub pty_5: PartyIdentificationAndAccount215,
}

impl Validate for SettlementParties109 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SupplementaryData1 {
    #[yaserde(rename = "PlcAndNm")]
    #[cfg_attr(feature = "serde", serde(rename = "PlcAndNm"))]
    pub plc_and_nm: Max350Text,

    #[yaserde(rename = "Envlp")]
    #[cfg_attr(feature = "serde", serde(rename = "Envlp"))]
    pub envlp: SupplementaryDataEnvelope1,
}

impl Validate for SupplementaryData1 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct SupplementaryDataEnvelope1 {}

impl Validate for SupplementaryDataEnvelope1 {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct TradeDate9Choice {
    #[yaserde(rename = "Dt")]
    #[cfg_attr(feature = "serde", serde(rename = "Dt"))]
    pub dt: Option<DateAndDateTime2Choice>,
    #[yaserde(rename = "DtCd")]
    #[cfg_attr(feature = "serde", serde(rename = "DtCd"))]
    pub dt_cd: Option<TradeDateCode4Choice>,
}

impl Validate for TradeDate9Choice {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct TradeDateCode4Choice {
    #[yaserde(rename = "Cd")]
    #[cfg_attr(feature = "serde", serde(rename = "Cd"))]
    pub cd: Option<DateType3Code>,
    #[yaserde(rename = "Prtry")]
    #[cfg_attr(feature = "serde", serde(rename = "Prtry"))]
    pub prtry: Option<GenericIdentification47>,
}

impl Validate for TradeDateCode4Choice {}




#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct TransactionDetails157 {
    #[yaserde(rename = "FinInstrmId")]
    #[cfg_attr(feature = "serde", serde(rename = "FinInstrmId"))]
    pub fin_instrm_id: SecurityIdentification20,

    #[yaserde(rename = "SctiesMvmntTp")]
    #[cfg_attr(feature = "serde", serde(rename = "SctiesMvmntTp"))]
    pub scties_mvmnt_tp: ReceiveDelivery1Code,

    #[yaserde(rename = "Pmt")]
    #[cfg_attr(feature = "serde", serde(rename = "Pmt"))]
    pub pmt: DeliveryReceiptType2Code,

    #[yaserde(rename = "SttlmQty")]
    #[cfg_attr(feature = "serde", serde(rename = "SttlmQty"))]
    pub sttlm_qty: Quantity54Choice,

    #[yaserde(rename = "SfkpgAcct")]
    #[cfg_attr(feature = "serde", serde(rename = "SfkpgAcct"))]
    pub sfkpg_acct: SecuritiesAccount30,

    #[yaserde(rename = "BlckChainAdrOrWllt")]
    #[cfg_attr(feature = "serde", serde(rename = "BlckChainAdrOrWllt"))]
    pub blck_chain_adr_or_wllt: BlockChainAddressWallet7,

    #[yaserde(rename = "SttlmAmt")]
    #[cfg_attr(feature = "serde", serde(rename = "SttlmAmt"))]
    pub sttlm_amt: AmountAndDirection67,

    #[yaserde(rename = "SttlmDt")]
    #[cfg_attr(feature = "serde", serde(rename = "SttlmDt"))]
    pub sttlm_dt: SettlementDate32Choice,

    #[yaserde(rename = "TradDt")]
    #[cfg_attr(feature = "serde", serde(rename = "TradDt"))]
    pub trad_dt: TradeDate9Choice,

    #[yaserde(rename = "DlvrgSttlmPties")]
    #[cfg_attr(feature = "serde", serde(rename = "DlvrgSttlmPties"))]
    pub dlvrg_sttlm_pties: SettlementParties109,

    #[yaserde(rename = "RcvgSttlmPties")]
    #[cfg_attr(feature = "serde", serde(rename = "RcvgSttlmPties"))]
    pub rcvg_sttlm_pties: SettlementParties109,

    #[yaserde(rename = "Invstr")]
    #[cfg_attr(feature = "serde", serde(rename = "Invstr"))]
    pub invstr: PartyIdentification170,
}

impl Validate for TransactionDetails157 {}


#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Clone, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "n", default_namespace = "n", namespace = "n: urn:iso:std:iso:20022:tech:xsd:sese.040.002.04")]
pub struct TransactionIdentification7 {
    #[yaserde(rename = "AcctOwnrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "AcctOwnrTxId"))]
    pub acct_ownr_tx_id: RestrictedFINXMax16Text,

    #[yaserde(rename = "AcctSvcrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "AcctSvcrTxId"))]
    pub acct_svcr_tx_id: RestrictedFINXMax16Text,

    #[yaserde(rename = "MktInfrstrctrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "MktInfrstrctrTxId"))]
    pub mkt_infrstrctr_tx_id: RestrictedFINXMax16Text,

    #[yaserde(rename = "PrcrTxId")]
    #[cfg_attr(feature = "serde", serde(rename = "PrcrTxId"))]
    pub prcr_tx_id: RestrictedFINXMax16Text,
}

impl Validate for TransactionIdentification7 {}

impl crate::MxMessage for Document {
    const BUSINESS_AREA: crate::BusinessArea = crate::BusinessArea::sese;
    const FUNCTIONALITY: &'static str = "040";
    const VARIANT: &'static str = "002";
    const VERSION: &'static str = "04";
    const MESSAGE_NAME: &'static str = "sese.040.002.04";
    const NAMESPACE: &'static str = "urn:iso:std:iso:20022:tech:xsd:sese.040.002.04";
}