@tmlmobilidade/go-utils-validation 0.0.0-stage → 20261112.1211.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,720 @@
1
+ import { z } from 'zod';
2
+ import pt from './locales/pt.json';
3
+ type MessageKeys<T> = {
4
+ [K in keyof T & string]: T[K] extends string ? K : `${K}.${MessageKeys<T[K]>}`;
5
+ }[keyof T & string];
6
+ export type ValidationKey = MessageKeys<typeof pt>;
7
+ export type ValidationValues = Record<string, unknown>;
8
+ export declare const validationResources: {
9
+ en: {
10
+ validation: {
11
+ custom: {
12
+ banner: {
13
+ link: string;
14
+ };
15
+ dates: {
16
+ event_id: string;
17
+ overlap: string;
18
+ period_name: string;
19
+ period_required: string;
20
+ };
21
+ documents: {
22
+ changes_required: string;
23
+ different_values: string;
24
+ null_values: string;
25
+ };
26
+ feedback: {
27
+ duplicate_reason: string;
28
+ reason: string;
29
+ };
30
+ formats: {
31
+ date: string;
32
+ hex_color: string;
33
+ hhmm: string;
34
+ operational_date: string;
35
+ operational_time: string;
36
+ unix_milliseconds: string;
37
+ unix_seconds: string;
38
+ };
39
+ geo: {
40
+ coordinate: string;
41
+ encoded_polyline: string;
42
+ latitude: string;
43
+ linear_ring: string;
44
+ longitude: string;
45
+ };
46
+ network: {
47
+ agency_required: string;
48
+ anchor: string;
49
+ default_required: string;
50
+ default_unique: string;
51
+ parameters_path: string;
52
+ path_ids: string;
53
+ shape_distances: string;
54
+ shape_sequences: string;
55
+ stop_distances: string;
56
+ stop_sequences: string;
57
+ weekdays: string;
58
+ year_periods: string;
59
+ };
60
+ password: {
61
+ lowercase: string;
62
+ min_length: string;
63
+ mismatch: string;
64
+ number: string;
65
+ requirements: string;
66
+ special: string;
67
+ uppercase: string;
68
+ };
69
+ schedule: {
70
+ active_period: string;
71
+ end_after_start: string;
72
+ publication: string;
73
+ };
74
+ unique: {
75
+ changelog_items: string;
76
+ module_ids: string;
77
+ release_ids: string;
78
+ };
79
+ };
80
+ errors: {
81
+ custom: string;
82
+ invalid_element: string;
83
+ invalid_format: {
84
+ default: string;
85
+ ends_with: string;
86
+ includes: string;
87
+ lowercase: string;
88
+ regex: string;
89
+ starts_with: string;
90
+ uppercase: string;
91
+ };
92
+ invalid_key: string;
93
+ invalid_type: string;
94
+ invalid_type_received_null: string;
95
+ invalid_type_received_undefined: string;
96
+ invalid_union: string;
97
+ invalid_union_discriminator: string;
98
+ invalid_union_type: string;
99
+ invalid_value: string;
100
+ invalid_value_single: string;
101
+ not_multiple_of: string;
102
+ too_big: {
103
+ array: {
104
+ exact: string;
105
+ inclusive: string;
106
+ not_inclusive: string;
107
+ };
108
+ date: {
109
+ exact: string;
110
+ inclusive: string;
111
+ not_inclusive: string;
112
+ };
113
+ file: {
114
+ exact: string;
115
+ inclusive: string;
116
+ not_inclusive: string;
117
+ };
118
+ map: {
119
+ exact: string;
120
+ inclusive: string;
121
+ not_inclusive: string;
122
+ };
123
+ number: {
124
+ exact: string;
125
+ inclusive: string;
126
+ not_inclusive: string;
127
+ };
128
+ set: {
129
+ exact: string;
130
+ inclusive: string;
131
+ not_inclusive: string;
132
+ };
133
+ string: {
134
+ exact: string;
135
+ inclusive: string;
136
+ not_inclusive: string;
137
+ };
138
+ };
139
+ too_small: {
140
+ array: {
141
+ exact: string;
142
+ inclusive: string;
143
+ not_inclusive: string;
144
+ };
145
+ date: {
146
+ exact: string;
147
+ inclusive: string;
148
+ not_inclusive: string;
149
+ };
150
+ file: {
151
+ exact: string;
152
+ inclusive: string;
153
+ not_inclusive: string;
154
+ };
155
+ map: {
156
+ exact: string;
157
+ inclusive: string;
158
+ not_inclusive: string;
159
+ };
160
+ number: {
161
+ exact: string;
162
+ inclusive: string;
163
+ not_inclusive: string;
164
+ };
165
+ set: {
166
+ exact: string;
167
+ inclusive: string;
168
+ not_inclusive: string;
169
+ };
170
+ string: {
171
+ exact: string;
172
+ inclusive: string;
173
+ not_inclusive: string;
174
+ };
175
+ };
176
+ unrecognized_keys: string;
177
+ };
178
+ formats: {
179
+ base64: string;
180
+ base64url: string;
181
+ cidrv4: string;
182
+ cidrv6: string;
183
+ credit_card: string;
184
+ cuid: string;
185
+ cuid2: string;
186
+ currency_code: string;
187
+ date: string;
188
+ datetime: string;
189
+ duration: string;
190
+ e164: string;
191
+ email: string;
192
+ emoji: string;
193
+ guid: string;
194
+ hash: string;
195
+ hex: string;
196
+ hostname: string;
197
+ iban: string;
198
+ ipv4: string;
199
+ ipv6: string;
200
+ json_string: string;
201
+ jwt: string;
202
+ ksuid: string;
203
+ mac: string;
204
+ nanoid: string;
205
+ template_literal: string;
206
+ time: string;
207
+ ulid: string;
208
+ url: string;
209
+ uuid: string;
210
+ xid: string;
211
+ };
212
+ types: {
213
+ array: string;
214
+ bigint: string;
215
+ boolean: string;
216
+ date: string;
217
+ file: string;
218
+ function: string;
219
+ int: string;
220
+ map: string;
221
+ nan: string;
222
+ never: string;
223
+ null: string;
224
+ number: string;
225
+ object: string;
226
+ promise: string;
227
+ record: string;
228
+ set: string;
229
+ string: string;
230
+ symbol: string;
231
+ tuple: string;
232
+ undefined: string;
233
+ void: string;
234
+ };
235
+ };
236
+ };
237
+ es: {
238
+ validation: {
239
+ custom: {
240
+ banner: {
241
+ link: string;
242
+ };
243
+ dates: {
244
+ event_id: string;
245
+ overlap: string;
246
+ period_name: string;
247
+ period_required: string;
248
+ };
249
+ documents: {
250
+ changes_required: string;
251
+ different_values: string;
252
+ null_values: string;
253
+ };
254
+ feedback: {
255
+ duplicate_reason: string;
256
+ reason: string;
257
+ };
258
+ formats: {
259
+ date: string;
260
+ hex_color: string;
261
+ hhmm: string;
262
+ operational_date: string;
263
+ operational_time: string;
264
+ unix_milliseconds: string;
265
+ unix_seconds: string;
266
+ };
267
+ geo: {
268
+ coordinate: string;
269
+ encoded_polyline: string;
270
+ latitude: string;
271
+ linear_ring: string;
272
+ longitude: string;
273
+ };
274
+ network: {
275
+ agency_required: string;
276
+ anchor: string;
277
+ default_required: string;
278
+ default_unique: string;
279
+ parameters_path: string;
280
+ path_ids: string;
281
+ shape_distances: string;
282
+ shape_sequences: string;
283
+ stop_distances: string;
284
+ stop_sequences: string;
285
+ weekdays: string;
286
+ year_periods: string;
287
+ };
288
+ password: {
289
+ lowercase: string;
290
+ min_length: string;
291
+ mismatch: string;
292
+ number: string;
293
+ requirements: string;
294
+ special: string;
295
+ uppercase: string;
296
+ };
297
+ schedule: {
298
+ active_period: string;
299
+ end_after_start: string;
300
+ publication: string;
301
+ };
302
+ unique: {
303
+ changelog_items: string;
304
+ module_ids: string;
305
+ release_ids: string;
306
+ };
307
+ };
308
+ errors: {
309
+ custom: string;
310
+ invalid_element: string;
311
+ invalid_format: {
312
+ default: string;
313
+ ends_with: string;
314
+ includes: string;
315
+ lowercase: string;
316
+ regex: string;
317
+ starts_with: string;
318
+ uppercase: string;
319
+ };
320
+ invalid_key: string;
321
+ invalid_type: string;
322
+ invalid_type_received_null: string;
323
+ invalid_type_received_undefined: string;
324
+ invalid_union: string;
325
+ invalid_union_discriminator: string;
326
+ invalid_union_type: string;
327
+ invalid_value: string;
328
+ invalid_value_single: string;
329
+ not_multiple_of: string;
330
+ too_big: {
331
+ array: {
332
+ exact: string;
333
+ inclusive: string;
334
+ not_inclusive: string;
335
+ };
336
+ date: {
337
+ exact: string;
338
+ inclusive: string;
339
+ not_inclusive: string;
340
+ };
341
+ file: {
342
+ exact: string;
343
+ inclusive: string;
344
+ not_inclusive: string;
345
+ };
346
+ map: {
347
+ exact: string;
348
+ inclusive: string;
349
+ not_inclusive: string;
350
+ };
351
+ number: {
352
+ exact: string;
353
+ inclusive: string;
354
+ not_inclusive: string;
355
+ };
356
+ set: {
357
+ exact: string;
358
+ inclusive: string;
359
+ not_inclusive: string;
360
+ };
361
+ string: {
362
+ exact: string;
363
+ inclusive: string;
364
+ not_inclusive: string;
365
+ };
366
+ };
367
+ too_small: {
368
+ array: {
369
+ exact: string;
370
+ inclusive: string;
371
+ not_inclusive: string;
372
+ };
373
+ date: {
374
+ exact: string;
375
+ inclusive: string;
376
+ not_inclusive: string;
377
+ };
378
+ file: {
379
+ exact: string;
380
+ inclusive: string;
381
+ not_inclusive: string;
382
+ };
383
+ map: {
384
+ exact: string;
385
+ inclusive: string;
386
+ not_inclusive: string;
387
+ };
388
+ number: {
389
+ exact: string;
390
+ inclusive: string;
391
+ not_inclusive: string;
392
+ };
393
+ set: {
394
+ exact: string;
395
+ inclusive: string;
396
+ not_inclusive: string;
397
+ };
398
+ string: {
399
+ exact: string;
400
+ inclusive: string;
401
+ not_inclusive: string;
402
+ };
403
+ };
404
+ unrecognized_keys: string;
405
+ };
406
+ formats: {
407
+ base64: string;
408
+ base64url: string;
409
+ cidrv4: string;
410
+ cidrv6: string;
411
+ credit_card: string;
412
+ cuid: string;
413
+ cuid2: string;
414
+ currency_code: string;
415
+ date: string;
416
+ datetime: string;
417
+ duration: string;
418
+ e164: string;
419
+ email: string;
420
+ emoji: string;
421
+ guid: string;
422
+ hash: string;
423
+ hex: string;
424
+ hostname: string;
425
+ iban: string;
426
+ ipv4: string;
427
+ ipv6: string;
428
+ json_string: string;
429
+ jwt: string;
430
+ ksuid: string;
431
+ mac: string;
432
+ nanoid: string;
433
+ template_literal: string;
434
+ time: string;
435
+ ulid: string;
436
+ url: string;
437
+ uuid: string;
438
+ xid: string;
439
+ };
440
+ types: {
441
+ array: string;
442
+ bigint: string;
443
+ boolean: string;
444
+ date: string;
445
+ file: string;
446
+ function: string;
447
+ int: string;
448
+ map: string;
449
+ nan: string;
450
+ never: string;
451
+ null: string;
452
+ number: string;
453
+ object: string;
454
+ promise: string;
455
+ record: string;
456
+ set: string;
457
+ string: string;
458
+ symbol: string;
459
+ tuple: string;
460
+ undefined: string;
461
+ void: string;
462
+ };
463
+ };
464
+ };
465
+ pt: {
466
+ validation: {
467
+ custom: {
468
+ banner: {
469
+ link: string;
470
+ };
471
+ dates: {
472
+ event_id: string;
473
+ overlap: string;
474
+ period_name: string;
475
+ period_required: string;
476
+ };
477
+ documents: {
478
+ changes_required: string;
479
+ different_values: string;
480
+ null_values: string;
481
+ };
482
+ feedback: {
483
+ duplicate_reason: string;
484
+ reason: string;
485
+ };
486
+ formats: {
487
+ date: string;
488
+ hex_color: string;
489
+ hhmm: string;
490
+ operational_date: string;
491
+ operational_time: string;
492
+ unix_milliseconds: string;
493
+ unix_seconds: string;
494
+ };
495
+ geo: {
496
+ coordinate: string;
497
+ encoded_polyline: string;
498
+ latitude: string;
499
+ linear_ring: string;
500
+ longitude: string;
501
+ };
502
+ network: {
503
+ agency_required: string;
504
+ anchor: string;
505
+ default_required: string;
506
+ default_unique: string;
507
+ parameters_path: string;
508
+ path_ids: string;
509
+ shape_distances: string;
510
+ shape_sequences: string;
511
+ stop_distances: string;
512
+ stop_sequences: string;
513
+ weekdays: string;
514
+ year_periods: string;
515
+ };
516
+ password: {
517
+ lowercase: string;
518
+ min_length: string;
519
+ mismatch: string;
520
+ number: string;
521
+ requirements: string;
522
+ special: string;
523
+ uppercase: string;
524
+ };
525
+ schedule: {
526
+ active_period: string;
527
+ end_after_start: string;
528
+ publication: string;
529
+ };
530
+ unique: {
531
+ changelog_items: string;
532
+ module_ids: string;
533
+ release_ids: string;
534
+ };
535
+ };
536
+ errors: {
537
+ custom: string;
538
+ invalid_element: string;
539
+ invalid_format: {
540
+ default: string;
541
+ ends_with: string;
542
+ includes: string;
543
+ lowercase: string;
544
+ regex: string;
545
+ starts_with: string;
546
+ uppercase: string;
547
+ };
548
+ invalid_key: string;
549
+ invalid_type: string;
550
+ invalid_type_received_null: string;
551
+ invalid_type_received_undefined: string;
552
+ invalid_union: string;
553
+ invalid_union_discriminator: string;
554
+ invalid_union_type: string;
555
+ invalid_value: string;
556
+ invalid_value_single: string;
557
+ not_multiple_of: string;
558
+ too_big: {
559
+ array: {
560
+ exact: string;
561
+ inclusive: string;
562
+ not_inclusive: string;
563
+ };
564
+ date: {
565
+ exact: string;
566
+ inclusive: string;
567
+ not_inclusive: string;
568
+ };
569
+ file: {
570
+ exact: string;
571
+ inclusive: string;
572
+ not_inclusive: string;
573
+ };
574
+ map: {
575
+ exact: string;
576
+ inclusive: string;
577
+ not_inclusive: string;
578
+ };
579
+ number: {
580
+ exact: string;
581
+ inclusive: string;
582
+ not_inclusive: string;
583
+ };
584
+ set: {
585
+ exact: string;
586
+ inclusive: string;
587
+ not_inclusive: string;
588
+ };
589
+ string: {
590
+ exact: string;
591
+ inclusive: string;
592
+ not_inclusive: string;
593
+ };
594
+ };
595
+ too_small: {
596
+ array: {
597
+ exact: string;
598
+ inclusive: string;
599
+ not_inclusive: string;
600
+ };
601
+ date: {
602
+ exact: string;
603
+ inclusive: string;
604
+ not_inclusive: string;
605
+ };
606
+ file: {
607
+ exact: string;
608
+ inclusive: string;
609
+ not_inclusive: string;
610
+ };
611
+ map: {
612
+ exact: string;
613
+ inclusive: string;
614
+ not_inclusive: string;
615
+ };
616
+ number: {
617
+ exact: string;
618
+ inclusive: string;
619
+ not_inclusive: string;
620
+ };
621
+ set: {
622
+ exact: string;
623
+ inclusive: string;
624
+ not_inclusive: string;
625
+ };
626
+ string: {
627
+ exact: string;
628
+ inclusive: string;
629
+ not_inclusive: string;
630
+ };
631
+ };
632
+ unrecognized_keys: string;
633
+ };
634
+ formats: {
635
+ base64: string;
636
+ base64url: string;
637
+ cidrv4: string;
638
+ cidrv6: string;
639
+ credit_card: string;
640
+ cuid: string;
641
+ cuid2: string;
642
+ currency_code: string;
643
+ date: string;
644
+ datetime: string;
645
+ duration: string;
646
+ e164: string;
647
+ email: string;
648
+ emoji: string;
649
+ guid: string;
650
+ hash: string;
651
+ hex: string;
652
+ hostname: string;
653
+ iban: string;
654
+ ipv4: string;
655
+ ipv6: string;
656
+ json_string: string;
657
+ jwt: string;
658
+ ksuid: string;
659
+ mac: string;
660
+ nanoid: string;
661
+ template_literal: string;
662
+ time: string;
663
+ ulid: string;
664
+ url: string;
665
+ uuid: string;
666
+ xid: string;
667
+ };
668
+ types: {
669
+ array: string;
670
+ bigint: string;
671
+ boolean: string;
672
+ date: string;
673
+ file: string;
674
+ function: string;
675
+ int: string;
676
+ map: string;
677
+ nan: string;
678
+ never: string;
679
+ null: string;
680
+ number: string;
681
+ object: string;
682
+ promise: string;
683
+ record: string;
684
+ set: string;
685
+ string: string;
686
+ symbol: string;
687
+ tuple: string;
688
+ undefined: string;
689
+ void: string;
690
+ };
691
+ };
692
+ };
693
+ };
694
+ /** Translate a rule outside parsing, for example a password requirement checklist. */
695
+ export declare function translateValidationMessage(key: ValidationKey, values?: ValidationValues, locale?: string): string;
696
+ /** Locale-neutral custom issue options for refine(), superRefine() and addIssue(). */
697
+ export declare function validationParams(key: ValidationKey, values?: ValidationValues): {
698
+ params: {
699
+ i18n: {
700
+ key: ValidationKey;
701
+ values: ValidationValues;
702
+ };
703
+ };
704
+ };
705
+ /**
706
+ * Custom wording for a built-in check such as min() or regex(). Leave translation
707
+ * to the per-parse map: a schema-level string would override the caller's locale.
708
+ */
709
+ export declare function validationMessage(key: ValidationKey, values?: ValidationValues): z.core.$ZodErrorMap;
710
+ /** Adapt an existing throwing validator to the Zod issue protocol. */
711
+ export declare function validationTransform<TInput, TOutput>(validate: (value: TInput) => TOutput, key: ValidationKey, values?: ValidationValues): (value: TInput, context: z.RefinementCtx) => TOutput;
712
+ /** A fixed-language map. Safe to use concurrently without changing global language. */
713
+ export declare function createValidationErrorMap(locale?: string): z.core.$ZodErrorMap<z.core.$ZodIssue> & {
714
+ translate: (issue: z.core.$ZodIssue) => string;
715
+ };
716
+ /** Format an existing Zod error for an API's error:string response or a worker log. */
717
+ export declare function formatValidationError(error: z.ZodError, locale?: string): string;
718
+ /** Synchronous form resolver preserving Zod paths, including nested array fields. */
719
+ export declare function createValidationResolver(schema: z.ZodType, locale?: string): (values: unknown) => Record<string, string>;
720
+ export {};