-
Notifications
You must be signed in to change notification settings - Fork 7
/
primitive.go
577 lines (473 loc) · 13.9 KB
/
primitive.go
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
// Copyright 2022 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package fincen
import (
"reflect"
"regexp"
)
const (
IndicateLegalName = "L"
IndicateDoingBusiness = "DBA"
IndicateKnownAs = "AKA"
)
// Must match the pattern \S+( +\S+)*|
type RestrictString100 string
func (r RestrictString100) Validate() error {
if len(string(r)) > 100 {
return NewErrValueInvalid("RestrictString100")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString15 string
func (r RestrictString15) Validate() error {
if len(string(r)) > 15 {
return NewErrValueInvalid("RestrictString15")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString150 string
func (r RestrictString150) Validate() error {
if len(string(r)) > 150 {
return NewErrValueInvalid("RestrictString150")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString16 string
func (r RestrictString16) Validate() error {
if len(string(r)) > 16 {
return NewErrValueInvalid("RestrictString16")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString2 string
func (r RestrictString2) Validate() error {
if len(string(r)) > 2 {
return NewErrValueInvalid("RestrictString2")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString25 string
func (r RestrictString25) Validate() error {
if len(string(r)) > 25 {
return NewErrValueInvalid("RestrictString25")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString3 string
func (r RestrictString3) Validate() error {
if len(string(r)) > 3 {
return NewErrValueInvalid("RestrictString3")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString30 string
func (r RestrictString30) Validate() error {
if len(string(r)) > 30 {
return NewErrValueInvalid("RestrictString30")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString35 string
func (r RestrictString35) Validate() error {
if len(string(r)) > 35 {
return NewErrValueInvalid("RestrictString35")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString39 string
func (r RestrictString39) Validate() error {
if len(string(r)) > 39 {
return NewErrValueInvalid("RestrictString39")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString40 string
func (r RestrictString40) Validate() error {
if len(string(r)) > 40 {
return NewErrValueInvalid("RestrictString40")
}
return nil
}
// May be no more than 4000 items long
type RestrictString4000 string
func (r RestrictString4000) Validate() error {
if len(string(r)) > 4000 {
return NewErrValueInvalid("RestrictString4000")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString50 string
func (r RestrictString50) Validate() error {
if len(string(r)) > 50 {
return NewErrValueInvalid("RestrictString50")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString512 string
func (r RestrictString512) Validate() error {
if len(string(r)) > 512 {
return NewErrValueInvalid("RestrictString517")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString517 string
func (r RestrictString517) Validate() error {
if len(string(r)) > 517 {
return NewErrValueInvalid("RestrictString517")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString525 string
func (r RestrictString525) Validate() error {
if len(string(r)) > 525 {
return NewErrValueInvalid("RestrictString525")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString6 string
func (r RestrictString6) Validate() error {
if len(string(r)) > 6 {
return NewErrValueInvalid("RestrictString6")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString9 string
func (r RestrictString9) Validate() error {
if len(string(r)) > 9 {
return NewErrValueInvalid("RestrictString9")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString750 string
func (r RestrictString750) Validate() error {
if len(string(r)) > 750 {
return NewErrValueInvalid("RestrictString750")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString4 string
func (r RestrictString4) Validate() error {
if len(string(r)) > 4 {
return NewErrValueInvalid("RestrictString4")
}
return nil
}
// Must match the pattern \S+( +\S+)*|
type RestrictString20 string
func (r RestrictString20) Validate() error {
if len(string(r)) > 20 {
return NewErrValueInvalid("RestrictString20")
}
return nil
}
// Must match the pattern ([0-1][0-9]|(2[0-3])):[0-5][0-9]:[0-5][0-9]|
type ValidateTimeDataOrBlankType string
var timeDataOrBlankTypeRegex = regexp.MustCompile(`([0-1][0-9]|(2[0-3])):[0-5][0-9]:[0-5][0-9]|`)
func (r ValidateTimeDataOrBlankType) Validate() error {
if !timeDataOrBlankTypeRegex.MatchString(string(r)) {
return NewErrValueInvalid("TimeDataOrBlankType")
}
return nil
}
// Must match the pattern (19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])|
type DateYYYYMMDDOrBlankType string
var dateYYYYMMDDOrBlankTypeRegex = regexp.MustCompile(`(19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])|`)
func (r DateYYYYMMDDOrBlankType) Validate() error {
if !dateYYYYMMDDOrBlankTypeRegex.MatchString(string(r)) {
return NewErrValueInvalid("DateYYYYMMDDOrBlankType")
}
return nil
}
// Must match the pattern (19|20)[0-9][0-9](0[0-9]|1[0-2])(0[0-9]|1[0-9]|2[0-9]|3[01])|
type DateYYYYMMDDOrBlankTypeDOB string
var dateYYYYMMDDOrBlankTypeDOBRegex = regexp.MustCompile(`(19|20)[0-9][0-9](0[0-9]|1[0-2])(0[0-9]|1[0-9]|2[0-9]|3[01])|`)
func (r DateYYYYMMDDOrBlankTypeDOB) Validate() error {
if !dateYYYYMMDDOrBlankTypeDOBRegex.MatchString(string(r)) {
return NewErrValueInvalid("DateYYYYMMDDOrBlankTypeDOB")
}
return nil
}
// Must match the pattern (19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])
type DateYYYYMMDDType string
var dateYYYYMMDDTypeRegex = regexp.MustCompile(`(19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])`)
func (r DateYYYYMMDDType) Validate() error {
if !dateYYYYMMDDTypeRegex.MatchString(string(r)) {
return NewErrValueInvalid("DateYYYYMMDDType")
}
return nil
}
// Must match the pattern (19|20)[0-9][0-9]
type DateYYYYType string
var dateYYYYTypeRegex = regexp.MustCompile(`(19|20)[0-9][0-9]`)
func (r DateYYYYType) Validate() error {
if !dateYYYYTypeRegex.MatchString(string(r)) {
return NewErrValueInvalid("DateYYYYType")
}
return nil
}
// May be one of 1, 2, 3, 4
type ValidateAssetAttributeTypeIDTypeCode int64
func (r ValidateAssetAttributeTypeIDTypeCode) Validate() error {
for _, vv := range []int{
1, 2, 3, 4,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("AssetAttributeTypeIDTypeCode")
}
// May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 46, 47
type ValidateAssetSubtypeIDTypeCode int64
func (r ValidateAssetSubtypeIDTypeCode) Validate() error {
for _, vv := range []int{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 46, 47,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("AssetSubtypeIDTypeCode")
}
// May be one of 5, 6
type ValidateAssetTypeIDTypeCode int64
func (r ValidateAssetTypeIDTypeCode) Validate() error {
for _, vv := range []int{
5, 6,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("AssetTypeIDTypeCode")
}
// May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999
type ValidateCyberEventIndicatorsTypeCode string
func (r ValidateCyberEventIndicatorsTypeCode) Validate() error {
for _, vv := range []string{
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "999",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("CyberEventIndicatorsTypeCode")
}
// May be one of E, U
type ValidateElectronicAddressTypeCode string
func (r ValidateElectronicAddressTypeCode) Validate() error {
for _, vv := range []string{
"E", "U",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("ElectronicAddressTypeCode")
}
// May be one of Y,
type ValidateIndicatorType string
func (r ValidateIndicatorType) Validate() error {
for _, vv := range []string{
"Y", "",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("IndicatorType")
}
// May be one of Y
type ValidateIndicatorNullType string
func (r ValidateIndicatorNullType) Validate() error {
for _, vv := range []string{
"Y",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("IndicatorType")
}
// May be one of 1, 2, 3, 4, 5, 11, 12, 999
type ValidateOrganizationCodeType int
func (r ValidateOrganizationCodeType) Validate() error {
for _, vv := range []int{
1, 2, 3, 4, 5, 11, 12, 999,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("OrganizationCodeType")
}
// May be one of 101, 102, 103, 503, 504, 508, 513, 514, 535, 528, 529, 533, 534, 539, 540, 541, 542, 1999, 5999
type ValidateOrganizationSubtypeCodeSarType int
func (r ValidateOrganizationSubtypeCodeSarType) Validate() error {
for _, vv := range []int{
101, 102, 103, 503, 504, 508, 513, 514, 535, 528, 529, 533, 534, 539, 540, 541, 542, 1999, 5999,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("OrganizationSubtypeCodeSarType")
}
// May be one of F, M, R, W
type ValidatePhoneNumberCodeType string
func (r ValidatePhoneNumberCodeType) Validate() error {
for _, vv := range []string{
"F", "M", "R", "W",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("PhoneNumberCodeType")
}
// May be one of 106, 111, 112, 113, 114, 301, 304, 305, 308, 309, 310, 312, 320, 321, 322, 323, 324, 325, 401, 402, 403, 404, 405, 409, 501, 502, 504, 505, 506, 507, 601, 603, 604, 608, 609, 701, 801, 804, 805, 806, 807, 808, 809, 812, 820, 821, 822, 823, 824, 901, 903, 904, 905, 907, 908, 909, 910, 911, 913, 917, 920, 921, 922, 924, 925, 926, 927, 928, 1001, 1003, 1005, 1006, 1007, 1101, 1102, 1201, 1202, 1203, 1204, 1999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 10999, 11999, 12999
type ValidateSuspiciousActivitySubtypeID int
func (r ValidateSuspiciousActivitySubtypeID) Validate() error {
for _, vv := range []int{
106, 111, 112, 113, 114, 301, 304, 305, 308, 309, 310, 312, 320, 321, 322, 323, 324, 325, 401, 402, 403, 404, 405, 409, 501, 502, 504, 505, 506, 507, 601, 603, 604, 608, 609, 701, 801, 804, 805, 806, 807, 808, 809, 812, 820, 821, 822, 823, 824, 901, 903, 904, 905, 907, 908, 909, 910, 911, 913, 917, 920, 921, 922, 924, 925, 926, 927, 928, 1001, 1003, 1005, 1006, 1007, 1101, 1102, 1201, 1202, 1203, 1204, 1999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 10999, 11999, 12999,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("SuspiciousActivitySubtypeID")
}
// May be one of 1, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11
type ValidateSuspiciousActivityTypeID int
func (r ValidateSuspiciousActivityTypeID) Validate() error {
for _, vv := range []int{
1, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("SuspiciousActivityTypeID")
}
// May be one of 35, 16, 39, 26, 40, 34
type ValidateInstrumentProductServiceTypeCode int
func (r ValidateInstrumentProductServiceTypeCode) Validate() error {
for _, vv := range []int{
35, 16, 39, 26, 40, 34,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("InstrumentProductServiceTypeCode")
}
// May be one of I, O, U
type ValidatePartyTypeCode string
func (r ValidatePartyTypeCode) Validate() error {
for _, vv := range []string{
"I", "O", "U",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("PartyTypeCode")
}
// May be one of 101, 102, 103, 1999
type ValidateOrganizationSubtypeCodeCtrType int
func (r ValidateOrganizationSubtypeCodeCtrType) Validate() error {
for _, vv := range []int{
101, 102, 103, 1999,
} {
if reflect.DeepEqual(int(r), vv) {
return nil
}
}
return NewErrValueInvalid("OrganizationSubtypeCodeCtrType")
}
// May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 999
type ValidateLateFilingReasonCodeType string
func (r ValidateLateFilingReasonCodeType) Validate() error {
for _, vv := range []string{
"1", "2", "3", "4", "5", "6", "7", "8", "9", "999",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("LateFilingReasonCodeType")
}
// May be one of 141, 142, 143, 144
type ValidateEFilingAccountTypeCodeType string
func (r ValidateEFilingAccountTypeCodeType) Validate() error {
for _, vv := range []string{
"141", "142", "143", "144",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("EFilingAccountTypeCodeType")
}
// May be one of 1, 2, 999
type ValidateAccountTypeCodeType string
func (r ValidateAccountTypeCodeType) Validate() error {
for _, vv := range []string{
"1", "2", "999",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("AccountTypeCodeType")
}
// May be one of C, D, E, F
type ValidateExemptBasisTypeCode string
func (r ValidateExemptBasisTypeCode) Validate() error {
for _, vv := range []string{
"C", "D", "E", "F",
} {
if reflect.DeepEqual(string(r), vv) {
return nil
}
}
return NewErrValueInvalid("ExemptBasisTypeCode")
}
// May be one of C, D, E, F
type SeqNumber int64
func (r SeqNumber) Validate() error {
// TODO disable check
/*
if int64(r) == 0 {
return NewErrValueInvalid("SeqNumber")
}
*/
return nil
}
type RestrictNumeric14 string
var restrictNumeric14Regex = regexp.MustCompile(`[0-9]{14}`)
func (r RestrictNumeric14) Validate() error {
if !restrictNumeric14Regex.MatchString(string(r)) {
return NewErrValueInvalid("RestrictNumeric14")
}
return nil
}