-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathmodule.ts
More file actions
938 lines (879 loc) · 33.7 KB
/
module.ts
File metadata and controls
938 lines (879 loc) · 33.7 KB
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
import { StandardSchemaV1 } from "@standard-schema/spec";
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
import { AssertionGuard } from "./AssertionGuard";
import { IRandomGenerator } from "./IRandomGenerator";
import { IValidation } from "./IValidation";
import { Resolved } from "./Resolved";
import { TypeGuardError } from "./TypeGuardError";
export * as decorators from "./decorators";
export * as functional from "./functional";
export * as http from "./http";
export * as llm from "./llm";
export * as json from "./json";
export * as misc from "./misc";
export * as notations from "./notations";
export * as protobuf from "./protobuf";
export * as reflect from "./reflect";
export * as tags from "./tags";
export * from "./schemas/metadata/IJsDocTagInfo";
export * from "./schemas/json/IJsonApplication";
export * from "./schemas/json/IJsonSchemaCollection";
export * from "./schemas/json/IJsonSchemaUnit";
export * from "./AssertionGuard";
export * from "./IRandomGenerator";
export * from "./IValidation";
export * from "./TypeGuardError";
export * from "./Primitive";
export * from "./Resolved";
export * from "./CamelCase";
export * from "./PascalCase";
export * from "./SnakeCase";
export * from "./IReadableURLSearchParams";
/* -----------------------------------------------------------
BASIC VALIDATORS
----------------------------------------------------------- */
/**
* Asserts a value type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with a detailed
* reason, if the parametric value is not following the type `T`. Otherwise, if the
* value is following the type `T`, the input parameter will be returned.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link is} function instead.
* Otherwise, if you want to know all the errors, {@link validate} is the way to go.
* Also, if you want to automatically cast the parametric value to the type `T`
* when there is no problem (perform the assertion guard of type).
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assert<T>(
input: T,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): T;
/**
* Asserts a value type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with a detailed
* reason, if the parametric value is not following the type `T`. Otherwise, if the
* value is following the type `T`, the input parameter will be returned.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link is} function instead.
* Otherwise, if you want to know all the errors, {@link validate} is the way to go.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value casted as `T`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assert<T>(
input: unknown,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): T;
/**
* @internal
*/
export function assert(): never {
NoTransformConfigurationError("assert");
}
/**
* Assertion guard of a value type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with a detailed
* reason, if the parametric value is not following the type `T`. Otherwise, if the
* value is following the type `T`, nothing will be returned, but the input value
* will be automatically casted to the type `T`. This is the concept of
* "Assertion Guard" of a value type.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link is} function instead.
* Otherwise, if you want to know all the errors, {@link validate} is the way to go.
* Also, if you want to return the parametric value when there is no problem, you can use
* {@link assert} function instead.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link assertGuardEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertGuard<T>(
input: T,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): asserts input is T;
/**
* Assertion guard of a value type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with a detailed
* reason, if the parametric value is not following the type `T`. Otherwise, if the
* value is following the type `T`, nothing will be returned, but the input value
* will be automatically casted to the type `T`. This is the concept of
* "Assertion Guard" of a value type.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link is} function instead.
* Otherwise, if you want to know all the errors, {@link validate} is the way to go.
* Also, if you want to return the parametric value when there is no problem, you can use
* {@link assert} function instead.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link assertGuardEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertGuard<T>(
input: unknown,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): asserts input is T;
/**
* @internal
*/
export function assertGuard(): never {
NoTransformConfigurationError("assertGuard");
}
/**
* Tests a value type.
*
* Tests a parametric value type and returns whether it's following the type `T` or not.
* If the parametric value is matched with the type `T`, `true` value will be returned.
* Otherwise, if the parametric value is not following the type `T`, `false` value will be
* returned.
*
* If what you want is not just knowing whether the parametric value is following the
* type `T` or not, but throwing an exception with a detailed reason, you can choose
* {@link assert} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validate} function will be useful.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link equals} function instead.
*
* @template T Type of the input value
* @param input A value to be tested
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Whether the parametric value is following the type `T` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function is<T>(input: T): input is T;
/**
* Tests a value type.
*
* Tests a parametric value type and returns whether it's following the type `T` or not.
* If the parametric value is matched with the type `T`, `true` value will be returned.
* Otherwise, if the parametric value is not following the type `T`, `false` value will be
* returned.
*
* If what you want is not just knowing whether the parametric value is following the
* type `T` or not, but throwing an exception with a detailed reason, you can choose
* {@link assert} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validate} function will be useful.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link equals} function instead.
*
* @template T Type of the input value
* @param input A value to be tested
* @returns Whether the parametric value is following the type `T` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function is<T>(input: unknown): input is T;
/**
* @internal
*/
export function is(): never {
NoTransformConfigurationError("is");
}
/**
* Validates a value type.
*
* Validates a parametric value type and archives all the type errors into an
* {@link IValidation.errors} array, if the parametric value is not following the
* type `T`. Of course, if the parametric value is following the type `T`, the
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
* will have the `true` value.
*
* If what you want is not finding all the errors, but asserting the parametric value
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, if you just want to know whether the parametric value is matched with the
* type `T`, {@link is} function is the way to go.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be validated
* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function validate<T>(input: T): IValidation<T>;
/**
* Validates a value type.
*
* Validates a parametric value type and archives all the type errors into an
* {@link IValidation.errors} array, if the parametric value is not following the
* type `T`. Of course, if the parametric value is following the type `T`, the
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
* will have the `true` value.
*
* If what you want is not finding all the errors, but asserting the parametric value
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, if you just want to know whether the parametric value is matched with the
* type `T`, {@link is} function is the way to go.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be validated
* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function validate<T>(input: unknown): IValidation<T>;
/**
* @internal
*/
export function validate(): never {
NoTransformConfigurationError("validate");
}
/* -----------------------------------------------------------
STRICT VALIDATORS
----------------------------------------------------------- */
/**
* Asserts equality between a value and its type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
* reason, if the parametric value is not following the type `T` or some superfluous
* property that is not listed on the type `T` has been found. Otherwise, the value is
* following the type `T` without any superfluous property, just input parameter would
* be returned.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise, if you want to know all the errors, {@link validateEquals} is the way to go.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assert} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertEquals<T>(
input: T,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): T;
/**
* Asserts equality between a value and its type.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
* reason, if the parametric value is not following the type `T` or some superfluous
* property that is not listed on the type `T` has been found. Otherwise, the value is
* following the type `T` without any superfluous property, just input parameter would
* be returned.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise, if you want to know all the errors, {@link validateEquals} is the way to go.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assert} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value casted as `T`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertEquals<T>(
input: unknown,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): T;
/**
* @internal
*/
export function assertEquals(): never {
NoTransformConfigurationError("assertEquals");
}
/**
* Assertion guard of a type with equality.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
* reason, if the parametric value is not following the type `T` or some superfluous
* property that is not listed on the type `T` has been found.
*
* Otherwise, the value is following the type `T` without any superfluous property,
* nothing will be returned, but the input value would be automatically casted to
* the type `T`. This is the concept of "Assertion Guard" of a value type.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise, if you want to know all the errors, {@link validateEquals} is the way to go.
* Also, if you want to returns the parametric value when no problem, you can use
* {@link assert} function instead.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assertEquals} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value casted as `T`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertGuardEquals<T>(
input: T,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): asserts input is T;
/**
* Assertion guard of a type with equality.
*
* Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
* reason, if the parametric value is not following the type `T` or some superfluous
* property that is not listed on the type `T` has been found.
*
* Otherwise, the value is following the type `T` without any superfluous property,
* nothing will be returned, but the input value would be automatically casted to
* the type `T`. This is the concept of "Assertion Guard" of a value type.
*
* If what you want is not asserting but just knowing whether the parametric value is
* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise, if you want to know all the errors, {@link validateEquals} is the way to go.
* Also, if you want to returns the parametric value when no problem, you can use
* {@link assertEquals} function instead.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assertGuard} function instead.
*
* @template T Type of the input value
* @param input A value to be asserted
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Parametric input value casted as `T`
* @throws A {@link TypeGuardError} instance with a detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function assertGuardEquals<T>(
input: unknown,
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): asserts input is T;
/**
* @internal
*/
export function assertGuardEquals(): never {
NoTransformConfigurationError("assertGuardEquals");
}
/**
* Tests equality between a value and its type.
*
* Tests a parametric value type and returns whether it's equivalent to the type `T`
* or not. If the parametric value is matched with the type `T` and there's not any
* superfluous property that is not listed on the type `T`, `true` value will be
* returned. Otherwise, if the parametric value is not following the type `T` or some
* superfluous property exists, `false` value will be returned.
*
* If what you want is not just knowing whether the parametric value is following the
* type `T` or not, but throwing an exception with a detailed reason, you can choose
* {@link assertEquals} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validateEquals} function will be useful.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link is} function instead.
*
* @template T Type of the input value
* @param input A value to be tested
* @returns Whether the parametric value is equivalent to the type `T` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function equals<T>(input: T): input is T;
/**
* Tests equality between a value and its type.
*
* Tests a parametric value type and returns whether it's equivalent to the type `T`
* or not. If the parametric value is matched with the type `T` and there's not any
* superfluous property that is not listed on the type `T`, `true` value will be
* returned. Otherwise, if the parametric value is not following the type `T` or some
* superfluous property exists, `false` value will be returned.
*
* If what you want is not just knowing whether the parametric value is following the
* type `T` or not, but throwing an exception with a detailed reason, you can choose
* {@link assertEquals} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validateEquals} function will be useful.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link is} function instead.
*
* @template T Type of the input value
* @param input A value to be tested
* @returns Whether the parametric value is equivalent to the type `T` or not
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function equals<T>(input: unknown): input is T;
/**
* @internal
*/
export function equals(): never {
NoTransformConfigurationError("equals");
}
/**
* Validates equality between a value and its type.
*
* Validates a parametric value type and archives all the type errors into an
* {@link IValidation.errors} array, if the parametric value is not following the
* type `T` or some superfluous property that is not listed on the type `T` has been
* found. Of course, if the parametric value is following the type `T` and no
* superfluous property exists, the {@link IValidation.errors} array would be empty
* and {@link IValidation.success} would have the `true` value.
*
* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the
* type `T`, {@link is} function is the way to go.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
*
* @template Type of the input value
* @param input A value to be validated
* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function validateEquals<T>(input: T): IValidation<T>;
/**
* Validates equality between a value and its type.
*
* Validates a parametric value type and archives all the type errors into an
* {@link IValidation.errors} array, if the parametric value is not following the
* type `T` or some superfluous property that is not listed on the type `T` has been
* found. Of course, if the parametric value is following the type `T` and no
* superfluous property exists, the {@link IValidation.errors} array would be empty
* and {@link IValidation.success} would have the `true` value.
*
* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the
* type `T`, {@link is} function is the way to go.
*
* On the other hand, if you don't want to allow any superfluous property that is not
* enrolled to the type `T`, you can use {@link validateEquals} function instead.
*
* @template Type of the input value
* @param input A value to be validated
* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function validateEquals<T>(input: unknown): IValidation<T>;
/**
* @internal
*/
export function validateEquals(): never {
NoTransformConfigurationError("validateEquals");
}
/* -----------------------------------------------------------
RANDOM
----------------------------------------------------------- */
/**
* > You must configure the generic argument `T`.
*
* Generate random data.
*
* Generates a random data following type the `T`.
*
* For reference, this `typia.random()` function generates only primitive type.
* If there're some methods in the type `T` or its nested instances, those would
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
* will be generated instead.
*
* @template T Type of data to generate
* @param generator Random data generator
* @return Randomly generated data
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function random(generator?: Partial<IRandomGenerator>): never;
/**
* Generate random data.
*
* Generates a random data following type the `T`.
*
* For reference, this `typia.random()` function generates only primitive type.
* If there're some methods in the type `T` or its nested instances, those would
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
* will be generated instead.
*
* @template T Type of data to generate
* @param generator Random data generator
* @return Randomly generated data
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
/**
* @internal
*/
export function random(): never {
NoTransformConfigurationError("random");
}
/* -----------------------------------------------------------
FACTORY FUNCTIONS
----------------------------------------------------------- */
/**
* Creates a reusable {@link assert} function.
*
* @danger You must configure the generic argument `T`
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssert(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): never;
/**
* Creates a reusable {@link assert} function.
*
* @template T Type of the input value
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns A reusable `assert` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssert<T>(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): (input: unknown) => T;
/**
* @internal
*/
export function createAssert<T>(): (input: unknown) => T {
NoTransformConfigurationError("createAssert");
}
/**
* Creates a reusable {@link assertGuard} function.
*
* Note that, you've to declare the variable type of the factory function caller
* like below. If you don't declare the variable type, compilation error be thrown.
* This is the special rule of the TypeScript compiler.
*
* ```typescript
* // MUST DECLARE THE VARIABLE TYPE
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
*
* // IF NOT, COMPILATION ERROR BE OCCURRED
* const func = typia.createAssertGuard<number>();
* ```
*
* > *Assertions require every name in the call target to be declared with an*
* > *explicit type annotation.*
*
* @danger You must configure the generic argument `T`
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertGuard(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): never;
/**
* Creates a reusable {@link assertGuard} function.
*
* Note that, you've to declare the variable type of the factory function caller
* like below. If you don't declare the variable type, compilation error be thrown.
* This is the special rule of the TypeScript compiler.
*
* ```typescript
* // MUST DECLARE THE VARIABLE TYPE
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
*
* // IF NOT, COMPILATION ERROR BE OCCURRED
* const func = typia.createAssertGuard<number>();
* ```
*
* > *Assertions require every name in the call target to be declared with an*
* > *explicit type annotation.*
*
* @returns Nothing until you configure the generic argument `T`
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertGuard<T>(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): (input: unknown) => AssertionGuard<T>;
/**
* @internal
*/
export function createAssertGuard<T>(): (input: unknown) => AssertionGuard<T> {
NoTransformConfigurationError("createAssertGuard");
}
/**
* Creates a reusable {@link is} function.
*
* @danger You must configure the generic argument `T`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createIs(): never;
/**
* Creates a reusable {@link is} function.
*
* @template T Type of the input value
* @returns A reusable `is` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createIs<T>(): (input: unknown) => input is T;
/**
* @internal
*/
export function createIs<T>(): (input: unknown) => input is T {
NoTransformConfigurationError("createIs");
}
/**
* Creates a reusable {@link validate} function.
*
* @danger You must configure the generic argument `T`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createValidate(): never;
/**
* Creates a reusable {@link validate} function.
*
* @template T Type of the input value
* @returns A reusable `validate` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createValidate<T>(): ((input: unknown) => IValidation<T>) &
StandardSchemaV1<unknown, T>;
/**
* @internal
*/
export function createValidate(): ((input: unknown) => IValidation) &
StandardSchemaV1<unknown, unknown> {
NoTransformConfigurationError("createValidate");
}
/**
* Creates a reusable {@link assertEquals} function.
*
* @danger You must configure the generic argument `T`
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertEquals(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): never;
/**
* Creates a reusable {@link assertEquals} function.
*
* @template T Type of the input value
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns A reusable `assertEquals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertEquals<T>(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): (input: unknown) => T;
/**
* @internal
*/
export function createAssertEquals<T>(): (input: unknown) => T {
NoTransformConfigurationError("createAssertEquals");
}
/**
* Creates a reusable {@link assertGuardEquals} function.
*
* Note that, you've to declare the variable type of the factory function caller
* like below. If you don't declare the variable type, compilation error be thrown.
* This is the special rule of the TypeScript compiler.
*
* ```typescript
* // MUST DECLARE THE VARIABLE TYPE
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
*
* // IF NOT, COMPILATION ERROR BE OCCURRED
* const func = typia.createAssertGuardEquals<number>();
* ```
*
* > *Assertions require every name in the call target to be declared with an*
* > *explicit type annotation.*
*
* @danger You must configure the generic argument `T`
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertGuardEquals(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): never;
/**
* Creates a reusable {@link assertGuardEquals} function.
*
* Note that, you've to declare the variable type of the factory function caller
* like below. If you don't declare the variable type, compilation error be thrown.
* This is the special rule of the TypeScript compiler.
*
* ```typescript
* // MUST DECLARE THE VARIABLE TYPE
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
*
* // IF NOT, COMPILATION ERROR BE OCCURRED
* const func = typia.createAssertGuardEquals<number>();
* ```
*
* > *Assertions require every name in the call target to be declared with an*
* > *explicit type annotation.*
*
* @param errorFactory Custom error factory. Default is `TypeGuardError`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createAssertGuardEquals<T>(
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
): (input: unknown) => AssertionGuard<T>;
/**
* @internal
*/
export function createAssertGuardEquals<T>(): (
input: unknown,
) => AssertionGuard<T> {
NoTransformConfigurationError("createAssertGuardEquals");
}
/**
* Creates a reusable {@link equals} function.
*
* @danger You must configure the generic argument `T`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createEquals(): never;
/**
* Creates a reusable {@link equals} function.
*
* @template T Type of the input value
* @returns A reusable `equals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createEquals<T>(): (input: unknown) => input is T;
/**
* @internal
*/
export function createEquals<T>(): (input: unknown) => input is T {
NoTransformConfigurationError("createEquals");
}
/**
* Creates a reusable {@link validateEquals} function.
*
* @danger You must configure the generic argument `T`
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createValidateEquals(): never;
/**
* Creates a reusable {@link validateEquals} function.
*
* @template T Type of the input value
* @returns A reusable `validateEquals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createValidateEquals<T>(): ((
input: unknown,
) => IValidation<T>) &
StandardSchemaV1<unknown, T>;
/**
* @internal
*/
export function createValidateEquals(): ((input: unknown) => IValidation) &
StandardSchemaV1<unknown, unknown> {
NoTransformConfigurationError("createValidateEquals");
}
/**
* Creates a reusable {@link random} function.
*
* @danger You must configure the generic argument `T`
* @param generator Random data generator
* @returns Nothing until you configure the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createRandom(generator?: Partial<IRandomGenerator>): never;
/**
* Creates a reusable {@link random} function.
*
* @template T Type of the input value
* @param generator Random data generator
* @returns A reusable `random` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export function createRandom<T>(
generator?: Partial<IRandomGenerator>,
): () => Resolved<T>;
/**
* @internal
*/
export function createRandom(): never {
NoTransformConfigurationError("createRandom");
}