typia 3.6.10 → 3.7.0-dev.20230331

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.
Files changed (260) hide show
  1. package/lib/factories/MetadataTagFactory.js +140 -132
  2. package/lib/factories/MetadataTagFactory.js.map +1 -1
  3. package/lib/functional/$dictionary.d.ts +1 -0
  4. package/lib/functional/$dictionary.js +14 -0
  5. package/lib/functional/$dictionary.js.map +1 -0
  6. package/lib/functional/$is_custom.d.ts +2 -0
  7. package/lib/functional/$is_custom.js +12 -0
  8. package/lib/functional/$is_custom.js.map +1 -0
  9. package/lib/functional/Namespace.js +2 -0
  10. package/lib/functional/Namespace.js.map +1 -1
  11. package/lib/module.d.ts +25 -0
  12. package/lib/module.js +12 -1
  13. package/lib/module.js.map +1 -1
  14. package/lib/programmers/CheckerProgrammer.d.ts +2 -2
  15. package/lib/programmers/CheckerProgrammer.js +22 -22
  16. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  17. package/lib/programmers/CloneProgrammer.js +2 -2
  18. package/lib/programmers/CloneProgrammer.js.map +1 -1
  19. package/lib/programmers/FeatureProgrammer.d.ts +3 -2
  20. package/lib/programmers/FeatureProgrammer.js +5 -5
  21. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  22. package/lib/programmers/IsProgrammer.d.ts +1 -1
  23. package/lib/programmers/IsProgrammer.js +2 -2
  24. package/lib/programmers/IsProgrammer.js.map +1 -1
  25. package/lib/programmers/PruneProgrammer.js +2 -2
  26. package/lib/programmers/PruneProgrammer.js.map +1 -1
  27. package/lib/programmers/StringifyProgrammer.js +6 -6
  28. package/lib/programmers/StringifyProgrammer.js.map +1 -1
  29. package/lib/programmers/helpers/UnionExplorer.d.ts +7 -7
  30. package/lib/programmers/helpers/UnionExplorer.js +6 -6
  31. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  32. package/lib/programmers/internal/check_array.js +36 -7
  33. package/lib/programmers/internal/check_array.js.map +1 -1
  34. package/lib/programmers/internal/check_bigint.d.ts +3 -1
  35. package/lib/programmers/internal/check_bigint.js +90 -61
  36. package/lib/programmers/internal/check_bigint.js.map +1 -1
  37. package/lib/programmers/internal/check_custom.d.ts +4 -0
  38. package/lib/programmers/internal/check_custom.js +30 -0
  39. package/lib/programmers/internal/check_custom.js.map +1 -0
  40. package/lib/programmers/internal/check_number.js +104 -75
  41. package/lib/programmers/internal/check_number.js.map +1 -1
  42. package/lib/programmers/internal/check_string.js +4 -3
  43. package/lib/programmers/internal/check_string.js.map +1 -1
  44. package/lib/programmers/internal/check_union_array_like.d.ts +2 -2
  45. package/lib/programmers/internal/check_union_array_like.js +4 -4
  46. package/lib/programmers/internal/check_union_array_like.js.map +1 -1
  47. package/lib/programmers/internal/check_union_tuple.js +2 -2
  48. package/lib/programmers/internal/check_union_tuple.js.map +1 -1
  49. package/lib/programmers/internal/feature_object_entries.js +1 -1
  50. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  51. package/lib/typings/Customizable.d.ts +7 -0
  52. package/lib/typings/Customizable.js +3 -0
  53. package/lib/typings/Customizable.js.map +1 -0
  54. package/package.json +1 -1
  55. package/src/IRandomGenerator.ts +17 -17
  56. package/src/IValidation.ts +21 -21
  57. package/src/Primitive.ts +104 -104
  58. package/src/TypeGuardError.ts +36 -36
  59. package/src/executable/TypiaGenerateWizard.ts +87 -87
  60. package/src/executable/TypiaSetupWizard.ts +152 -152
  61. package/src/executable/setup/ArgumentParser.ts +91 -91
  62. package/src/executable/setup/CommandExecutor.ts +8 -8
  63. package/src/executable/setup/FileRetriever.ts +33 -33
  64. package/src/executable/setup/PackageManager.ts +92 -92
  65. package/src/executable/setup/PluginConfigurator.ts +99 -99
  66. package/src/executable/typia.ts +38 -38
  67. package/src/factories/CommentFactory.ts +10 -10
  68. package/src/factories/ExpressionFactory.ts +77 -77
  69. package/src/factories/IdentifierFactory.ts +73 -73
  70. package/src/factories/LiteralFactory.ts +44 -44
  71. package/src/factories/MetadataCollection.ts +122 -122
  72. package/src/factories/MetadataFactory.ts +51 -51
  73. package/src/factories/MetadataTagFactory.ts +302 -276
  74. package/src/factories/StatementFactory.ts +60 -60
  75. package/src/factories/TemplateFactory.ts +56 -56
  76. package/src/factories/TypeFactory.ts +129 -129
  77. package/src/factories/TypiaFileFactory.ts +120 -120
  78. package/src/factories/ValueFactory.ts +12 -12
  79. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  80. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  81. package/src/factories/internal/metadata/explore_metadata.ts +92 -92
  82. package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
  83. package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
  84. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  85. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  86. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  87. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  88. package/src/factories/internal/metadata/iterate_metadata_native.ts +222 -222
  89. package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
  90. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  91. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  92. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  93. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
  94. package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
  95. package/src/functional/$any.ts +3 -3
  96. package/src/functional/$dictionary.ts +17 -0
  97. package/src/functional/$every.ts +11 -11
  98. package/src/functional/$guard.ts +35 -35
  99. package/src/functional/$is_between.ts +7 -7
  100. package/src/functional/$is_custom.ts +14 -0
  101. package/src/functional/$is_date.ts +4 -4
  102. package/src/functional/$is_datetime.ts +3 -3
  103. package/src/functional/$is_email.ts +5 -5
  104. package/src/functional/$is_ipv4.ts +5 -5
  105. package/src/functional/$is_ipv6.ts +5 -5
  106. package/src/functional/$is_url.ts +5 -5
  107. package/src/functional/$is_uuid.ts +5 -5
  108. package/src/functional/$join.ts +50 -50
  109. package/src/functional/$number.ts +12 -12
  110. package/src/functional/$report.ts +15 -15
  111. package/src/functional/$rest.ts +3 -3
  112. package/src/functional/$string.ts +37 -37
  113. package/src/functional/$tail.ts +6 -6
  114. package/src/functional/Namespace.ts +127 -125
  115. package/src/index.ts +4 -4
  116. package/src/metadata/IJsDocTagInfo.ts +10 -10
  117. package/src/metadata/IMetadata.ts +25 -25
  118. package/src/metadata/IMetadataApplication.ts +7 -7
  119. package/src/metadata/IMetadataConstant.ts +16 -16
  120. package/src/metadata/IMetadataEntry.ts +6 -6
  121. package/src/metadata/IMetadataObject.ts +29 -29
  122. package/src/metadata/IMetadataProperty.ts +11 -11
  123. package/src/metadata/IMetadataTag.ts +105 -105
  124. package/src/metadata/Metadata.ts +534 -534
  125. package/src/metadata/MetadataConstant.ts +3 -3
  126. package/src/metadata/MetadataObject.ts +131 -131
  127. package/src/metadata/MetadataProperty.ts +64 -64
  128. package/src/module.ts +1986 -1946
  129. package/src/programmers/ApplicationProgrammer.ts +55 -55
  130. package/src/programmers/AssertCloneProgrammer.ts +70 -70
  131. package/src/programmers/AssertParseProgrammer.ts +65 -65
  132. package/src/programmers/AssertProgrammer.ts +232 -232
  133. package/src/programmers/AssertPruneProgrammer.ts +67 -67
  134. package/src/programmers/AssertStringifyProgrammer.ts +71 -71
  135. package/src/programmers/CheckerProgrammer.ts +923 -893
  136. package/src/programmers/CloneProgrammer.ts +388 -386
  137. package/src/programmers/FeatureProgrammer.ts +512 -505
  138. package/src/programmers/IsCloneProgrammer.ts +80 -80
  139. package/src/programmers/IsParseProgrammer.ts +74 -74
  140. package/src/programmers/IsProgrammer.ts +201 -200
  141. package/src/programmers/IsPruneProgrammer.ts +75 -75
  142. package/src/programmers/IsStringifyProgrammer.ts +81 -81
  143. package/src/programmers/PruneProgrammer.ts +343 -341
  144. package/src/programmers/RandomProgrammer.ts +388 -388
  145. package/src/programmers/StringifyProgrammer.ts +801 -795
  146. package/src/programmers/ValidateCloneProgrammer.ts +90 -90
  147. package/src/programmers/ValidateParseProgrammer.ts +69 -69
  148. package/src/programmers/ValidateProgrammer.ts +266 -266
  149. package/src/programmers/ValidatePruneProgrammer.ts +83 -83
  150. package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
  151. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  152. package/src/programmers/helpers/CloneJoiner.ts +134 -134
  153. package/src/programmers/helpers/FunctionImporeter.ts +55 -55
  154. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  155. package/src/programmers/helpers/OptionPredicator.ts +19 -19
  156. package/src/programmers/helpers/PruneJoiner.ts +52 -52
  157. package/src/programmers/helpers/RandomJoiner.ts +149 -149
  158. package/src/programmers/helpers/RandomRanger.ts +216 -216
  159. package/src/programmers/helpers/StringifyJoinder.ts +114 -114
  160. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  161. package/src/programmers/helpers/UnionExplorer.ts +281 -274
  162. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  163. package/src/programmers/internal/application_array.ts +37 -37
  164. package/src/programmers/internal/application_boolean.ts +17 -17
  165. package/src/programmers/internal/application_constant.ts +29 -29
  166. package/src/programmers/internal/application_default.ts +17 -17
  167. package/src/programmers/internal/application_default_string.ts +32 -32
  168. package/src/programmers/internal/application_native.ts +29 -29
  169. package/src/programmers/internal/application_number.ts +73 -73
  170. package/src/programmers/internal/application_object.ts +153 -153
  171. package/src/programmers/internal/application_schema.ts +184 -184
  172. package/src/programmers/internal/application_string.ts +45 -45
  173. package/src/programmers/internal/application_templates.ts +27 -27
  174. package/src/programmers/internal/application_tuple.ts +29 -29
  175. package/src/programmers/internal/check_array.ts +31 -22
  176. package/src/programmers/internal/check_array_length.ts +44 -44
  177. package/src/programmers/internal/check_bigint.ts +84 -64
  178. package/src/programmers/internal/check_custom.ts +32 -0
  179. package/src/programmers/internal/check_dynamic_properties.ts +197 -197
  180. package/src/programmers/internal/check_everything.ts +28 -28
  181. package/src/programmers/internal/check_native.ts +21 -21
  182. package/src/programmers/internal/check_number.ts +155 -145
  183. package/src/programmers/internal/check_object.ts +48 -48
  184. package/src/programmers/internal/check_string.ts +30 -24
  185. package/src/programmers/internal/check_string_tags.ts +63 -63
  186. package/src/programmers/internal/check_template.ts +50 -50
  187. package/src/programmers/internal/check_union_array_like.ts +265 -260
  188. package/src/programmers/internal/check_union_tuple.ts +35 -33
  189. package/src/programmers/internal/decode_union_object.ts +73 -73
  190. package/src/programmers/internal/feature_object_entries.ts +60 -59
  191. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  192. package/src/programmers/internal/prune_object_properties.ts +60 -60
  193. package/src/programmers/internal/stringify_dynamic_properties.ts +165 -165
  194. package/src/programmers/internal/stringify_native.ts +8 -8
  195. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  196. package/src/programmers/internal/template_to_pattern.ts +15 -15
  197. package/src/schemas/IJsonApplication.ts +9 -9
  198. package/src/schemas/IJsonComponents.ts +26 -26
  199. package/src/schemas/IJsonSchema.ts +121 -121
  200. package/src/transform.ts +21 -21
  201. package/src/transformers/CallExpressionTransformer.ts +172 -172
  202. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  203. package/src/transformers/FileTransformer.ts +49 -49
  204. package/src/transformers/IProject.ts +11 -11
  205. package/src/transformers/ITransformOptions.ts +62 -62
  206. package/src/transformers/ImportTransformer.ts +60 -60
  207. package/src/transformers/NodeTransformer.ts +19 -19
  208. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +120 -120
  209. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  210. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  211. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  212. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  213. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  214. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  215. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  216. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  217. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  218. package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +42 -42
  219. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  220. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  221. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  222. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  223. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  224. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  225. package/src/transformers/features/miscellaneous/RandomTransformer.ts +48 -48
  226. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  227. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  228. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  229. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  230. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  231. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  232. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  233. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  234. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  235. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
  236. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  237. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  238. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
  239. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  240. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  241. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  242. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  243. package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
  244. package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
  245. package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
  246. package/src/transformers/features/validators/IsTransformer.ts +10 -10
  247. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  248. package/src/transformers/internal/GenericTransformer.ts +99 -99
  249. package/src/typings/Atomic.ts +17 -17
  250. package/src/typings/ClassProperties.ts +5 -5
  251. package/src/typings/Customizable.ts +7 -0
  252. package/src/typings/OmitNever.ts +3 -3
  253. package/src/typings/SpecialFields.ts +3 -3
  254. package/src/typings/Writable.ts +11 -11
  255. package/src/utils/ArrayUtil.ts +49 -49
  256. package/src/utils/Escaper.ts +50 -50
  257. package/src/utils/MapUtil.ts +14 -14
  258. package/src/utils/PatternUtil.ts +30 -30
  259. package/src/utils/RandomGenerator.ts +96 -96
  260. package/src/utils/Singleton.ts +17 -17
package/src/module.ts CHANGED
@@ -1,1946 +1,1986 @@
1
- import { Namespace } from "./functional/Namespace";
2
-
3
- import { IMetadataApplication } from "./metadata/IMetadataApplication";
4
- import { IJsonApplication } from "./schemas/IJsonApplication";
5
-
6
- import { IRandomGenerator } from "./IRandomGenerator";
7
- import { IValidation } from "./IValidation";
8
- import { Primitive } from "./Primitive";
9
- import { TypeGuardError } from "./TypeGuardError";
10
-
11
- export * from "./schemas/IJsonApplication";
12
- export * from "./schemas/IJsonComponents";
13
- export * from "./schemas/IJsonSchema";
14
- export * from "./IRandomGenerator";
15
- export * from "./IValidation";
16
- export * from "./Primitive";
17
- export * from "./TypeGuardError";
18
-
19
- /* ===========================================================
20
- SINGLE FUNCTIONS
21
- - BASIC VALIDATORS
22
- - STRICT VALIDATORS
23
- - JSON FUNCTIONS
24
- - MISCELLANEOUS
25
- ==============================================================
26
- BASIC VALIDATORS
27
- ----------------------------------------------------------- */
28
- /**
29
- * Asserts a value type.
30
- *
31
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
32
- * reason, if the parametric value is not following the type `T`. Otherwise, the
33
- * value is following the type `T`, just input parameter would be returned.
34
- *
35
- * If what you want is not asserting but just knowing whether the parametric value is
36
- * following the type `T` or not, you can choose the {@link is} function instead.
37
- * Otherwise you want to know all the errors, {@link validate} is the way to go.
38
- *
39
- * On the other and, if you don't want to allow any superfluous property that is not
40
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
41
- *
42
- * @template T Type of the input value
43
- * @param input A value to be asserted
44
- * @returns Parametric input value
45
- * @throws A {@link TypeGuardError} instance with detailed reason
46
- *
47
- * @author Jeongho Nam - https://github.com/samchon
48
- */
49
- export function assert<T>(input: T): T;
50
-
51
- /**
52
- * Asserts a value type.
53
- *
54
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
55
- * reason, if the parametric value is not following the type `T`. Otherwise, the
56
- * value is following the type `T`, just input parameter would be returned.
57
- *
58
- * If what you want is not asserting but just knowing whether the parametric value is
59
- * following the type `T` or not, you can choose the {@link is} function instead.
60
- * Otherwise, you want to know all the errors, {@link validate} is the way to go.
61
- *
62
- * On the other and, if you don't want to allow any superfluous property that is not
63
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
64
- *
65
- * @template T Type of the input value
66
- * @param input A value to be asserted
67
- * @returns Parametric input value casted as `T`
68
- * @throws A {@link TypeGuardError} instance with detailed reason
69
- *
70
- * @author Jeongho Nam - https://github.com/samchon
71
- */
72
- export function assert<T>(input: unknown): T;
73
-
74
- /**
75
- * @internal
76
- */
77
- export function assert(): never {
78
- halt("assert");
79
- }
80
- Object.assign(assert, Namespace.assert("assert"));
81
-
82
- /**
83
- * Asserts a value type.
84
- *
85
- * Duplicated function of {@link assert} for `typescript-is` users.
86
- *
87
- * @template T Type of the input value
88
- * @param input A value to be asserted
89
- * @returns Parametric input value
90
- * @throws A {@link TypeGuardError} instance with detailed reason
91
- *
92
- * @author Jeongho Nam - https://github.com/samchon
93
- * @deprecated
94
- */
95
- export function assertType<T>(input: T): T;
96
-
97
- /**
98
- * Asserts a value type.
99
- *
100
- * Duplicated function of {@link assert} for `typescript-is` users.
101
- *
102
- * @template T Type of the input value
103
- * @param input A value to be asserted
104
- * @returns Parametric input value
105
- * @throws A {@link TypeGuardError} instance with detailed reason
106
- *
107
- * @author Jeongho Nam - https://github.com/samchon
108
- * @deprecated
109
- */
110
- export function assertType<T>(input: unknown): T;
111
-
112
- /**
113
- * @internal
114
- */
115
- export function assertType(): never {
116
- halt("assertType");
117
- }
118
- Object.assign(assertType, Namespace.assert("assertType"));
119
-
120
- /**
121
- * Tests a value type.
122
- *
123
- * Tests a parametric value type and returns whether it's following the type `T` or not.
124
- * If the parametric value is matched with the type `T`, `true` value would be returned.
125
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
126
- * returned.
127
- *
128
- * If what you want is not just knowing whether the parametric value is following the
129
- * type `T` or not, but throwing an exception with detailed reason, you can choose
130
- * {@link assert} function instead. Also, if you want to know all the errors with
131
- * detailed reasons, {@link validate} function would be useful.
132
- *
133
- * On the other and, if you don't want to allow any superfluous property that is not
134
- * enrolled to the type `T`, you can use {@link equals} function instead.
135
- *
136
- * @template T Type of the input value
137
- * @param input A value to be tested
138
- * @returns Whether the parametric value is following the type `T` or not
139
- *
140
- * @author Jeongho Nam - https://github.com/samchon
141
- */
142
- export function is<T>(input: T): input is T;
143
-
144
- /**
145
- * Tests a value type.
146
- *
147
- * Tests a parametric value type and returns whether it's following the type `T` or not.
148
- * If the parametric value is matched with the type `T`, `true` value would be returned.
149
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
150
- * returned.
151
- *
152
- * If what you want is not just knowing whether the parametric value is following the
153
- * type `T` or not, but throwing an exception with detailed reason, you can choose
154
- * {@link assert} function instead. Also, if you want to know all the errors with
155
- * detailed reasons, {@link validate} function would be useful.
156
- *
157
- * On the other and, if you don't want to allow any superfluous property that is not
158
- * enrolled to the type `T`, you can use {@link equals} function instead.
159
- *
160
- * @template T Type of the input value
161
- * @param input A value to be tested
162
- * @returns Whether the parametric value is following the type `T` or not
163
- *
164
- * @author Jeongho Nam - https://github.com/samchon
165
- */
166
- export function is<T>(input: unknown): input is T;
167
-
168
- /**
169
- * @internal
170
- */
171
- export function is(): never {
172
- halt("is");
173
- }
174
- Object.assign(is, Namespace.assert("is"));
175
-
176
- /**
177
- * Validates a value type.
178
- *
179
- * Validates a parametric value type and archives all the type errors into an
180
- * {@link IValidation.errors} array, if the parametric value is not following the
181
- * type `T`. Of course, if the parametric value is following the type `T`, the
182
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
183
- * would have the `true` value.
184
- *
185
- * If what you want is not finding all the error, but asserting the parametric value
186
- * type with exception throwing, you can choose {@link assert} function instead.
187
- * Otherwise, you just want to know whether the parametric value is matched with the
188
- * type `T`, {@link is} function is the way to go.
189
- *
190
- * On the other and, if you don't want to allow any superfluous property that is not
191
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
192
- *
193
- * @template Type of the input value
194
- * @param input A value to be validated
195
- * @returns Validation result
196
- *
197
- * @author Jeongho Nam - https://github.com/samchon
198
- */
199
- export function validate<T>(input: T): IValidation<T>;
200
-
201
- /**
202
- * Validates a value type.
203
- *
204
- * Validates a parametric value type and archives all the type errors into an
205
- * {@link IValidation.errors} array, if the parametric value is not following the
206
- * type `T`. Of course, if the parametric value is following the type `T`, the
207
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
208
- * would have the `true` value.
209
- *
210
- * If what you want is not finding all the error, but asserting the parametric value
211
- * type with exception throwing, you can choose {@link assert} function instead.
212
- * Otherwise, you just want to know whether the parametric value is matched with the
213
- * type `T`, {@link is} function is the way to go.
214
- *
215
- * On the other and, if you don't want to allow any superfluous property that is not
216
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
217
- *
218
- * @template Type of the input value
219
- * @param input A value to be validated
220
- * @returns Validation result
221
- *
222
- * @author Jeongho Nam - https://github.com/samchon
223
- */
224
- export function validate<T>(input: unknown): IValidation<T>;
225
-
226
- /**
227
- * @internal
228
- */
229
- export function validate(): never {
230
- halt("validate");
231
- }
232
- Object.assign(validate, Namespace.validate());
233
-
234
- /* -----------------------------------------------------------
235
- STRICT VALIDATORS
236
- ----------------------------------------------------------- */
237
- /**
238
- * Asserts equality between a value and its type.
239
- *
240
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
241
- * reason, if the parametric value is not following the type `T` or some superfluous
242
- * property that is not listed on the type `T` has been found. Otherwise, the value is
243
- * following the type `T` without any superfluous property, just input parameter would
244
- * be returned.
245
- *
246
- * If what you want is not asserting but just knowing whether the parametric value is
247
- * following the type `T` or not, you can choose the {@link equals} function instead.
248
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
249
- *
250
- * On the other hand, if you want to allow superfluous property that is not enrolled
251
- * to the type `T`, you can use {@link assert} function instead.
252
- *
253
- * @template T Type of the input value
254
- * @param input A value to be asserted
255
- * @returns Parametric input value
256
- * @throws A {@link TypeGuardError} instance with detailed reason
257
- *
258
- * @author Jeongho Nam - https://github.com/samchon
259
- */
260
- export function assertEquals<T>(input: T): T;
261
-
262
- /**
263
- * Asserts equality between a value and its type.
264
- *
265
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
266
- * reason, if the parametric value is not following the type `T` or some superfluous
267
- * property that is not listed on the type `T` has been found. Otherwise, the value is
268
- * following the type `T` without any superfluous property, just input parameter would
269
- * be returned.
270
- *
271
- * If what you want is not asserting but just knowing whether the parametric value is
272
- * following the type `T` or not, you can choose the {@link equals} function instead.
273
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
274
- *
275
- * On the other hand, if you want to allow superfluous property that is not enrolled
276
- * to the type `T`, you can use {@link assert} function instead.
277
- *
278
- * @template T Type of the input value
279
- * @param input A value to be asserted
280
- * @returns Parametric input value casted as `T`
281
- * @throws A {@link TypeGuardError} instance with detailed reason
282
- *
283
- * @author Jeongho Nam - https://github.com/samchon
284
- */
285
- export function assertEquals<T>(input: unknown): T;
286
-
287
- /**
288
- * @internal
289
- */
290
- export function assertEquals(): never {
291
- halt("assertEquals");
292
- }
293
- Object.assign(assertEquals, Namespace.assert("assertEquals"));
294
-
295
- /**
296
- * Tests equality between a value and its type.
297
- *
298
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
299
- * or not. If the parametric value is matched with the type `T` and there's not any
300
- * superfluous property that is not listed on the type `T`, `true` value would be
301
- * returned. Otherwise, the parametric value is not following the type `T` or some
302
- * superfluous property exists, `false` value would be returned.
303
- *
304
- * If what you want is not just knowing whether the parametric value is following the
305
- * type `T` or not, but throwing an exception with detailed reason, you can choose
306
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
307
- * detailed reasons, {@link validateEquals} function would be useful.
308
- *
309
- * On the other hand, if you want to allow superfluous property that is not enrolled
310
- * to the type `T`, you can use {@link is} function instead.
311
- *
312
- * @template T Type of the input value
313
- * @param input A value to be tested
314
- * @returns Whether the parametric value is equivalent to the type `T` or not
315
- *
316
- * @author Jeongho Nam - https://github.com/samchon
317
- */
318
- export function equals<T>(input: T): input is T;
319
-
320
- /**
321
- * Tests equality between a value and its type.
322
- *
323
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
324
- * or not. If the parametric value is matched with the type `T` and there's not any
325
- * superfluous property that is not listed on the type `T`, `true` value would be
326
- * returned. Otherwise, the parametric value is not following the type `T` or some
327
- * superfluous property exists, `false` value would be returned.
328
- *
329
- * If what you want is not just knowing whether the parametric value is following the
330
- * type `T` or not, but throwing an exception with detailed reason, you can choose
331
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
332
- * detailed reasons, {@link validateEquals} function would be useful.
333
- *
334
- * On the other hand, if you want to allow superfluous property that is not enrolled
335
- * to the type `T`, you can use {@link is} function instead.
336
- *
337
- * @template T Type of the input value
338
- * @param input A value to be tested
339
- * @returns Whether the parametric value is equivalent to the type `T` or not
340
- *
341
- * @author Jeongho Nam - https://github.com/samchon
342
- */
343
- export function equals<T>(input: unknown): input is T;
344
-
345
- /**
346
- * @internal
347
- */
348
- export function equals(): never {
349
- halt("equals");
350
- }
351
- Object.assign(equals, Namespace.is());
352
-
353
- /**
354
- * Validates equality between a value and its type.
355
- *
356
- * Validates a parametric value type and archives all the type errors into an
357
- * {@link IValidation.errors} array, if the parametric value is not following the
358
- * type `T` or some superfluous property that is not listed on the type `T` has been
359
- * found. Of course, if the parametric value is following the type `T` and no
360
- * superfluous property exists, the {@link IValidation.errors} array would be empty
361
- * and {@link IValidation.success} would have the `true` value.
362
- *
363
- * If what you want is not finding all the error, but asserting the parametric value
364
- * type with exception throwing, you can choose {@link assert} function instead.
365
- * Otherwise, you just want to know whether the parametric value is matched with the
366
- * type `T`, {@link is} function is the way to go.
367
- *
368
- * On the other and, if you don't want to allow any superfluous property that is not
369
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
370
- *
371
- * @template Type of the input value
372
- * @param input A value to be validated
373
- * @returns Validation result
374
- *
375
- * @author Jeongho Nam - https://github.com/samchon
376
- */
377
- export function validateEquals<T>(input: T): IValidation<T>;
378
-
379
- /**
380
- * Validates equality between a value and its type.
381
- *
382
- * Validates a parametric value type and archives all the type errors into an
383
- * {@link IValidation.errors} array, if the parametric value is not following the
384
- * type `T` or some superfluous property that is not listed on the type `T` has been
385
- * found. Of course, if the parametric value is following the type `T` and no
386
- * superfluous property exists, the {@link IValidation.errors} array would be empty
387
- * and {@link IValidation.success} would have the `true` value.
388
- *
389
- * If what you want is not finding all the error, but asserting the parametric value
390
- * type with exception throwing, you can choose {@link assert} function instead.
391
- * Otherwise, you just want to know whether the parametric value is matched with the
392
- * type `T`, {@link is} function is the way to go.
393
- *
394
- * On the other and, if you don't want to allow any superfluous property that is not
395
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
396
- *
397
- * @template Type of the input value
398
- * @param input A value to be validated
399
- * @returns Validation result
400
- *
401
- * @author Jeongho Nam - https://github.com/samchon
402
- */
403
- export function validateEquals<T>(input: unknown): IValidation<T>;
404
-
405
- /**
406
- * @internal
407
- */
408
- export function validateEquals(): never {
409
- halt("validateEquals");
410
- }
411
- Object.assign(validateEquals, Namespace.validate());
412
-
413
- /* -----------------------------------------------------------
414
- JSON FUNCTIONS
415
- ----------------------------------------------------------- */
416
- /**
417
- * > You must configure the generic argument `T`.
418
- *
419
- * JSON Schema Application.
420
- *
421
- * Creates a JSON schema application which contains both main JSON schemas and components.
422
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
423
- * property for the `$ref` referencing.
424
- *
425
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
426
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
427
- * you should configure the *Purpose* appropriately.
428
- *
429
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
430
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
431
- * the tuple definition.
432
- *
433
- * @template Types Tuple of target types
434
- * @template Purpose Purpose of the JSON schema`
435
- * @template Prefix Prefix of the JSON components referenced by `$ref` tag
436
- * @return JSON schema application
437
- *
438
- * @author Jeongho Nam - https://github.com/samchon
439
- */
440
- export function application(): never;
441
-
442
- /**
443
- * JSON Schema Application.
444
- *
445
- * Creates a JSON schema application which contains both main JSON schemas and components.
446
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
447
- * property for the `$ref` referencing.
448
- *
449
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
450
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
451
- * you should configure the *Purpose* appropriately.
452
- *
453
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
454
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
455
- * the tuple definition.
456
- *
457
- * @template Types Tuple of target types
458
- * @template Purpose Purpose of the JSON schema
459
- * @template Prefix Prefix of the JSON components referenced by `$ref` tag
460
- * @return JSON schema application
461
- *
462
- * @author Jeongho Nam - https://github.com/samchon
463
- */
464
- export function application<
465
- Types extends unknown[],
466
- Purpose extends "swagger" | "ajv" = "swagger",
467
- Prefix extends string = Purpose extends "swagger"
468
- ? "#/components/schemas"
469
- : "components#/schemas",
470
- >(): IJsonApplication;
471
-
472
- /**
473
- * @internal
474
- */
475
- export function application(): never {
476
- halt("application");
477
- }
478
-
479
- /**
480
- * > You must configure the generic argument `T`.
481
- *
482
- * Safe `JSON.parse()` function with type assertion.
483
- *
484
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
485
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
486
- * instance with type assertion.
487
- *
488
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
489
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
490
- * the parsed value would be returned.
491
- *
492
- * @template T Expected type of parsed value
493
- * @param input JSON string
494
- * @returns Parsed value
495
- *
496
- * @author Jeongho Nam - https://github.com/samchon
497
- */
498
- export function assertParse(input: string): never;
499
-
500
- /**
501
- * Safe `JSON.parse()` function with type assertion.
502
- *
503
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
504
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
505
- * instance with type assertion.
506
- *
507
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
508
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
509
- * the parsed value would be returned.
510
- *
511
- * @template T Expected type of parsed value
512
- * @param input JSON string
513
- * @returns Parsed value
514
- *
515
- * @author Jeongho Nam - https://github.com/samchon
516
- */
517
- export function assertParse<T>(input: string): T;
518
-
519
- /**
520
- * @internal
521
- */
522
- export function assertParse<T>(): T {
523
- halt("assertParse");
524
- }
525
- Object.assign(assertParse, Namespace.assert("assertParse"));
526
-
527
- /**
528
- * > You must configure the generic argument `T`.
529
- *
530
- * Safe `JSON.parse()` function with type checking.
531
- *
532
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
533
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
534
- * instance with type checking.
535
- *
536
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
537
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
538
- * value would be returned.
539
- *
540
- * @template T Expected type of parsed value
541
- * @param input JSON string
542
- * @returns Parsed value when exact type, otherwise `null`
543
- *
544
- * @author Jeongho Nam - https://github.com/samchon
545
- */
546
- export function isParse(input: string): never;
547
-
548
- /**
549
- * Safe `JSON.parse()` function with type checking.
550
- *
551
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
552
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
553
- * instance with type checking.
554
- *
555
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
556
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
557
- * value would be returned.
558
- *
559
- * @template T Expected type of parsed value
560
- * @param input JSON string
561
- * @returns Parsed value when exact type, otherwise `null`
562
- *
563
- * @author Jeongho Nam - https://github.com/samchon
564
- */
565
- export function isParse<T>(input: string): T | null;
566
-
567
- /**
568
- * @internal
569
- */
570
- export function isParse<T>(): T | null {
571
- halt("isParse");
572
- }
573
- Object.assign(isParse, is);
574
-
575
- /**
576
- * > You must configure the generic argument `T`.
577
- *
578
- * Safe `JSON.parse()` function with detailed type validation.
579
- *
580
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
581
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
582
- * to a `T` typed instance with detailed type validation.
583
- *
584
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
585
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
586
- * there's no problem on the parsed value, the parsed value would be stored in `data`
587
- * property of the output {@link IValidation.ISuccess} instance.
588
- *
589
- * @template T Expected type of parsed value
590
- * @param input JSON string
591
- * @returns Validation result with JSON parsed value
592
- *
593
- * @author Jeongho Nam - https://github.com/samchon
594
- */
595
- export function validateParse(input: string): never;
596
-
597
- /**
598
- * Safe `JSON.parse()` function with detailed type validation.
599
- *
600
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
601
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
602
- * to a `T` typed instance with detailed type validation.
603
- *
604
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
605
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
606
- * there's no problem on the parsed value, the parsed value would be stored in `data`
607
- * property of the output {@link IValidation.ISuccess} instance.
608
- *
609
- * @template T Expected type of parsed value
610
- * @param input JSON string
611
- * @returns Validation result with JSON parsed value
612
- *
613
- * @author Jeongho Nam - https://github.com/samchon
614
- */
615
- export function validateParse<T>(input: string): IValidation<T>;
616
-
617
- /**
618
- * @internal
619
- */
620
- export function validateParse<T>(): IValidation<T> {
621
- halt("validateParse");
622
- }
623
- Object.assign(validateParse, validate);
624
-
625
- /**
626
- * 8x faster `JSON.stringify()` function.
627
- *
628
- * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
629
- * than the native `JSON.stringify()` function. The 5x faster principle is because
630
- * it writes an optimized JSON conversion plan, only for the type `T`.
631
- *
632
- * For reference, this `typia.stringify()` does not validate the input value type.
633
- * It just believes that the input value is following the type `T`. Therefore, if you
634
- * can't ensure the input value type, it would be better to call one of below functions
635
- * instead.
636
- *
637
- * - {@link assertStringify}
638
- * - {@link isStringify}
639
- * - {@link validateStringify}
640
- *
641
- * @template T Type of the input value
642
- * @param input A value to be converted
643
- * @return JSON string value
644
- *
645
- * @author Jeongho Nam - https://github.com/samchon
646
- */
647
- export function stringify<T>(input: T): string;
648
-
649
- /**
650
- * @internal
651
- */
652
- export function stringify(): never {
653
- halt("stringify");
654
- }
655
- Object.assign(stringify, Namespace.stringify("stringify"));
656
-
657
- /**
658
- * 5x faster `JSON.stringify()` function with type assertion.
659
- *
660
- * `typia.assertStringify()` is a combination function of {@link assert} and
661
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
662
- * Notation) string, with type assertion.
663
- *
664
- * In such reason, when `input` value is not matched with the type `T`, it throws an
665
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
666
- * string would be returned.
667
- *
668
- * For reference, with type assertion, it is even 5x times faster than the native
669
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
670
- * with confidence.
671
- *
672
- * @template T Type of the input value
673
- * @param input A value to be asserted and converted
674
- * @return JSON string value
675
- *
676
- * @author Jeongho Nam - https://github.com/samchon
677
- */
678
- export function assertStringify<T>(input: T): string;
679
-
680
- /**
681
- * 5x faster `JSON.stringify()` function with type assertion.
682
- *
683
- * `typia.assertStringify()` is a combination function of {@link assert} and
684
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
685
- * Notation) string, with type assertion.
686
- *
687
- * In such reason, when `input` value is not matched with the type `T`, it throws an
688
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
689
- * string would be returned.
690
- *
691
- * For reference, with type assertion, it is even 5x times faster than the native
692
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
693
- * with confidence.
694
- *
695
- * @template T Type of the input value
696
- * @param input A value to be asserted and converted
697
- * @return JSON string value
698
- *
699
- * @author Jeongho Nam - https://github.com/samchon
700
- */
701
- export function assertStringify<T>(input: T): unknown;
702
-
703
- /**
704
- * @internal
705
- */
706
- export function assertStringify(): string {
707
- halt("assertStringify");
708
- }
709
- Object.assign(assertStringify, Namespace.assert("assertStringify"));
710
- Object.assign(assertStringify, Namespace.stringify("assertStringify"));
711
-
712
- /**
713
- * 7x faster `JSON.stringify()` function with type checking.
714
- *
715
- * `typia.stringify()` is a combination function of {@link is} and
716
- * {@link stringify}. Therefore, it converts an input value to JSON
717
- * (JavaScript Object Notation) string, with type checking.
718
- *
719
- * In such reason, when `input` value is not matched with the type `T`, it returns
720
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
721
- * be returned.
722
- *
723
- * For reference, with type checking, it is even 7x times faster than the native
724
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
725
- * with confidence.
726
- *
727
- * @template T Type of the input value
728
- * @param input A value to be checked and converted
729
- * @return JSON string value when exact type, otherwise null
730
- *
731
- * @author Jeongho Nam - https://github.com/samchon
732
- */
733
- export function isStringify<T>(input: T): string | null;
734
-
735
- /**
736
- * 7x faster `JSON.stringify()` function with type checking.
737
- *
738
- * `typia.isStringify()` is a combination function of {@link is} and
739
- * {@link stringify}. Therefore, it converts an input value to JSON
740
- * (JavaScript Object Notation) string, with type checking.
741
- *f
742
- * In such reason, when `input` value is not matched with the type `T`, it returns
743
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
744
- * be returned.
745
- *
746
- * For reference, with type checking, it is even 7x times faster than the native
747
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
748
- * with confidence.
749
- *
750
- * @template T Type of the input value
751
- * @param input A value to be checked and converted
752
- * @return JSON string value when exact type, otherwise null
753
- *
754
- * @author Jeongho Nam - https://github.com/samchon
755
- */
756
- export function isStringify<T>(input: unknown): string | null;
757
-
758
- /**
759
- * @internal
760
- */
761
- export function isStringify(): string | null {
762
- halt("isStringify");
763
- }
764
-
765
- Object.assign(isStringify, Namespace.is());
766
- Object.assign(isStringify, Namespace.stringify("isStringify"));
767
-
768
- /**
769
- * 5x faster `JSON.stringify()` function with detailed type validation.
770
- *
771
- * `typia.validateStringify()` is a combination function of {@link validate} and
772
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
773
- * Notation) string, with detailed type validation.
774
- *
775
- * In such reason, when `input` value is not matched with the type `T`, it returns
776
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
777
- * problem on the `input` value, JSON string would be stored in `data` property of
778
- * the output {@link IValidation.ISuccess} instance.
779
- *
780
- * For reference, with detailed type validation, it is even 5x times faster than the
781
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
782
- * with confidence.
783
- *
784
- * @template T Type of the input value
785
- * @param input A value to be checked and converted
786
- * @returns Validation result with JSON string value
787
- *
788
- * @author Jeongho Nam - https://github.com/samchon
789
- */
790
- export function validateStringify<T>(input: T): IValidation<string>;
791
-
792
- /**
793
- * 5x faster `JSON.stringify()` function with detailed type validation.
794
- *
795
- * `typia.validateStringify()` is a combination function of {@link validate} and
796
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
797
- * Notation) string, with detailed type validation.
798
- *
799
- * In such reason, when `input` value is not matched with the type `T`, it returns
800
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
801
- * problem on the `input` value, JSON string would be stored in `data` property of
802
- * the output {@link IValidation.ISuccess} instance.
803
- *
804
- * For reference, with detailed type validation, it is even 5x times faster than the
805
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
806
- * with confidence.
807
- *
808
- * @template T Type of the input value
809
- * @param input A value to be checked and converted
810
- * @returns Validation result with JSON string value
811
- *
812
- * @author Jeongho Nam - https://github.com/samchon
813
- */
814
- export function validateStringify<T>(input: unknown): IValidation<string>;
815
-
816
- /**
817
- * @internal
818
- */
819
- export function validateStringify(): IValidation<string> {
820
- halt("validateStringify");
821
- }
822
- Object.assign(validateStringify, Namespace.validate());
823
- Object.assign(validateStringify, Namespace.stringify("validateStringify"));
824
-
825
- /* -----------------------------------------------------------
826
- MISCELLANEOUS
827
- ----------------------------------------------------------- */
828
- /**
829
- * @internal
830
- */
831
- export function metadata(): never;
832
-
833
- /**
834
- * @internal
835
- */
836
- export function metadata<Types extends unknown[]>(): IMetadataApplication;
837
-
838
- /**
839
- * @internal
840
- */
841
- export function metadata(): never {
842
- halt("metadata");
843
- }
844
-
845
- /**
846
- * > You must configure the generic argument `T`.
847
- *
848
- * Generate random data.
849
- *
850
- * Generates a random data following type the `T`.
851
- *
852
- * For reference, this `typia.random()` function generates only primitive type.
853
- * If there're some methods in the type `T` or its nested instances, those would
854
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
855
- * would be generated instead.
856
- *
857
- * @template T Type of data to generate
858
- * @param generator Random data generator
859
- * @return Randomly generated data
860
- *
861
- * @author Jeongho Nam - https://github.com/samchon
862
- */
863
- export function random(generator?: Partial<IRandomGenerator>): never;
864
-
865
- /**
866
- * Generate random data.
867
- *
868
- * Generates a random data following type the `T`.
869
- *
870
- * For reference, this `typia.random()` function generates only primitive type.
871
- * If there're some methods in the type `T` or its nested instances, those would
872
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
873
- * would be generated instead.
874
- *
875
- * @template T Type of data to generate
876
- * @param generator Random data generator
877
- * @return Randomly generated data
878
- *
879
- * @author Jeongho Nam - https://github.com/samchon
880
- */
881
- export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
882
-
883
- /**
884
- * @internal
885
- */
886
- export function random(): never {
887
- halt("random");
888
- }
889
- Object.assign(random, Namespace.random());
890
-
891
- /**
892
- * Clone a data.
893
- *
894
- * Clones an instance following type `T`. If the target *input* value or its member
895
- * variable contains a class instance that is having a `toJSON()` method, its return
896
- * value would be cloned.
897
- *
898
- * For reference, this `typia.clone()` function does not validate the input value type.
899
- * It just believes that the input value is following the type `T`. Therefore, if you
900
- * can't ensure the input value type, it would be better to call {@link assertClone}
901
- * function instead.
902
- *
903
- * @template T Type of the input value
904
- * @param input A value to be cloned
905
- * @return Cloned data
906
- *
907
- * @author Jeongho Nam - https://github.com/samchon
908
- */
909
- export function clone<T>(input: T): Primitive<T>;
910
-
911
- /**
912
- * @internal
913
- */
914
- export function clone(): never {
915
- halt("clone");
916
- }
917
- Object.assign(clone, Namespace.clone("clone"));
918
-
919
- /**
920
- * Clone a data with type assertion.
921
- *
922
- * Clones an instance following type `T`, with type assertion. If the target `input`
923
- * value or its member variable contains a class instance that is having a `toJSON()`
924
- * method, its return value would be cloned.
925
- *
926
- * In such reason, when `input` value is not matched with the type `T`, it throws an
927
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
928
- * data would be returned.
929
- *
930
- * @template T Type of the input value
931
- * @param input A value to be cloned
932
- * @return Cloned data
933
- *
934
- * @author Jeongho Nam - https://github.com/samchon
935
- */
936
- export function assertClone<T>(input: T): Primitive<T>;
937
-
938
- /**
939
- * Clone a data with type assertion.
940
- *
941
- * Clones an instance following type `T`, with type assertion. If the target `input`
942
- * value or its member variable contains a class instance that is having a `toJSON()`
943
- * method, its return value would be cloned.
944
- *
945
- * In such reason, when `input` value is not matched with the type `T`, it throws an
946
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
947
- * data would be returned.
948
- *
949
- * @template T Type of the input value
950
- * @param input A value to be cloned
951
- * @return Cloned data
952
- *
953
- * @author Jeongho Nam - https://github.com/samchon
954
- */
955
- export function assertClone<T>(input: unknown): Primitive<T>;
956
-
957
- /**
958
- * @internal
959
- */
960
- export function assertClone(): never {
961
- halt("assertClone");
962
- }
963
- Object.assign(assertClone, Namespace.assert("assertClone"));
964
- Object.assign(assertClone, Namespace.clone("assertClone"));
965
-
966
- /**
967
- * Clone a data with type checking.
968
- *
969
- * Clones an instance following type `T`, with type checking. If the target `input`
970
- * value or its member variable contains a class instance that is having a `toJSON()`
971
- * method, its return value would be cloned.
972
- *
973
- * In such reason, when `input` value is not matched with the type `T`, it returns
974
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
975
- * data would be returned.
976
- *
977
- * @template T Type of the input value
978
- * @param input A value to be cloned
979
- * @return Cloned data when exact type, otherwise null
980
- *
981
- * @author Jeongho Nam - https://github.com/samchon
982
- */
983
- export function isClone<T>(input: T): Primitive<T> | null;
984
-
985
- /**
986
- * Clone a data with type checking.
987
- *
988
- * Clones an instance following type `T`, with type checking. If the target `input`
989
- * value or its member variable contains a class instance that is having a `toJSON()`
990
- * method, its return value would be cloned.
991
- *
992
- * In such reason, when `input` value is not matched with the type `T`, it returns
993
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
994
- * data would be returned.
995
- *
996
- * @template T Type of the input value
997
- * @param input A value to be cloned
998
- * @return Cloned data when exact type, otherwise null
999
- *
1000
- * @author Jeongho Nam - https://github.com/samchon
1001
- */
1002
- export function isClone<T>(input: unknown): Primitive<T> | null;
1003
-
1004
- /**
1005
- * @internal
1006
- */
1007
- export function isClone(): never {
1008
- halt("isClone");
1009
- }
1010
- Object.assign(isClone, Namespace.is());
1011
- Object.assign(isClone, Namespace.clone("isClone"));
1012
-
1013
- /**
1014
- * Clone a data with detailed type validation.
1015
- *
1016
- * Clones an instance following type `T`, with detailed type validation. If the target
1017
- * `input` value or its member variable contains a class instance that is having a
1018
- * `toJSON()` method, its return value would be cloned.
1019
- *
1020
- * In such reason, when `input` value is not matched with the type `T`, it returns
1021
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1022
- * value, cloned data would be stored in `data` property of the output
1023
- * {@link IValidation.Success} instance.
1024
- *
1025
- * @template T Type of the input value
1026
- * @param input A value to be cloned
1027
- * @returns Validation result with cloned value
1028
- */
1029
- export function validateClone<T>(input: T): IValidation<Primitive<T>>;
1030
-
1031
- /**
1032
- * Clone a data with detailed type validation.
1033
- *
1034
- * Clones an instance following type `T`, with detailed type validation. If the target
1035
- * `input` value or its member variable contains a class instance that is having a
1036
- * `toJSON()` method, its return value would be cloned.
1037
- *
1038
- * In such reason, when `input` value is not matched with the type `T`, it returns
1039
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1040
- * value, cloned data would be stored in `data` property of the output
1041
- * {@link IValidation.Success} instance.
1042
- *
1043
- * @template T Type of the input value
1044
- * @param input A value to be cloned
1045
- * @returns Validation result with cloned value
1046
- */
1047
- export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
1048
-
1049
- /**
1050
- * @internal
1051
- */
1052
- export function validateClone(): never {
1053
- halt("validateClone");
1054
- }
1055
- Object.assign(validateClone, Namespace.validate());
1056
- Object.assign(validateClone, Namespace.clone("validateClone"));
1057
-
1058
- /**
1059
- * Prune, erase superfluous properties.
1060
- *
1061
- * Remove every superfluous properties from the `input` object, even including nested
1062
- * objects. Note that, as every superfluous properties would be deleted, you never can
1063
- * read those superfluous properties after calling this `prune()` function.
1064
- *
1065
- * For reference, this `typia.prune()` function does not validate the input value type.
1066
- * It just believes that the input value is following the type `T`. Therefore, if you
1067
- * can't ensure the input value type, it would better to call one of below functions
1068
- * instead.
1069
- *
1070
- * - {@link assertPrune}
1071
- * - {@link isPrune}
1072
- * - {@link validatePrune}
1073
- *
1074
- * @template T Type of the input value
1075
- * @param input Target instance to prune
1076
- *
1077
- * @author Jeongho Nam - https://github.com/samchon
1078
- */
1079
- export function prune<T extends object>(input: T): void;
1080
-
1081
- /**
1082
- * @internal
1083
- */
1084
- export function prune(): never {
1085
- halt("prune");
1086
- }
1087
- Object.assign(prune, Namespace.prune("prune"));
1088
-
1089
- /**
1090
- * Prune, erase superfluous properties, with type assertion.
1091
- *
1092
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1093
- * Therefore, it removes every superfluous properties from the `input` object including
1094
- * nested objects, with type assertion.
1095
- *
1096
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1097
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1098
- * every superfluous properties would be removed, including nested objects.
1099
- *
1100
- * @template T Type of the input value
1101
- * @param input Target instance to assert and prune
1102
- *
1103
- * @author Jeongho Nam - https://github.com/samchon
1104
- */
1105
- export function assertPrune<T>(input: T): T;
1106
-
1107
- /**
1108
- * Prune, erase superfluous properties, with type assertion.
1109
- *
1110
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1111
- * Therefore, it removes every superfluous properties from the `input` object including
1112
- * nested objects, with type assertion.
1113
- *
1114
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1115
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1116
- * every superfluous properties would be removed, including nested objects.
1117
- *
1118
- * @template T Type of the input value
1119
- * @param input Target instance to assert and prune
1120
- *
1121
- * @author Jeongho Nam - https://github.com/samchon
1122
- */
1123
- export function assertPrune<T>(input: unknown): T;
1124
-
1125
- /**
1126
- * @internal
1127
- */
1128
- export function assertPrune(): unknown {
1129
- halt("assertPrune");
1130
- }
1131
- Object.assign(assertPrune, Namespace.assert("assertPrune"));
1132
- Object.assign(assertPrune, Namespace.prune("assertPrune"));
1133
-
1134
- /**
1135
- * Prune, erase superfluous properties, with type checking.
1136
- *
1137
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1138
- * Therefore, it removes every superfluous properties from the `input` object including
1139
- * nested objects, with type checking.
1140
- *
1141
- * In such reason, when `input` value is not matched with the type `T`, it returns
1142
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1143
- * `true` after removing every superfluous properties, including nested objects.
1144
- *
1145
- * @template T Type of the input value
1146
- * @param input Target instance to check and prune
1147
- * @returns Whether the parametric value is following the type `T` or not
1148
- *
1149
- * @author Jeongho Nam - https://github.com/samchon
1150
- */
1151
- export function isPrune<T>(input: T): input is T;
1152
-
1153
- /**
1154
- * Prune, erase superfluous properties, with type checking.
1155
- *
1156
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1157
- * Therefore, it removes every superfluous properties from the `input` object including
1158
- * nested objects, with type checking.
1159
- *
1160
- * In such reason, when `input` value is not matched with the type `T`, it returns
1161
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1162
- * `true` after removing every superfluous properties, including nested objects.
1163
- *
1164
- * @template T Type of the input value
1165
- * @param input Target instance to check and prune
1166
- * @returns Whether the parametric value is following the type `T` or not
1167
- *
1168
- * @author Jeongho Nam - https://github.com/samchon
1169
- */
1170
- export function isPrune<T>(input: unknown): input is T;
1171
-
1172
- /**
1173
- * @internal
1174
- */
1175
- export function isPrune(): never {
1176
- halt("isPrune");
1177
- }
1178
- Object.assign(isPrune, Namespace.is());
1179
- Object.assign(isPrune, Namespace.prune("isPrune"));
1180
-
1181
- /**
1182
- * Prune, erase superfluous properties, with type validation.
1183
- *
1184
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1185
- * Therefore, it removes every superfluous properties from the `input` object including
1186
- * nested objects, with type validation.
1187
- *
1188
- * In such reason, when `input` value is not matched with the type `T`, it returns
1189
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1190
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1191
- * removing every superfluous properties, including nested objects.
1192
- *
1193
- * @template T Type of the input value
1194
- * @param input Target instance to validate and prune
1195
- * @returns Validation result
1196
- *
1197
- * @author Jeongho Nam - https://github.com/samchon
1198
- */
1199
- export function validatePrune<T>(input: T): IValidation<T>;
1200
-
1201
- /**
1202
- * Prune, erase superfluous properties, with type validation.
1203
- *
1204
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1205
- * Therefore, it removes every superfluous properties from the `input` object including
1206
- * nested objects, with type validation.
1207
- *
1208
- * In such reason, when `input` value is not matched with the type `T`, it returns
1209
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1210
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1211
- * removing every superfluous properties, including nested objects.
1212
- *
1213
- * @template T Type of the input value
1214
- * @param input Target instance to validate and prune
1215
- * @returns Validation result
1216
- *
1217
- * @author Jeongho Nam - https://github.com/samchon
1218
- */
1219
- export function validatePrune<T>(input: unknown): IValidation<T>;
1220
-
1221
- /**
1222
- * @internal
1223
- */
1224
- export function validatePrune<T>(): IValidation<T> {
1225
- halt("validatePrune");
1226
- }
1227
- Object.assign(validatePrune, Namespace.prune("validatePrune"));
1228
- Object.assign(validatePrune, Namespace.validate());
1229
-
1230
- /* ===========================================================
1231
- FACTORY FUNCTIONS
1232
- - BASIC VALIDATORS
1233
- - STRICT VALIDATORS
1234
- - JSON FUNCTIONS
1235
- - MISCELLANEOUS
1236
- ==============================================================
1237
- BASIC VALIDATORS
1238
- ----------------------------------------------------------- */
1239
- /**
1240
- * Creates a reusable {@link assert} function.
1241
- *
1242
- * @danger You have to specify the generic argument `T`
1243
- * @return Nothing until specifying the generic argument `T`
1244
- * @throws compile error
1245
- *
1246
- * @author Jeongho Nam - https://github.com/samchon
1247
- */
1248
- export function createAssert(): never;
1249
-
1250
- /**
1251
- * Creates a reusable {@link assert} function.
1252
- *
1253
- * @template T Type of the input value
1254
- * @returns A reusable `assert` function
1255
- *
1256
- * @author Jeongho Nam - https://github.com/samchon
1257
- */
1258
- export function createAssert<T>(): (input: unknown) => T;
1259
-
1260
- /**
1261
- * @internal
1262
- */
1263
- export function createAssert<T>(): (input: unknown) => T {
1264
- halt("createAssert");
1265
- }
1266
- Object.assign(createAssert, assert);
1267
-
1268
- /**
1269
- * Creates a reusable {@link assertType} function.
1270
- *
1271
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1272
- *
1273
- * @danger You have to specify the generic argument `T`
1274
- * @return Nothing until specifying the generic argument `T`
1275
- * @throws compile error
1276
- *
1277
- * @author Jeongho Nam - https://github.com/samchon
1278
- * @deprecated
1279
- */
1280
- export function createAssertType(): never;
1281
-
1282
- /**
1283
- * Creates a reusable {@link assertType} function.
1284
- *
1285
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1286
- *
1287
- * @template T Type of the input value
1288
- * @returns A reusable `assert` function
1289
- *
1290
- * @author Jeongho Nam - https://github.com/samchon
1291
- * @deprecated
1292
- */
1293
- export function createAssertType<T>(): (input: unknown) => T;
1294
-
1295
- /**
1296
- * @internal
1297
- */
1298
- export function createAssertType<T>(): (input: unknown) => T {
1299
- halt("createAssertType");
1300
- }
1301
- Object.assign(createAssertType, assertType);
1302
-
1303
- /**
1304
- * Creates a reusable {@link is} function.
1305
- *
1306
- * @danger You have to specify the generic argument `T`
1307
- * @return Nothing until specifying the generic argument `T`
1308
- * @throws compile error
1309
- *
1310
- * @author Jeongho Nam - https://github.com/samchon
1311
- */
1312
- export function createIs(): never;
1313
-
1314
- /**
1315
- * Creates a reusable {@link is} function.
1316
- *
1317
- * @template T Type of the input value
1318
- * @returns A reusable `is` function
1319
- *
1320
- * @author Jeongho Nam - https://github.com/samchon
1321
- */
1322
- export function createIs<T>(): (input: unknown) => input is T;
1323
-
1324
- /**
1325
- * @internal
1326
- */
1327
- export function createIs<T>(): (input: unknown) => input is T {
1328
- halt("createIs");
1329
- }
1330
- Object.assign(createIs, is);
1331
-
1332
- /**
1333
- * Creates a reusable {@link validate} function.
1334
- *
1335
- * @danger You have to specify the generic argument `T`
1336
- * @return Nothing until specifying the generic argument `T`
1337
- * @throws compile error
1338
- *
1339
- * @author Jeongho Nam - https://github.com/samchon
1340
- */
1341
- export function createValidate(): never;
1342
-
1343
- /**
1344
- * Creates a reusable {@link validate} function.
1345
- *
1346
- * @template T Type of the input value
1347
- * @returns A reusable `validate` function
1348
- *
1349
- * @author Jeongho Nam - https://github.com/samchon
1350
- */
1351
- export function createValidate<T>(): (input: unknown) => IValidation<T>;
1352
-
1353
- /**
1354
- * @internal
1355
- */
1356
- export function createValidate(): (input: unknown) => IValidation {
1357
- halt("createValidate");
1358
- }
1359
- Object.assign(createValidate, validate);
1360
-
1361
- /* -----------------------------------------------------------
1362
- STRICT VALIDATORS
1363
- ----------------------------------------------------------- */
1364
- /**
1365
- * Creates a reusable {@link assertEquals} function.
1366
- *
1367
- * @danger You have to specify the generic argument `T`
1368
- * @return Nothing until specifying the generic argument `T`
1369
- * @throws compile error
1370
- *
1371
- * @author Jeongho Nam - https://github.com/samchon
1372
- */
1373
- export function createAssertEquals(): never;
1374
-
1375
- /**
1376
- * Creates a reusable {@link assertEquals} function.
1377
- *
1378
- * @template T Type of the input value
1379
- * @returns A reusable `assertEquals` function
1380
- *
1381
- * @author Jeongho Nam - https://github.com/samchon
1382
- */
1383
- export function createAssertEquals<T>(): (input: unknown) => T;
1384
-
1385
- /**
1386
- * @internal
1387
- */
1388
- export function createAssertEquals<T>(): (input: unknown) => T {
1389
- halt("createAssertEquals");
1390
- }
1391
- Object.assign(createAssertEquals, assertEquals);
1392
-
1393
- /**
1394
- * Creates a reusable {@link equals} function.
1395
- *
1396
- * @danger You have to specify the generic argument `T`
1397
- * @return Nothing until specifying the generic argument `T`
1398
- * @throws compile error
1399
- *
1400
- * @author Jeongho Nam - https://github.com/samchon
1401
- */
1402
- export function createEquals(): never;
1403
-
1404
- /**
1405
- * Creates a reusable {@link equals} function.
1406
- *
1407
- * @template T Type of the input value
1408
- * @returns A reusable `equals` function
1409
- *
1410
- * @author Jeongho Nam - https://github.com/samchon
1411
- */
1412
- export function createEquals<T>(): (input: unknown) => input is T;
1413
-
1414
- /**
1415
- * @internal
1416
- */
1417
- export function createEquals<T>(): (input: unknown) => input is T {
1418
- halt("createEquals");
1419
- }
1420
- Object.assign(createEquals, equals);
1421
-
1422
- /**
1423
- * Creates a reusable {@link validateEquals} function.
1424
- *
1425
- * @danger You have to specify the generic argument `T`
1426
- * @return Nothing until specifying the generic argument `T`
1427
- * @throws compile error
1428
- *
1429
- * @author Jeongho Nam - https://github.com/samchon
1430
- */
1431
- export function createValidateEquals(): never;
1432
-
1433
- /**
1434
- * Creates a reusable {@link validateEquals} function.
1435
- *
1436
- * @template T Type of the input value
1437
- * @returns A reusable `validateEquals` function
1438
- *
1439
- * @author Jeongho Nam - https://github.com/samchon
1440
- */
1441
- export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
1442
-
1443
- /**
1444
- * @internal
1445
- */
1446
- export function createValidateEquals(): (input: unknown) => IValidation {
1447
- halt("createValidateEquals");
1448
- }
1449
- Object.assign(createValidateEquals, validateEquals);
1450
-
1451
- /* -----------------------------------------------------------
1452
- JSON FUNCTIONS
1453
- ----------------------------------------------------------- */
1454
- /**
1455
- * Creates a reusable {@link isParse} function.
1456
- *
1457
- * @danger You have to specify the generic argument `T`
1458
- * @return Nothing until specifying the generic argument `T`
1459
- * @throws compile error
1460
- *
1461
- * @author Jeongho Nam - https://github.com/samchon
1462
- */
1463
- export function createIsParse(): never;
1464
-
1465
- /**
1466
- * Creates a reusable {@link isParse} function.
1467
- *
1468
- * @template T Expected type of parsed value
1469
- * @returns A reusable `isParse` function
1470
- *
1471
- * @author Jeongho Nam - https://github.com/samchon
1472
- */
1473
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
1474
-
1475
- /**
1476
- * @internal
1477
- */
1478
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
1479
- halt("createIsParse");
1480
- }
1481
- Object.assign(createIsParse, isParse);
1482
-
1483
- /**
1484
- * Creates a reusable {@link assertParse} function.
1485
- *
1486
- * @danger You have to specify the generic argument `T`
1487
- * @return Nothing until specifying the generic argument `T`
1488
- * @throws compile error
1489
- *
1490
- * @author Jeongho Nam - https://github.com/samchon
1491
- */
1492
- export function createAssertParse(): never;
1493
-
1494
- /**
1495
- * Creates a reusable {@link assertParse} function.
1496
- *
1497
- * @template T Expected type of parsed value
1498
- * @returns A reusable `assertParse` function
1499
- *
1500
- * @author Jeongho Nam - https://github.com/samchon
1501
- */
1502
- export function createAssertParse<T>(): (input: string) => Primitive<T>;
1503
-
1504
- /**
1505
- * @internal
1506
- */
1507
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
1508
- halt("createAssertParse");
1509
- }
1510
- Object.assign(createAssertParse, assertParse);
1511
-
1512
- /**
1513
- * Creates a reusable {@link validateParse} function.
1514
- *
1515
- * @danger You have to specify the generic argument `T`
1516
- * @return Nothing until specifying the generic argument `T`
1517
- * @throws compile error
1518
- *
1519
- * @author Jeongho Nam - https://github.com/samchon
1520
- */
1521
- export function createValidateParse(): never;
1522
-
1523
- /**
1524
- * Creates a reusable {@link validateParse} function.
1525
- *
1526
- * @template T Expected type of parsed value
1527
- * @returns A reusable `validateParse` function
1528
- *
1529
- * @author Jeongho Nam - https://github.com/samchon
1530
- */
1531
- export function createValidateParse<T>(): (
1532
- input: string,
1533
- ) => IValidation<Primitive<T>>;
1534
-
1535
- /**
1536
- * @internal
1537
- */
1538
- export function createValidateParse<T>(): (
1539
- input: string,
1540
- ) => IValidation<Primitive<T>> {
1541
- halt("createValidateParse");
1542
- }
1543
- Object.assign(createValidateParse, validateParse);
1544
-
1545
- /**
1546
- * Creates a reusable {@link stringify} function.
1547
- *
1548
- * @danger You have to specify the generic argument `T`
1549
- * @return Nothing until specifying the generic argument `T`
1550
- * @throws compile error
1551
- *
1552
- * @author Jeongho Nam - https://github.com/samchon
1553
- */
1554
- export function createStringify(): never;
1555
-
1556
- /**
1557
- * Creates a reusable {@link stringify} function.
1558
- *
1559
- * @template T Type of the input value
1560
- * @returns A reusable `stringify` function
1561
- *
1562
- * @author Jeongho Nam - https://github.com/samchon
1563
- */
1564
- export function createStringify<T>(): (input: T) => string;
1565
-
1566
- /**
1567
- * @internal
1568
- */
1569
- export function createStringify<T>(): (input: T) => string {
1570
- halt("createStringify");
1571
- }
1572
- Object.assign(createStringify, stringify);
1573
-
1574
- /**
1575
- * Creates a reusable {@link assertStringify} function.
1576
- *
1577
- * @danger You have to specify the generic argument `T`
1578
- * @return Nothing until specifying the generic argument `T`
1579
- * @throws compile error
1580
- *
1581
- * @author Jeongho Nam - https://github.com/samchon
1582
- */
1583
- export function createAssertStringify(): never;
1584
-
1585
- /**
1586
- * Creates a reusable {@link assertStringify} function.
1587
- *
1588
- * @template T Type of the input value
1589
- * @returns A reusable `assertStringify` function
1590
- *
1591
- * @author Jeongho Nam - https://github.com/samchon
1592
- */
1593
- export function createAssertStringify<T>(): (input: unknown) => string;
1594
-
1595
- /**
1596
- * @internal
1597
- */
1598
- export function createAssertStringify(): (input: unknown) => string {
1599
- halt("createAssertStringify");
1600
- }
1601
- Object.assign(createAssertStringify, assertStringify);
1602
-
1603
- /**
1604
- * Creates a reusable {@link isStringify} function.
1605
- *
1606
- * @danger You have to specify the generic argument `T`
1607
- * @return Nothing until specifying the generic argument `T`
1608
- * @throws compile error
1609
- *
1610
- * @author Jeongho Nam - https://github.com/samchon
1611
- */
1612
- export function createIsStringify(): never;
1613
-
1614
- /**
1615
- * Creates a reusable {@link isStringify} function.
1616
- *
1617
- * @template T Type of the input value
1618
- * @returns A reusable `isStringify` function
1619
- *
1620
- * @author Jeongho Nam - https://github.com/samchon
1621
- */
1622
- export function createIsStringify<T>(): (input: unknown) => string | null;
1623
-
1624
- /**
1625
- * @internal
1626
- */
1627
- export function createIsStringify(): (input: unknown) => string | null {
1628
- halt("createIsStringify");
1629
- }
1630
- Object.assign(createIsStringify, isStringify);
1631
-
1632
- /**
1633
- * Creates a reusable {@link validateStringify} function.
1634
- *
1635
- * @danger You have to specify the generic argument `T`
1636
- * @return Nothing until specifying the generic argument `T`
1637
- * @throws compile error
1638
- *
1639
- * @author Jeongho Nam - https://github.com/samchon
1640
- */
1641
- export function createValidateStringify(): never;
1642
-
1643
- /**
1644
- * Creates a reusable {@link validateStringify} function.
1645
- *
1646
- * @template T Type of the input value
1647
- * @returns A reusable `validateStringify` function
1648
-
1649
- * @author Jeongho Nam - https://github.com/samchon
1650
- */
1651
- export function createValidateStringify<T>(): (
1652
- input: unknown,
1653
- ) => IValidation<string>;
1654
-
1655
- /**
1656
- * @internal
1657
- */
1658
- export function createValidateStringify(): (
1659
- input: unknown,
1660
- ) => IValidation<string> {
1661
- halt("createValidateStringify");
1662
- }
1663
- Object.assign(createValidateStringify, validateStringify);
1664
-
1665
- /* -----------------------------------------------------------
1666
- MISCELLANEOUS
1667
- ----------------------------------------------------------- */
1668
- /**
1669
- * Creates a reusable {@link random} function.
1670
- *
1671
- * @danger You have to specify the generic argument `T`
1672
- * @param generator Random data generator
1673
- * @return Nothing until specifying the generic argument `T`
1674
- * @throws compile error
1675
- *
1676
- * @author Jeongho Nam - https://github.com/samchon
1677
- */
1678
- export function createRandom(generator?: Partial<IRandomGenerator>): never;
1679
-
1680
- /**
1681
- * Creates a resuable {@link random} function.
1682
- *
1683
- * @template T Type of the input value
1684
- * @param generator Random data generator
1685
- * @returns A reusable `random` function
1686
- *
1687
- * @author Jeongho Nam - https://github.com/samchon
1688
- */
1689
- export function createRandom<T>(
1690
- generator?: Partial<IRandomGenerator>,
1691
- ): () => Primitive<T>;
1692
-
1693
- /**
1694
- * @internal
1695
- */
1696
- export function createRandom(): never {
1697
- halt("createRandom");
1698
- }
1699
- Object.assign(createRandom, random);
1700
-
1701
- /**
1702
- * Creates a reusable {@link clone} function.
1703
- *
1704
- * @danger You have to specify the generic argument `T`
1705
- * @return Nothing until specifying the generic argument `T`
1706
- * @throws compile error
1707
- *
1708
- * @author Jeongho Nam - https://github.com/samchon
1709
- */
1710
- export function createClone(): never;
1711
-
1712
- /**
1713
- * Creates a resuable {@link clone} function.
1714
- *
1715
- * @template T Type of the input value
1716
- * @returns A reusable `clone` function
1717
- *
1718
- * @author Jeongho Nam - https://github.com/samchon
1719
- */
1720
- export function createClone<T>(): (input: T) => Primitive<T>;
1721
-
1722
- /**
1723
- * @internal
1724
- */
1725
- export function createClone(): never {
1726
- halt("createClone");
1727
- }
1728
- Object.assign(createClone, clone);
1729
-
1730
- /**
1731
- * Creates a reusable {@link assertClone} function.
1732
- *
1733
- * @danger You have to specify the generic argument `T`
1734
- * @return Nothing until specifying the generic argument `T`
1735
- * @throws compile error
1736
- *
1737
- * @author Jeongho Nam - https://github.com/samchon
1738
- */
1739
- export function createAssertClone(): never;
1740
-
1741
- /**
1742
- * Creates a resuable {@link assertClone} function.
1743
- *
1744
- * @template T Type of the input value
1745
- * @returns A reusable `clone` function
1746
- *
1747
- * @author Jeongho Nam - https://github.com/samchon
1748
- */
1749
- export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
1750
-
1751
- /**
1752
- * @internal
1753
- */
1754
- export function createAssertClone(): never {
1755
- halt("createAssertClone");
1756
- }
1757
- Object.assign(createAssertClone, assertClone);
1758
-
1759
- /**
1760
- * Creates a reusable {@link isClone} function.
1761
- *
1762
- * @danger You have to specify the generic argument `T`
1763
- * @return Nothing until specifying the generic argument `T`
1764
- * @throws compile error
1765
- *
1766
- * @author Jeongho Nam - https://github.com/samchon
1767
- */
1768
- export function createIsClone(): never;
1769
-
1770
- /**
1771
- * Creates a resuable {@link isClone} function.
1772
- *
1773
- * @template T Type of the input value
1774
- * @returns A reusable `clone` function
1775
- *
1776
- * @author Jeongho Nam - https://github.com/samchon
1777
- */
1778
- export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
1779
-
1780
- /**
1781
- * @internal
1782
- */
1783
- export function createIsClone(): never {
1784
- halt("createIsClone");
1785
- }
1786
- Object.assign(createIsClone, isClone);
1787
-
1788
- /**
1789
- * Creates a reusable {@link validateClone} function.
1790
- *
1791
- * @danger You have to specify the generic argument `T`
1792
- * @return Nothing until specifying the generic argument `T`
1793
- * @throws compile error
1794
- *
1795
- * @author Jeongho Nam - https://github.com/samchon
1796
- */
1797
- export function createValidateClone(): never;
1798
-
1799
- /**
1800
- * Creates a resuable {@link validateClone} function.
1801
- *
1802
- * @template T Type of the input value
1803
- * @returns A reusable `clone` function
1804
- *
1805
- * @author Jeongho Nam - https://github.com/samchon
1806
- */
1807
- export function createValidateClone<T>(): (
1808
- input: unknown,
1809
- ) => IValidation<Primitive<T>>;
1810
-
1811
- /**
1812
- * @internal
1813
- */
1814
- export function createValidateClone(): never {
1815
- halt("createValidateClone");
1816
- }
1817
- Object.assign(createValidateClone, validateClone);
1818
-
1819
- /**
1820
- * Creates a reusable {@link prune} function.
1821
- *
1822
- * @danger You have to specify the generic argument `T`
1823
- * @return Nothing until specifying the generic argument `T`
1824
- * @throws compile error
1825
- *
1826
- * @author Jeongho Nam - https://github.com/samchon
1827
- */
1828
- export function createPrune(): never;
1829
-
1830
- /**
1831
- * Creates a resuable {@link prune} function.
1832
- *
1833
- * @template T Type of the input value
1834
- * @returns A reusable `prune` function
1835
- *
1836
- * @author Jeongho Nam - https://github.com/samchon
1837
- */
1838
- export function createPrune<T extends object>(): (input: T) => void;
1839
-
1840
- /**
1841
- * @internal
1842
- */
1843
- export function createPrune<T extends object>(): (input: T) => void {
1844
- halt("createPrune");
1845
- }
1846
- Object.assign(createPrune, prune);
1847
-
1848
- /**
1849
- * Creates a reusable {@link assertPrune} function.
1850
- *
1851
- * @danger You have to specify the generic argument `T`
1852
- * @return Nothing until specifying the generic argument `T`
1853
- * @throws compile error
1854
- *
1855
- * @author Jeongho Nam - https://github.com/samchon
1856
- */
1857
- export function createAssertPrune(): never;
1858
-
1859
- /**
1860
- * Creates a resuable {@link assertPrune} function.
1861
- *
1862
- * @template T Type of the input value
1863
- * @returns A reusable `isPrune` function
1864
- *
1865
- * @author Jeongho Nam - https://github.com/samchon
1866
- */
1867
- export function createAssertPrune<T extends object>(): (input: T) => T;
1868
-
1869
- /**
1870
- * @internal
1871
- */
1872
- export function createAssertPrune<T extends object>(): (input: T) => T {
1873
- halt("createAssertPrune");
1874
- }
1875
- Object.assign(createAssertPrune, assertPrune);
1876
-
1877
- /**
1878
- * Creates a reusable {@link isPrune} function.
1879
- *
1880
- * @danger You have to specify the generic argument `T`
1881
- * @return Nothing until specifying the generic argument `T`
1882
- * @throws compile error
1883
- *
1884
- * @author Jeongho Nam - https://github.com/samchon
1885
- */
1886
- export function createIsPrune(): never;
1887
-
1888
- /**
1889
- * Creates a resuable {@link isPrune} function.
1890
- *
1891
- * @template T Type of the input value
1892
- * @returns A reusable `isPrune` function
1893
- *
1894
- * @author Jeongho Nam - https://github.com/samchon
1895
- */
1896
- export function createIsPrune<T extends object>(): (input: T) => input is T;
1897
-
1898
- /**
1899
- * @internal
1900
- */
1901
- export function createIsPrune<T extends object>(): (input: T) => input is T {
1902
- halt("createIsPrune");
1903
- }
1904
- Object.assign(createIsPrune, isPrune);
1905
-
1906
- /**
1907
- * Creates a reusable {@link validatePrune} function.
1908
- *
1909
- * @danger You have to specify the generic argument `T`
1910
- * @return Nothing until specifying the generic argument `T`
1911
- * @throws compile error
1912
- *
1913
- * @author Jeongho Nam - https://github.com/samchon
1914
- */
1915
- export function createValidatePrune(): never;
1916
-
1917
- /**
1918
- * Creates a resuable {@link validatePrune} function.
1919
- *
1920
- * @template T Type of the input value
1921
- * @returns A reusable `validatePrune` function
1922
- *
1923
- * @author Jeongho Nam - https://github.com/samchon
1924
- */
1925
- export function createValidatePrune<T extends object>(): (
1926
- input: T,
1927
- ) => IValidation<T>;
1928
-
1929
- /**
1930
- * @internal
1931
- */
1932
- export function createValidatePrune<T extends object>(): (
1933
- input: T,
1934
- ) => IValidation<T> {
1935
- halt("createValidatePrune");
1936
- }
1937
- Object.assign(createValidatePrune, validatePrune);
1938
-
1939
- /**
1940
- * @internal
1941
- */
1942
- function halt(name: string): never {
1943
- throw new Error(
1944
- `Error on typia.${name}(): no transform has been configured. Configure the "tsconfig.json" file following the [README.md#setup](https://github.com/samchon/typia#setup)`,
1945
- );
1946
- }
1
+ import { $dictionary } from "./functional/$dictionary";
2
+ import { Namespace } from "./functional/Namespace";
3
+
4
+ import { IMetadataApplication } from "./metadata/IMetadataApplication";
5
+ import { IJsonApplication } from "./schemas/IJsonApplication";
6
+
7
+ import { Customizable } from "./typings/Customizable";
8
+
9
+ import { IRandomGenerator } from "./IRandomGenerator";
10
+ import { IValidation } from "./IValidation";
11
+ import { Primitive } from "./Primitive";
12
+ import { TypeGuardError } from "./TypeGuardError";
13
+
14
+ export * from "./schemas/IJsonApplication";
15
+ export * from "./schemas/IJsonComponents";
16
+ export * from "./schemas/IJsonSchema";
17
+ export * from "./IRandomGenerator";
18
+ export * from "./IValidation";
19
+ export * from "./Primitive";
20
+ export * from "./TypeGuardError";
21
+
22
+ /* ===========================================================
23
+ SINGLE FUNCTIONS
24
+ - BASIC VALIDATORS
25
+ - STRICT VALIDATORS
26
+ - JSON FUNCTIONS
27
+ - MISCELLANEOUS
28
+ ==============================================================
29
+ BASIC VALIDATORS
30
+ ----------------------------------------------------------- */
31
+ /**
32
+ * Asserts a value type.
33
+ *
34
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
35
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
36
+ * value is following the type `T`, just input parameter would be returned.
37
+ *
38
+ * If what you want is not asserting but just knowing whether the parametric value is
39
+ * following the type `T` or not, you can choose the {@link is} function instead.
40
+ * Otherwise you want to know all the errors, {@link validate} is the way to go.
41
+ *
42
+ * On the other and, if you don't want to allow any superfluous property that is not
43
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
44
+ *
45
+ * @template T Type of the input value
46
+ * @param input A value to be asserted
47
+ * @returns Parametric input value
48
+ * @throws A {@link TypeGuardError} instance with detailed reason
49
+ *
50
+ * @author Jeongho Nam - https://github.com/samchon
51
+ */
52
+ export function assert<T>(input: T): T;
53
+
54
+ /**
55
+ * Asserts a value type.
56
+ *
57
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
58
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
59
+ * value is following the type `T`, just input parameter would be returned.
60
+ *
61
+ * If what you want is not asserting but just knowing whether the parametric value is
62
+ * following the type `T` or not, you can choose the {@link is} function instead.
63
+ * Otherwise, you want to know all the errors, {@link validate} is the way to go.
64
+ *
65
+ * On the other and, if you don't want to allow any superfluous property that is not
66
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
67
+ *
68
+ * @template T Type of the input value
69
+ * @param input A value to be asserted
70
+ * @returns Parametric input value casted as `T`
71
+ * @throws A {@link TypeGuardError} instance with detailed reason
72
+ *
73
+ * @author Jeongho Nam - https://github.com/samchon
74
+ */
75
+ export function assert<T>(input: unknown): T;
76
+
77
+ /**
78
+ * @internal
79
+ */
80
+ export function assert(): never {
81
+ halt("assert");
82
+ }
83
+ Object.assign(assert, Namespace.assert("assert"));
84
+
85
+ /**
86
+ * Asserts a value type.
87
+ *
88
+ * Duplicated function of {@link assert} for `typescript-is` users.
89
+ *
90
+ * @template T Type of the input value
91
+ * @param input A value to be asserted
92
+ * @returns Parametric input value
93
+ * @throws A {@link TypeGuardError} instance with detailed reason
94
+ *
95
+ * @author Jeongho Nam - https://github.com/samchon
96
+ * @deprecated
97
+ */
98
+ export function assertType<T>(input: T): T;
99
+
100
+ /**
101
+ * Asserts a value type.
102
+ *
103
+ * Duplicated function of {@link assert} for `typescript-is` users.
104
+ *
105
+ * @template T Type of the input value
106
+ * @param input A value to be asserted
107
+ * @returns Parametric input value
108
+ * @throws A {@link TypeGuardError} instance with detailed reason
109
+ *
110
+ * @author Jeongho Nam - https://github.com/samchon
111
+ * @deprecated
112
+ */
113
+ export function assertType<T>(input: unknown): T;
114
+
115
+ /**
116
+ * @internal
117
+ */
118
+ export function assertType(): never {
119
+ halt("assertType");
120
+ }
121
+ Object.assign(assertType, Namespace.assert("assertType"));
122
+
123
+ /**
124
+ * Tests a value type.
125
+ *
126
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
127
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
128
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
129
+ * returned.
130
+ *
131
+ * If what you want is not just knowing whether the parametric value is following the
132
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
133
+ * {@link assert} function instead. Also, if you want to know all the errors with
134
+ * detailed reasons, {@link validate} function would be useful.
135
+ *
136
+ * On the other and, if you don't want to allow any superfluous property that is not
137
+ * enrolled to the type `T`, you can use {@link equals} function instead.
138
+ *
139
+ * @template T Type of the input value
140
+ * @param input A value to be tested
141
+ * @returns Whether the parametric value is following the type `T` or not
142
+ *
143
+ * @author Jeongho Nam - https://github.com/samchon
144
+ */
145
+ export function is<T>(input: T): input is T;
146
+
147
+ /**
148
+ * Tests a value type.
149
+ *
150
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
151
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
152
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
153
+ * returned.
154
+ *
155
+ * If what you want is not just knowing whether the parametric value is following the
156
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
157
+ * {@link assert} function instead. Also, if you want to know all the errors with
158
+ * detailed reasons, {@link validate} function would be useful.
159
+ *
160
+ * On the other and, if you don't want to allow any superfluous property that is not
161
+ * enrolled to the type `T`, you can use {@link equals} function instead.
162
+ *
163
+ * @template T Type of the input value
164
+ * @param input A value to be tested
165
+ * @returns Whether the parametric value is following the type `T` or not
166
+ *
167
+ * @author Jeongho Nam - https://github.com/samchon
168
+ */
169
+ export function is<T>(input: unknown): input is T;
170
+
171
+ /**
172
+ * @internal
173
+ */
174
+ export function is(): never {
175
+ halt("is");
176
+ }
177
+ Object.assign(is, Namespace.assert("is"));
178
+
179
+ /**
180
+ * Validates a value type.
181
+ *
182
+ * Validates a parametric value type and archives all the type errors into an
183
+ * {@link IValidation.errors} array, if the parametric value is not following the
184
+ * type `T`. Of course, if the parametric value is following the type `T`, the
185
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
186
+ * would have the `true` value.
187
+ *
188
+ * If what you want is not finding all the error, but asserting the parametric value
189
+ * type with exception throwing, you can choose {@link assert} function instead.
190
+ * Otherwise, you just want to know whether the parametric value is matched with the
191
+ * type `T`, {@link is} function is the way to go.
192
+ *
193
+ * On the other and, if you don't want to allow any superfluous property that is not
194
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
195
+ *
196
+ * @template Type of the input value
197
+ * @param input A value to be validated
198
+ * @returns Validation result
199
+ *
200
+ * @author Jeongho Nam - https://github.com/samchon
201
+ */
202
+ export function validate<T>(input: T): IValidation<T>;
203
+
204
+ /**
205
+ * Validates a value type.
206
+ *
207
+ * Validates a parametric value type and archives all the type errors into an
208
+ * {@link IValidation.errors} array, if the parametric value is not following the
209
+ * type `T`. Of course, if the parametric value is following the type `T`, the
210
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
211
+ * would have the `true` value.
212
+ *
213
+ * If what you want is not finding all the error, but asserting the parametric value
214
+ * type with exception throwing, you can choose {@link assert} function instead.
215
+ * Otherwise, you just want to know whether the parametric value is matched with the
216
+ * type `T`, {@link is} function is the way to go.
217
+ *
218
+ * On the other and, if you don't want to allow any superfluous property that is not
219
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
220
+ *
221
+ * @template Type of the input value
222
+ * @param input A value to be validated
223
+ * @returns Validation result
224
+ *
225
+ * @author Jeongho Nam - https://github.com/samchon
226
+ */
227
+ export function validate<T>(input: unknown): IValidation<T>;
228
+
229
+ /**
230
+ * @internal
231
+ */
232
+ export function validate(): never {
233
+ halt("validate");
234
+ }
235
+ Object.assign(validate, Namespace.validate());
236
+
237
+ /* -----------------------------------------------------------
238
+ STRICT VALIDATORS
239
+ ----------------------------------------------------------- */
240
+ /**
241
+ * Asserts equality between a value and its type.
242
+ *
243
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
244
+ * reason, if the parametric value is not following the type `T` or some superfluous
245
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
246
+ * following the type `T` without any superfluous property, just input parameter would
247
+ * be returned.
248
+ *
249
+ * If what you want is not asserting but just knowing whether the parametric value is
250
+ * following the type `T` or not, you can choose the {@link equals} function instead.
251
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
252
+ *
253
+ * On the other hand, if you want to allow superfluous property that is not enrolled
254
+ * to the type `T`, you can use {@link assert} function instead.
255
+ *
256
+ * @template T Type of the input value
257
+ * @param input A value to be asserted
258
+ * @returns Parametric input value
259
+ * @throws A {@link TypeGuardError} instance with detailed reason
260
+ *
261
+ * @author Jeongho Nam - https://github.com/samchon
262
+ */
263
+ export function assertEquals<T>(input: T): T;
264
+
265
+ /**
266
+ * Asserts equality between a value and its type.
267
+ *
268
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
269
+ * reason, if the parametric value is not following the type `T` or some superfluous
270
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
271
+ * following the type `T` without any superfluous property, just input parameter would
272
+ * be returned.
273
+ *
274
+ * If what you want is not asserting but just knowing whether the parametric value is
275
+ * following the type `T` or not, you can choose the {@link equals} function instead.
276
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
277
+ *
278
+ * On the other hand, if you want to allow superfluous property that is not enrolled
279
+ * to the type `T`, you can use {@link assert} function instead.
280
+ *
281
+ * @template T Type of the input value
282
+ * @param input A value to be asserted
283
+ * @returns Parametric input value casted as `T`
284
+ * @throws A {@link TypeGuardError} instance with detailed reason
285
+ *
286
+ * @author Jeongho Nam - https://github.com/samchon
287
+ */
288
+ export function assertEquals<T>(input: unknown): T;
289
+
290
+ /**
291
+ * @internal
292
+ */
293
+ export function assertEquals(): never {
294
+ halt("assertEquals");
295
+ }
296
+ Object.assign(assertEquals, Namespace.assert("assertEquals"));
297
+
298
+ /**
299
+ * Tests equality between a value and its type.
300
+ *
301
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
302
+ * or not. If the parametric value is matched with the type `T` and there's not any
303
+ * superfluous property that is not listed on the type `T`, `true` value would be
304
+ * returned. Otherwise, the parametric value is not following the type `T` or some
305
+ * superfluous property exists, `false` value would be returned.
306
+ *
307
+ * If what you want is not just knowing whether the parametric value is following the
308
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
309
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
310
+ * detailed reasons, {@link validateEquals} function would be useful.
311
+ *
312
+ * On the other hand, if you want to allow superfluous property that is not enrolled
313
+ * to the type `T`, you can use {@link is} function instead.
314
+ *
315
+ * @template T Type of the input value
316
+ * @param input A value to be tested
317
+ * @returns Whether the parametric value is equivalent to the type `T` or not
318
+ *
319
+ * @author Jeongho Nam - https://github.com/samchon
320
+ */
321
+ export function equals<T>(input: T): input is T;
322
+
323
+ /**
324
+ * Tests equality between a value and its type.
325
+ *
326
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
327
+ * or not. If the parametric value is matched with the type `T` and there's not any
328
+ * superfluous property that is not listed on the type `T`, `true` value would be
329
+ * returned. Otherwise, the parametric value is not following the type `T` or some
330
+ * superfluous property exists, `false` value would be returned.
331
+ *
332
+ * If what you want is not just knowing whether the parametric value is following the
333
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
334
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
335
+ * detailed reasons, {@link validateEquals} function would be useful.
336
+ *
337
+ * On the other hand, if you want to allow superfluous property that is not enrolled
338
+ * to the type `T`, you can use {@link is} function instead.
339
+ *
340
+ * @template T Type of the input value
341
+ * @param input A value to be tested
342
+ * @returns Whether the parametric value is equivalent to the type `T` or not
343
+ *
344
+ * @author Jeongho Nam - https://github.com/samchon
345
+ */
346
+ export function equals<T>(input: unknown): input is T;
347
+
348
+ /**
349
+ * @internal
350
+ */
351
+ export function equals(): never {
352
+ halt("equals");
353
+ }
354
+ Object.assign(equals, Namespace.is());
355
+
356
+ /**
357
+ * Validates equality between a value and its type.
358
+ *
359
+ * Validates a parametric value type and archives all the type errors into an
360
+ * {@link IValidation.errors} array, if the parametric value is not following the
361
+ * type `T` or some superfluous property that is not listed on the type `T` has been
362
+ * found. Of course, if the parametric value is following the type `T` and no
363
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
364
+ * and {@link IValidation.success} would have the `true` value.
365
+ *
366
+ * If what you want is not finding all the error, but asserting the parametric value
367
+ * type with exception throwing, you can choose {@link assert} function instead.
368
+ * Otherwise, you just want to know whether the parametric value is matched with the
369
+ * type `T`, {@link is} function is the way to go.
370
+ *
371
+ * On the other and, if you don't want to allow any superfluous property that is not
372
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
373
+ *
374
+ * @template Type of the input value
375
+ * @param input A value to be validated
376
+ * @returns Validation result
377
+ *
378
+ * @author Jeongho Nam - https://github.com/samchon
379
+ */
380
+ export function validateEquals<T>(input: T): IValidation<T>;
381
+
382
+ /**
383
+ * Validates equality between a value and its type.
384
+ *
385
+ * Validates a parametric value type and archives all the type errors into an
386
+ * {@link IValidation.errors} array, if the parametric value is not following the
387
+ * type `T` or some superfluous property that is not listed on the type `T` has been
388
+ * found. Of course, if the parametric value is following the type `T` and no
389
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
390
+ * and {@link IValidation.success} would have the `true` value.
391
+ *
392
+ * If what you want is not finding all the error, but asserting the parametric value
393
+ * type with exception throwing, you can choose {@link assert} function instead.
394
+ * Otherwise, you just want to know whether the parametric value is matched with the
395
+ * type `T`, {@link is} function is the way to go.
396
+ *
397
+ * On the other and, if you don't want to allow any superfluous property that is not
398
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
399
+ *
400
+ * @template Type of the input value
401
+ * @param input A value to be validated
402
+ * @returns Validation result
403
+ *
404
+ * @author Jeongho Nam - https://github.com/samchon
405
+ */
406
+ export function validateEquals<T>(input: unknown): IValidation<T>;
407
+
408
+ /**
409
+ * @internal
410
+ */
411
+ export function validateEquals(): never {
412
+ halt("validateEquals");
413
+ }
414
+ Object.assign(validateEquals, Namespace.validate());
415
+
416
+ /**
417
+ * Add validation tag.
418
+ *
419
+ * If you want to add a custom validation logic, you can use this function.
420
+ *
421
+ * ```ts
422
+ * typia.addValidationTag("powerOf")("number")(
423
+ * (text: string) => {
424
+ * const denominator: number = Math.log(Number(text));
425
+ * return (value: number) => {
426
+ * value = Math.log(value) / denominator;
427
+ * return value === Math.floor(value);
428
+ * };
429
+ * }
430
+ * );
431
+ * typia.addValidationTag("dollar")("string")(
432
+ * () => (value: string) => value.startsWith("$"),
433
+ * );
434
+ * ```
435
+ *
436
+ * @param name Name of tag (`@name`)
437
+ * @returns Currying function
438
+ */
439
+ export const addValidationTag =
440
+ (name: string) =>
441
+ /**
442
+ * @param type Type of target value
443
+ */
444
+ <Type extends keyof Customizable>(type: Type) =>
445
+ /**
446
+ * @param closure Closure function for custom validation
447
+ */
448
+ (closure: (text: string) => (value: Customizable[Type]) => boolean) => {
449
+ const key = `${name}:${type}` as const;
450
+ if (!$dictionary.has(key)) $dictionary.set(key, closure);
451
+ };
452
+
453
+ /* -----------------------------------------------------------
454
+ JSON FUNCTIONS
455
+ ----------------------------------------------------------- */
456
+ /**
457
+ * > You must configure the generic argument `T`.
458
+ *
459
+ * JSON Schema Application.
460
+ *
461
+ * Creates a JSON schema application which contains both main JSON schemas and components.
462
+ * Note that, all of the object types are stored in the {@link IJsonApplication.components}
463
+ * property for the `$ref` referencing.
464
+ *
465
+ * Also, `typia.application()` has additional generic arguments, *Purpose*.
466
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
467
+ * you should configure the *Purpose* appropriately.
468
+ *
469
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
470
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
471
+ * the tuple definition.
472
+ *
473
+ * @template Types Tuple of target types
474
+ * @template Purpose Purpose of the JSON schema`
475
+ * @template Prefix Prefix of the JSON components referenced by `$ref` tag
476
+ * @return JSON schema application
477
+ *
478
+ * @author Jeongho Nam - https://github.com/samchon
479
+ */
480
+ export function application(): never;
481
+
482
+ /**
483
+ * JSON Schema Application.
484
+ *
485
+ * Creates a JSON schema application which contains both main JSON schemas and components.
486
+ * Note that, all of the object types are stored in the {@link IJsonApplication.components}
487
+ * property for the `$ref` referencing.
488
+ *
489
+ * Also, `typia.application()` has additional generic arguments, *Purpose*.
490
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
491
+ * you should configure the *Purpose* appropriately.
492
+ *
493
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
494
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
495
+ * the tuple definition.
496
+ *
497
+ * @template Types Tuple of target types
498
+ * @template Purpose Purpose of the JSON schema
499
+ * @template Prefix Prefix of the JSON components referenced by `$ref` tag
500
+ * @return JSON schema application
501
+ *
502
+ * @author Jeongho Nam - https://github.com/samchon
503
+ */
504
+ export function application<
505
+ Types extends unknown[],
506
+ Purpose extends "swagger" | "ajv" = "swagger",
507
+ Prefix extends string = Purpose extends "swagger"
508
+ ? "#/components/schemas"
509
+ : "components#/schemas",
510
+ >(): IJsonApplication;
511
+
512
+ /**
513
+ * @internal
514
+ */
515
+ export function application(): never {
516
+ halt("application");
517
+ }
518
+
519
+ /**
520
+ * > You must configure the generic argument `T`.
521
+ *
522
+ * Safe `JSON.parse()` function with type assertion.
523
+ *
524
+ * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
525
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
526
+ * instance with type assertion.
527
+ *
528
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
529
+ * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
530
+ * the parsed value would be returned.
531
+ *
532
+ * @template T Expected type of parsed value
533
+ * @param input JSON string
534
+ * @returns Parsed value
535
+ *
536
+ * @author Jeongho Nam - https://github.com/samchon
537
+ */
538
+ export function assertParse(input: string): never;
539
+
540
+ /**
541
+ * Safe `JSON.parse()` function with type assertion.
542
+ *
543
+ * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
544
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
545
+ * instance with type assertion.
546
+ *
547
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
548
+ * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
549
+ * the parsed value would be returned.
550
+ *
551
+ * @template T Expected type of parsed value
552
+ * @param input JSON string
553
+ * @returns Parsed value
554
+ *
555
+ * @author Jeongho Nam - https://github.com/samchon
556
+ */
557
+ export function assertParse<T>(input: string): T;
558
+
559
+ /**
560
+ * @internal
561
+ */
562
+ export function assertParse<T>(): T {
563
+ halt("assertParse");
564
+ }
565
+ Object.assign(assertParse, Namespace.assert("assertParse"));
566
+
567
+ /**
568
+ * > You must configure the generic argument `T`.
569
+ *
570
+ * Safe `JSON.parse()` function with type checking.
571
+ *
572
+ * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
573
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
574
+ * instance with type checking.
575
+ *
576
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
577
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
578
+ * value would be returned.
579
+ *
580
+ * @template T Expected type of parsed value
581
+ * @param input JSON string
582
+ * @returns Parsed value when exact type, otherwise `null`
583
+ *
584
+ * @author Jeongho Nam - https://github.com/samchon
585
+ */
586
+ export function isParse(input: string): never;
587
+
588
+ /**
589
+ * Safe `JSON.parse()` function with type checking.
590
+ *
591
+ * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
592
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
593
+ * instance with type checking.
594
+ *
595
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
596
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
597
+ * value would be returned.
598
+ *
599
+ * @template T Expected type of parsed value
600
+ * @param input JSON string
601
+ * @returns Parsed value when exact type, otherwise `null`
602
+ *
603
+ * @author Jeongho Nam - https://github.com/samchon
604
+ */
605
+ export function isParse<T>(input: string): T | null;
606
+
607
+ /**
608
+ * @internal
609
+ */
610
+ export function isParse<T>(): T | null {
611
+ halt("isParse");
612
+ }
613
+ Object.assign(isParse, is);
614
+
615
+ /**
616
+ * > You must configure the generic argument `T`.
617
+ *
618
+ * Safe `JSON.parse()` function with detailed type validation.
619
+ *
620
+ * `typia.validateParse()` is a combination function of `JSON.parse()` and
621
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
622
+ * to a `T` typed instance with detailed type validation.
623
+ *
624
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
625
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
626
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
627
+ * property of the output {@link IValidation.ISuccess} instance.
628
+ *
629
+ * @template T Expected type of parsed value
630
+ * @param input JSON string
631
+ * @returns Validation result with JSON parsed value
632
+ *
633
+ * @author Jeongho Nam - https://github.com/samchon
634
+ */
635
+ export function validateParse(input: string): never;
636
+
637
+ /**
638
+ * Safe `JSON.parse()` function with detailed type validation.
639
+ *
640
+ * `typia.validateParse()` is a combination function of `JSON.parse()` and
641
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
642
+ * to a `T` typed instance with detailed type validation.
643
+ *
644
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
645
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
646
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
647
+ * property of the output {@link IValidation.ISuccess} instance.
648
+ *
649
+ * @template T Expected type of parsed value
650
+ * @param input JSON string
651
+ * @returns Validation result with JSON parsed value
652
+ *
653
+ * @author Jeongho Nam - https://github.com/samchon
654
+ */
655
+ export function validateParse<T>(input: string): IValidation<T>;
656
+
657
+ /**
658
+ * @internal
659
+ */
660
+ export function validateParse<T>(): IValidation<T> {
661
+ halt("validateParse");
662
+ }
663
+ Object.assign(validateParse, validate);
664
+
665
+ /**
666
+ * 8x faster `JSON.stringify()` function.
667
+ *
668
+ * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
669
+ * than the native `JSON.stringify()` function. The 5x faster principle is because
670
+ * it writes an optimized JSON conversion plan, only for the type `T`.
671
+ *
672
+ * For reference, this `typia.stringify()` does not validate the input value type.
673
+ * It just believes that the input value is following the type `T`. Therefore, if you
674
+ * can't ensure the input value type, it would be better to call one of below functions
675
+ * instead.
676
+ *
677
+ * - {@link assertStringify}
678
+ * - {@link isStringify}
679
+ * - {@link validateStringify}
680
+ *
681
+ * @template T Type of the input value
682
+ * @param input A value to be converted
683
+ * @return JSON string value
684
+ *
685
+ * @author Jeongho Nam - https://github.com/samchon
686
+ */
687
+ export function stringify<T>(input: T): string;
688
+
689
+ /**
690
+ * @internal
691
+ */
692
+ export function stringify(): never {
693
+ halt("stringify");
694
+ }
695
+ Object.assign(stringify, Namespace.stringify("stringify"));
696
+
697
+ /**
698
+ * 5x faster `JSON.stringify()` function with type assertion.
699
+ *
700
+ * `typia.assertStringify()` is a combination function of {@link assert} and
701
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
702
+ * Notation) string, with type assertion.
703
+ *
704
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
705
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
706
+ * string would be returned.
707
+ *
708
+ * For reference, with type assertion, it is even 5x times faster than the native
709
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
710
+ * with confidence.
711
+ *
712
+ * @template T Type of the input value
713
+ * @param input A value to be asserted and converted
714
+ * @return JSON string value
715
+ *
716
+ * @author Jeongho Nam - https://github.com/samchon
717
+ */
718
+ export function assertStringify<T>(input: T): string;
719
+
720
+ /**
721
+ * 5x faster `JSON.stringify()` function with type assertion.
722
+ *
723
+ * `typia.assertStringify()` is a combination function of {@link assert} and
724
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
725
+ * Notation) string, with type assertion.
726
+ *
727
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
728
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
729
+ * string would be returned.
730
+ *
731
+ * For reference, with type assertion, it is even 5x times faster than the native
732
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
733
+ * with confidence.
734
+ *
735
+ * @template T Type of the input value
736
+ * @param input A value to be asserted and converted
737
+ * @return JSON string value
738
+ *
739
+ * @author Jeongho Nam - https://github.com/samchon
740
+ */
741
+ export function assertStringify<T>(input: T): unknown;
742
+
743
+ /**
744
+ * @internal
745
+ */
746
+ export function assertStringify(): string {
747
+ halt("assertStringify");
748
+ }
749
+ Object.assign(assertStringify, Namespace.assert("assertStringify"));
750
+ Object.assign(assertStringify, Namespace.stringify("assertStringify"));
751
+
752
+ /**
753
+ * 7x faster `JSON.stringify()` function with type checking.
754
+ *
755
+ * `typia.stringify()` is a combination function of {@link is} and
756
+ * {@link stringify}. Therefore, it converts an input value to JSON
757
+ * (JavaScript Object Notation) string, with type checking.
758
+ *
759
+ * In such reason, when `input` value is not matched with the type `T`, it returns
760
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
761
+ * be returned.
762
+ *
763
+ * For reference, with type checking, it is even 7x times faster than the native
764
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
765
+ * with confidence.
766
+ *
767
+ * @template T Type of the input value
768
+ * @param input A value to be checked and converted
769
+ * @return JSON string value when exact type, otherwise null
770
+ *
771
+ * @author Jeongho Nam - https://github.com/samchon
772
+ */
773
+ export function isStringify<T>(input: T): string | null;
774
+
775
+ /**
776
+ * 7x faster `JSON.stringify()` function with type checking.
777
+ *
778
+ * `typia.isStringify()` is a combination function of {@link is} and
779
+ * {@link stringify}. Therefore, it converts an input value to JSON
780
+ * (JavaScript Object Notation) string, with type checking.
781
+ *f
782
+ * In such reason, when `input` value is not matched with the type `T`, it returns
783
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
784
+ * be returned.
785
+ *
786
+ * For reference, with type checking, it is even 7x times faster than the native
787
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
788
+ * with confidence.
789
+ *
790
+ * @template T Type of the input value
791
+ * @param input A value to be checked and converted
792
+ * @return JSON string value when exact type, otherwise null
793
+ *
794
+ * @author Jeongho Nam - https://github.com/samchon
795
+ */
796
+ export function isStringify<T>(input: unknown): string | null;
797
+
798
+ /**
799
+ * @internal
800
+ */
801
+ export function isStringify(): string | null {
802
+ halt("isStringify");
803
+ }
804
+
805
+ Object.assign(isStringify, Namespace.is());
806
+ Object.assign(isStringify, Namespace.stringify("isStringify"));
807
+
808
+ /**
809
+ * 5x faster `JSON.stringify()` function with detailed type validation.
810
+ *
811
+ * `typia.validateStringify()` is a combination function of {@link validate} and
812
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
813
+ * Notation) string, with detailed type validation.
814
+ *
815
+ * In such reason, when `input` value is not matched with the type `T`, it returns
816
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
817
+ * problem on the `input` value, JSON string would be stored in `data` property of
818
+ * the output {@link IValidation.ISuccess} instance.
819
+ *
820
+ * For reference, with detailed type validation, it is even 5x times faster than the
821
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
822
+ * with confidence.
823
+ *
824
+ * @template T Type of the input value
825
+ * @param input A value to be checked and converted
826
+ * @returns Validation result with JSON string value
827
+ *
828
+ * @author Jeongho Nam - https://github.com/samchon
829
+ */
830
+ export function validateStringify<T>(input: T): IValidation<string>;
831
+
832
+ /**
833
+ * 5x faster `JSON.stringify()` function with detailed type validation.
834
+ *
835
+ * `typia.validateStringify()` is a combination function of {@link validate} and
836
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
837
+ * Notation) string, with detailed type validation.
838
+ *
839
+ * In such reason, when `input` value is not matched with the type `T`, it returns
840
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
841
+ * problem on the `input` value, JSON string would be stored in `data` property of
842
+ * the output {@link IValidation.ISuccess} instance.
843
+ *
844
+ * For reference, with detailed type validation, it is even 5x times faster than the
845
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
846
+ * with confidence.
847
+ *
848
+ * @template T Type of the input value
849
+ * @param input A value to be checked and converted
850
+ * @returns Validation result with JSON string value
851
+ *
852
+ * @author Jeongho Nam - https://github.com/samchon
853
+ */
854
+ export function validateStringify<T>(input: unknown): IValidation<string>;
855
+
856
+ /**
857
+ * @internal
858
+ */
859
+ export function validateStringify(): IValidation<string> {
860
+ halt("validateStringify");
861
+ }
862
+ Object.assign(validateStringify, Namespace.validate());
863
+ Object.assign(validateStringify, Namespace.stringify("validateStringify"));
864
+
865
+ /* -----------------------------------------------------------
866
+ MISCELLANEOUS
867
+ ----------------------------------------------------------- */
868
+ /**
869
+ * @internal
870
+ */
871
+ export function metadata(): never;
872
+
873
+ /**
874
+ * @internal
875
+ */
876
+ export function metadata<Types extends unknown[]>(): IMetadataApplication;
877
+
878
+ /**
879
+ * @internal
880
+ */
881
+ export function metadata(): never {
882
+ halt("metadata");
883
+ }
884
+
885
+ /**
886
+ * > You must configure the generic argument `T`.
887
+ *
888
+ * Generate random data.
889
+ *
890
+ * Generates a random data following type the `T`.
891
+ *
892
+ * For reference, this `typia.random()` function generates only primitive type.
893
+ * If there're some methods in the type `T` or its nested instances, those would
894
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
895
+ * would be generated instead.
896
+ *
897
+ * @template T Type of data to generate
898
+ * @param generator Random data generator
899
+ * @return Randomly generated data
900
+ *
901
+ * @author Jeongho Nam - https://github.com/samchon
902
+ */
903
+ export function random(generator?: Partial<IRandomGenerator>): never;
904
+
905
+ /**
906
+ * Generate random data.
907
+ *
908
+ * Generates a random data following type the `T`.
909
+ *
910
+ * For reference, this `typia.random()` function generates only primitive type.
911
+ * If there're some methods in the type `T` or its nested instances, those would
912
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
913
+ * would be generated instead.
914
+ *
915
+ * @template T Type of data to generate
916
+ * @param generator Random data generator
917
+ * @return Randomly generated data
918
+ *
919
+ * @author Jeongho Nam - https://github.com/samchon
920
+ */
921
+ export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
922
+
923
+ /**
924
+ * @internal
925
+ */
926
+ export function random(): never {
927
+ halt("random");
928
+ }
929
+ Object.assign(random, Namespace.random());
930
+
931
+ /**
932
+ * Clone a data.
933
+ *
934
+ * Clones an instance following type `T`. If the target *input* value or its member
935
+ * variable contains a class instance that is having a `toJSON()` method, its return
936
+ * value would be cloned.
937
+ *
938
+ * For reference, this `typia.clone()` function does not validate the input value type.
939
+ * It just believes that the input value is following the type `T`. Therefore, if you
940
+ * can't ensure the input value type, it would be better to call {@link assertClone}
941
+ * function instead.
942
+ *
943
+ * @template T Type of the input value
944
+ * @param input A value to be cloned
945
+ * @return Cloned data
946
+ *
947
+ * @author Jeongho Nam - https://github.com/samchon
948
+ */
949
+ export function clone<T>(input: T): Primitive<T>;
950
+
951
+ /**
952
+ * @internal
953
+ */
954
+ export function clone(): never {
955
+ halt("clone");
956
+ }
957
+ Object.assign(clone, Namespace.clone("clone"));
958
+
959
+ /**
960
+ * Clone a data with type assertion.
961
+ *
962
+ * Clones an instance following type `T`, with type assertion. If the target `input`
963
+ * value or its member variable contains a class instance that is having a `toJSON()`
964
+ * method, its return value would be cloned.
965
+ *
966
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
967
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
968
+ * data would be returned.
969
+ *
970
+ * @template T Type of the input value
971
+ * @param input A value to be cloned
972
+ * @return Cloned data
973
+ *
974
+ * @author Jeongho Nam - https://github.com/samchon
975
+ */
976
+ export function assertClone<T>(input: T): Primitive<T>;
977
+
978
+ /**
979
+ * Clone a data with type assertion.
980
+ *
981
+ * Clones an instance following type `T`, with type assertion. If the target `input`
982
+ * value or its member variable contains a class instance that is having a `toJSON()`
983
+ * method, its return value would be cloned.
984
+ *
985
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
986
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
987
+ * data would be returned.
988
+ *
989
+ * @template T Type of the input value
990
+ * @param input A value to be cloned
991
+ * @return Cloned data
992
+ *
993
+ * @author Jeongho Nam - https://github.com/samchon
994
+ */
995
+ export function assertClone<T>(input: unknown): Primitive<T>;
996
+
997
+ /**
998
+ * @internal
999
+ */
1000
+ export function assertClone(): never {
1001
+ halt("assertClone");
1002
+ }
1003
+ Object.assign(assertClone, Namespace.assert("assertClone"));
1004
+ Object.assign(assertClone, Namespace.clone("assertClone"));
1005
+
1006
+ /**
1007
+ * Clone a data with type checking.
1008
+ *
1009
+ * Clones an instance following type `T`, with type checking. If the target `input`
1010
+ * value or its member variable contains a class instance that is having a `toJSON()`
1011
+ * method, its return value would be cloned.
1012
+ *
1013
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1014
+ * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1015
+ * data would be returned.
1016
+ *
1017
+ * @template T Type of the input value
1018
+ * @param input A value to be cloned
1019
+ * @return Cloned data when exact type, otherwise null
1020
+ *
1021
+ * @author Jeongho Nam - https://github.com/samchon
1022
+ */
1023
+ export function isClone<T>(input: T): Primitive<T> | null;
1024
+
1025
+ /**
1026
+ * Clone a data with type checking.
1027
+ *
1028
+ * Clones an instance following type `T`, with type checking. If the target `input`
1029
+ * value or its member variable contains a class instance that is having a `toJSON()`
1030
+ * method, its return value would be cloned.
1031
+ *
1032
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1033
+ * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1034
+ * data would be returned.
1035
+ *
1036
+ * @template T Type of the input value
1037
+ * @param input A value to be cloned
1038
+ * @return Cloned data when exact type, otherwise null
1039
+ *
1040
+ * @author Jeongho Nam - https://github.com/samchon
1041
+ */
1042
+ export function isClone<T>(input: unknown): Primitive<T> | null;
1043
+
1044
+ /**
1045
+ * @internal
1046
+ */
1047
+ export function isClone(): never {
1048
+ halt("isClone");
1049
+ }
1050
+ Object.assign(isClone, Namespace.is());
1051
+ Object.assign(isClone, Namespace.clone("isClone"));
1052
+
1053
+ /**
1054
+ * Clone a data with detailed type validation.
1055
+ *
1056
+ * Clones an instance following type `T`, with detailed type validation. If the target
1057
+ * `input` value or its member variable contains a class instance that is having a
1058
+ * `toJSON()` method, its return value would be cloned.
1059
+ *
1060
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1061
+ * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1062
+ * value, cloned data would be stored in `data` property of the output
1063
+ * {@link IValidation.Success} instance.
1064
+ *
1065
+ * @template T Type of the input value
1066
+ * @param input A value to be cloned
1067
+ * @returns Validation result with cloned value
1068
+ */
1069
+ export function validateClone<T>(input: T): IValidation<Primitive<T>>;
1070
+
1071
+ /**
1072
+ * Clone a data with detailed type validation.
1073
+ *
1074
+ * Clones an instance following type `T`, with detailed type validation. If the target
1075
+ * `input` value or its member variable contains a class instance that is having a
1076
+ * `toJSON()` method, its return value would be cloned.
1077
+ *
1078
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1079
+ * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1080
+ * value, cloned data would be stored in `data` property of the output
1081
+ * {@link IValidation.Success} instance.
1082
+ *
1083
+ * @template T Type of the input value
1084
+ * @param input A value to be cloned
1085
+ * @returns Validation result with cloned value
1086
+ */
1087
+ export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
1088
+
1089
+ /**
1090
+ * @internal
1091
+ */
1092
+ export function validateClone(): never {
1093
+ halt("validateClone");
1094
+ }
1095
+ Object.assign(validateClone, Namespace.validate());
1096
+ Object.assign(validateClone, Namespace.clone("validateClone"));
1097
+
1098
+ /**
1099
+ * Prune, erase superfluous properties.
1100
+ *
1101
+ * Remove every superfluous properties from the `input` object, even including nested
1102
+ * objects. Note that, as every superfluous properties would be deleted, you never can
1103
+ * read those superfluous properties after calling this `prune()` function.
1104
+ *
1105
+ * For reference, this `typia.prune()` function does not validate the input value type.
1106
+ * It just believes that the input value is following the type `T`. Therefore, if you
1107
+ * can't ensure the input value type, it would better to call one of below functions
1108
+ * instead.
1109
+ *
1110
+ * - {@link assertPrune}
1111
+ * - {@link isPrune}
1112
+ * - {@link validatePrune}
1113
+ *
1114
+ * @template T Type of the input value
1115
+ * @param input Target instance to prune
1116
+ *
1117
+ * @author Jeongho Nam - https://github.com/samchon
1118
+ */
1119
+ export function prune<T extends object>(input: T): void;
1120
+
1121
+ /**
1122
+ * @internal
1123
+ */
1124
+ export function prune(): never {
1125
+ halt("prune");
1126
+ }
1127
+ Object.assign(prune, Namespace.prune("prune"));
1128
+
1129
+ /**
1130
+ * Prune, erase superfluous properties, with type assertion.
1131
+ *
1132
+ * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1133
+ * Therefore, it removes every superfluous properties from the `input` object including
1134
+ * nested objects, with type assertion.
1135
+ *
1136
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1137
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1138
+ * every superfluous properties would be removed, including nested objects.
1139
+ *
1140
+ * @template T Type of the input value
1141
+ * @param input Target instance to assert and prune
1142
+ *
1143
+ * @author Jeongho Nam - https://github.com/samchon
1144
+ */
1145
+ export function assertPrune<T>(input: T): T;
1146
+
1147
+ /**
1148
+ * Prune, erase superfluous properties, with type assertion.
1149
+ *
1150
+ * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1151
+ * Therefore, it removes every superfluous properties from the `input` object including
1152
+ * nested objects, with type assertion.
1153
+ *
1154
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
1155
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1156
+ * every superfluous properties would be removed, including nested objects.
1157
+ *
1158
+ * @template T Type of the input value
1159
+ * @param input Target instance to assert and prune
1160
+ *
1161
+ * @author Jeongho Nam - https://github.com/samchon
1162
+ */
1163
+ export function assertPrune<T>(input: unknown): T;
1164
+
1165
+ /**
1166
+ * @internal
1167
+ */
1168
+ export function assertPrune(): unknown {
1169
+ halt("assertPrune");
1170
+ }
1171
+ Object.assign(assertPrune, Namespace.assert("assertPrune"));
1172
+ Object.assign(assertPrune, Namespace.prune("assertPrune"));
1173
+
1174
+ /**
1175
+ * Prune, erase superfluous properties, with type checking.
1176
+ *
1177
+ * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1178
+ * Therefore, it removes every superfluous properties from the `input` object including
1179
+ * nested objects, with type checking.
1180
+ *
1181
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1182
+ * `false` value. Otherwise, there's no problem on the `input` value, it returns
1183
+ * `true` after removing every superfluous properties, including nested objects.
1184
+ *
1185
+ * @template T Type of the input value
1186
+ * @param input Target instance to check and prune
1187
+ * @returns Whether the parametric value is following the type `T` or not
1188
+ *
1189
+ * @author Jeongho Nam - https://github.com/samchon
1190
+ */
1191
+ export function isPrune<T>(input: T): input is T;
1192
+
1193
+ /**
1194
+ * Prune, erase superfluous properties, with type checking.
1195
+ *
1196
+ * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1197
+ * Therefore, it removes every superfluous properties from the `input` object including
1198
+ * nested objects, with type checking.
1199
+ *
1200
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1201
+ * `false` value. Otherwise, there's no problem on the `input` value, it returns
1202
+ * `true` after removing every superfluous properties, including nested objects.
1203
+ *
1204
+ * @template T Type of the input value
1205
+ * @param input Target instance to check and prune
1206
+ * @returns Whether the parametric value is following the type `T` or not
1207
+ *
1208
+ * @author Jeongho Nam - https://github.com/samchon
1209
+ */
1210
+ export function isPrune<T>(input: unknown): input is T;
1211
+
1212
+ /**
1213
+ * @internal
1214
+ */
1215
+ export function isPrune(): never {
1216
+ halt("isPrune");
1217
+ }
1218
+ Object.assign(isPrune, Namespace.is());
1219
+ Object.assign(isPrune, Namespace.prune("isPrune"));
1220
+
1221
+ /**
1222
+ * Prune, erase superfluous properties, with type validation.
1223
+ *
1224
+ * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1225
+ * Therefore, it removes every superfluous properties from the `input` object including
1226
+ * nested objects, with type validation.
1227
+ *
1228
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1229
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1230
+ * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1231
+ * removing every superfluous properties, including nested objects.
1232
+ *
1233
+ * @template T Type of the input value
1234
+ * @param input Target instance to validate and prune
1235
+ * @returns Validation result
1236
+ *
1237
+ * @author Jeongho Nam - https://github.com/samchon
1238
+ */
1239
+ export function validatePrune<T>(input: T): IValidation<T>;
1240
+
1241
+ /**
1242
+ * Prune, erase superfluous properties, with type validation.
1243
+ *
1244
+ * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1245
+ * Therefore, it removes every superfluous properties from the `input` object including
1246
+ * nested objects, with type validation.
1247
+ *
1248
+ * In such reason, when `input` value is not matched with the type `T`, it returns
1249
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1250
+ * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1251
+ * removing every superfluous properties, including nested objects.
1252
+ *
1253
+ * @template T Type of the input value
1254
+ * @param input Target instance to validate and prune
1255
+ * @returns Validation result
1256
+ *
1257
+ * @author Jeongho Nam - https://github.com/samchon
1258
+ */
1259
+ export function validatePrune<T>(input: unknown): IValidation<T>;
1260
+
1261
+ /**
1262
+ * @internal
1263
+ */
1264
+ export function validatePrune<T>(): IValidation<T> {
1265
+ halt("validatePrune");
1266
+ }
1267
+ Object.assign(validatePrune, Namespace.prune("validatePrune"));
1268
+ Object.assign(validatePrune, Namespace.validate());
1269
+
1270
+ /* ===========================================================
1271
+ FACTORY FUNCTIONS
1272
+ - BASIC VALIDATORS
1273
+ - STRICT VALIDATORS
1274
+ - JSON FUNCTIONS
1275
+ - MISCELLANEOUS
1276
+ ==============================================================
1277
+ BASIC VALIDATORS
1278
+ ----------------------------------------------------------- */
1279
+ /**
1280
+ * Creates a reusable {@link assert} function.
1281
+ *
1282
+ * @danger You have to specify the generic argument `T`
1283
+ * @return Nothing until specifying the generic argument `T`
1284
+ * @throws compile error
1285
+ *
1286
+ * @author Jeongho Nam - https://github.com/samchon
1287
+ */
1288
+ export function createAssert(): never;
1289
+
1290
+ /**
1291
+ * Creates a reusable {@link assert} function.
1292
+ *
1293
+ * @template T Type of the input value
1294
+ * @returns A reusable `assert` function
1295
+ *
1296
+ * @author Jeongho Nam - https://github.com/samchon
1297
+ */
1298
+ export function createAssert<T>(): (input: unknown) => T;
1299
+
1300
+ /**
1301
+ * @internal
1302
+ */
1303
+ export function createAssert<T>(): (input: unknown) => T {
1304
+ halt("createAssert");
1305
+ }
1306
+ Object.assign(createAssert, assert);
1307
+
1308
+ /**
1309
+ * Creates a reusable {@link assertType} function.
1310
+ *
1311
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
1312
+ *
1313
+ * @danger You have to specify the generic argument `T`
1314
+ * @return Nothing until specifying the generic argument `T`
1315
+ * @throws compile error
1316
+ *
1317
+ * @author Jeongho Nam - https://github.com/samchon
1318
+ * @deprecated
1319
+ */
1320
+ export function createAssertType(): never;
1321
+
1322
+ /**
1323
+ * Creates a reusable {@link assertType} function.
1324
+ *
1325
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
1326
+ *
1327
+ * @template T Type of the input value
1328
+ * @returns A reusable `assert` function
1329
+ *
1330
+ * @author Jeongho Nam - https://github.com/samchon
1331
+ * @deprecated
1332
+ */
1333
+ export function createAssertType<T>(): (input: unknown) => T;
1334
+
1335
+ /**
1336
+ * @internal
1337
+ */
1338
+ export function createAssertType<T>(): (input: unknown) => T {
1339
+ halt("createAssertType");
1340
+ }
1341
+ Object.assign(createAssertType, assertType);
1342
+
1343
+ /**
1344
+ * Creates a reusable {@link is} function.
1345
+ *
1346
+ * @danger You have to specify the generic argument `T`
1347
+ * @return Nothing until specifying the generic argument `T`
1348
+ * @throws compile error
1349
+ *
1350
+ * @author Jeongho Nam - https://github.com/samchon
1351
+ */
1352
+ export function createIs(): never;
1353
+
1354
+ /**
1355
+ * Creates a reusable {@link is} function.
1356
+ *
1357
+ * @template T Type of the input value
1358
+ * @returns A reusable `is` function
1359
+ *
1360
+ * @author Jeongho Nam - https://github.com/samchon
1361
+ */
1362
+ export function createIs<T>(): (input: unknown) => input is T;
1363
+
1364
+ /**
1365
+ * @internal
1366
+ */
1367
+ export function createIs<T>(): (input: unknown) => input is T {
1368
+ halt("createIs");
1369
+ }
1370
+ Object.assign(createIs, is);
1371
+
1372
+ /**
1373
+ * Creates a reusable {@link validate} function.
1374
+ *
1375
+ * @danger You have to specify the generic argument `T`
1376
+ * @return Nothing until specifying the generic argument `T`
1377
+ * @throws compile error
1378
+ *
1379
+ * @author Jeongho Nam - https://github.com/samchon
1380
+ */
1381
+ export function createValidate(): never;
1382
+
1383
+ /**
1384
+ * Creates a reusable {@link validate} function.
1385
+ *
1386
+ * @template T Type of the input value
1387
+ * @returns A reusable `validate` function
1388
+ *
1389
+ * @author Jeongho Nam - https://github.com/samchon
1390
+ */
1391
+ export function createValidate<T>(): (input: unknown) => IValidation<T>;
1392
+
1393
+ /**
1394
+ * @internal
1395
+ */
1396
+ export function createValidate(): (input: unknown) => IValidation {
1397
+ halt("createValidate");
1398
+ }
1399
+ Object.assign(createValidate, validate);
1400
+
1401
+ /* -----------------------------------------------------------
1402
+ STRICT VALIDATORS
1403
+ ----------------------------------------------------------- */
1404
+ /**
1405
+ * Creates a reusable {@link assertEquals} function.
1406
+ *
1407
+ * @danger You have to specify the generic argument `T`
1408
+ * @return Nothing until specifying the generic argument `T`
1409
+ * @throws compile error
1410
+ *
1411
+ * @author Jeongho Nam - https://github.com/samchon
1412
+ */
1413
+ export function createAssertEquals(): never;
1414
+
1415
+ /**
1416
+ * Creates a reusable {@link assertEquals} function.
1417
+ *
1418
+ * @template T Type of the input value
1419
+ * @returns A reusable `assertEquals` function
1420
+ *
1421
+ * @author Jeongho Nam - https://github.com/samchon
1422
+ */
1423
+ export function createAssertEquals<T>(): (input: unknown) => T;
1424
+
1425
+ /**
1426
+ * @internal
1427
+ */
1428
+ export function createAssertEquals<T>(): (input: unknown) => T {
1429
+ halt("createAssertEquals");
1430
+ }
1431
+ Object.assign(createAssertEquals, assertEquals);
1432
+
1433
+ /**
1434
+ * Creates a reusable {@link equals} function.
1435
+ *
1436
+ * @danger You have to specify the generic argument `T`
1437
+ * @return Nothing until specifying the generic argument `T`
1438
+ * @throws compile error
1439
+ *
1440
+ * @author Jeongho Nam - https://github.com/samchon
1441
+ */
1442
+ export function createEquals(): never;
1443
+
1444
+ /**
1445
+ * Creates a reusable {@link equals} function.
1446
+ *
1447
+ * @template T Type of the input value
1448
+ * @returns A reusable `equals` function
1449
+ *
1450
+ * @author Jeongho Nam - https://github.com/samchon
1451
+ */
1452
+ export function createEquals<T>(): (input: unknown) => input is T;
1453
+
1454
+ /**
1455
+ * @internal
1456
+ */
1457
+ export function createEquals<T>(): (input: unknown) => input is T {
1458
+ halt("createEquals");
1459
+ }
1460
+ Object.assign(createEquals, equals);
1461
+
1462
+ /**
1463
+ * Creates a reusable {@link validateEquals} function.
1464
+ *
1465
+ * @danger You have to specify the generic argument `T`
1466
+ * @return Nothing until specifying the generic argument `T`
1467
+ * @throws compile error
1468
+ *
1469
+ * @author Jeongho Nam - https://github.com/samchon
1470
+ */
1471
+ export function createValidateEquals(): never;
1472
+
1473
+ /**
1474
+ * Creates a reusable {@link validateEquals} function.
1475
+ *
1476
+ * @template T Type of the input value
1477
+ * @returns A reusable `validateEquals` function
1478
+ *
1479
+ * @author Jeongho Nam - https://github.com/samchon
1480
+ */
1481
+ export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
1482
+
1483
+ /**
1484
+ * @internal
1485
+ */
1486
+ export function createValidateEquals(): (input: unknown) => IValidation {
1487
+ halt("createValidateEquals");
1488
+ }
1489
+ Object.assign(createValidateEquals, validateEquals);
1490
+
1491
+ /* -----------------------------------------------------------
1492
+ JSON FUNCTIONS
1493
+ ----------------------------------------------------------- */
1494
+ /**
1495
+ * Creates a reusable {@link isParse} function.
1496
+ *
1497
+ * @danger You have to specify the generic argument `T`
1498
+ * @return Nothing until specifying the generic argument `T`
1499
+ * @throws compile error
1500
+ *
1501
+ * @author Jeongho Nam - https://github.com/samchon
1502
+ */
1503
+ export function createIsParse(): never;
1504
+
1505
+ /**
1506
+ * Creates a reusable {@link isParse} function.
1507
+ *
1508
+ * @template T Expected type of parsed value
1509
+ * @returns A reusable `isParse` function
1510
+ *
1511
+ * @author Jeongho Nam - https://github.com/samchon
1512
+ */
1513
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null;
1514
+
1515
+ /**
1516
+ * @internal
1517
+ */
1518
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null {
1519
+ halt("createIsParse");
1520
+ }
1521
+ Object.assign(createIsParse, isParse);
1522
+
1523
+ /**
1524
+ * Creates a reusable {@link assertParse} function.
1525
+ *
1526
+ * @danger You have to specify the generic argument `T`
1527
+ * @return Nothing until specifying the generic argument `T`
1528
+ * @throws compile error
1529
+ *
1530
+ * @author Jeongho Nam - https://github.com/samchon
1531
+ */
1532
+ export function createAssertParse(): never;
1533
+
1534
+ /**
1535
+ * Creates a reusable {@link assertParse} function.
1536
+ *
1537
+ * @template T Expected type of parsed value
1538
+ * @returns A reusable `assertParse` function
1539
+ *
1540
+ * @author Jeongho Nam - https://github.com/samchon
1541
+ */
1542
+ export function createAssertParse<T>(): (input: string) => Primitive<T>;
1543
+
1544
+ /**
1545
+ * @internal
1546
+ */
1547
+ export function createAssertParse<T>(): (input: string) => Primitive<T> {
1548
+ halt("createAssertParse");
1549
+ }
1550
+ Object.assign(createAssertParse, assertParse);
1551
+
1552
+ /**
1553
+ * Creates a reusable {@link validateParse} function.
1554
+ *
1555
+ * @danger You have to specify the generic argument `T`
1556
+ * @return Nothing until specifying the generic argument `T`
1557
+ * @throws compile error
1558
+ *
1559
+ * @author Jeongho Nam - https://github.com/samchon
1560
+ */
1561
+ export function createValidateParse(): never;
1562
+
1563
+ /**
1564
+ * Creates a reusable {@link validateParse} function.
1565
+ *
1566
+ * @template T Expected type of parsed value
1567
+ * @returns A reusable `validateParse` function
1568
+ *
1569
+ * @author Jeongho Nam - https://github.com/samchon
1570
+ */
1571
+ export function createValidateParse<T>(): (
1572
+ input: string,
1573
+ ) => IValidation<Primitive<T>>;
1574
+
1575
+ /**
1576
+ * @internal
1577
+ */
1578
+ export function createValidateParse<T>(): (
1579
+ input: string,
1580
+ ) => IValidation<Primitive<T>> {
1581
+ halt("createValidateParse");
1582
+ }
1583
+ Object.assign(createValidateParse, validateParse);
1584
+
1585
+ /**
1586
+ * Creates a reusable {@link stringify} function.
1587
+ *
1588
+ * @danger You have to specify the generic argument `T`
1589
+ * @return Nothing until specifying the generic argument `T`
1590
+ * @throws compile error
1591
+ *
1592
+ * @author Jeongho Nam - https://github.com/samchon
1593
+ */
1594
+ export function createStringify(): never;
1595
+
1596
+ /**
1597
+ * Creates a reusable {@link stringify} function.
1598
+ *
1599
+ * @template T Type of the input value
1600
+ * @returns A reusable `stringify` function
1601
+ *
1602
+ * @author Jeongho Nam - https://github.com/samchon
1603
+ */
1604
+ export function createStringify<T>(): (input: T) => string;
1605
+
1606
+ /**
1607
+ * @internal
1608
+ */
1609
+ export function createStringify<T>(): (input: T) => string {
1610
+ halt("createStringify");
1611
+ }
1612
+ Object.assign(createStringify, stringify);
1613
+
1614
+ /**
1615
+ * Creates a reusable {@link assertStringify} function.
1616
+ *
1617
+ * @danger You have to specify the generic argument `T`
1618
+ * @return Nothing until specifying the generic argument `T`
1619
+ * @throws compile error
1620
+ *
1621
+ * @author Jeongho Nam - https://github.com/samchon
1622
+ */
1623
+ export function createAssertStringify(): never;
1624
+
1625
+ /**
1626
+ * Creates a reusable {@link assertStringify} function.
1627
+ *
1628
+ * @template T Type of the input value
1629
+ * @returns A reusable `assertStringify` function
1630
+ *
1631
+ * @author Jeongho Nam - https://github.com/samchon
1632
+ */
1633
+ export function createAssertStringify<T>(): (input: unknown) => string;
1634
+
1635
+ /**
1636
+ * @internal
1637
+ */
1638
+ export function createAssertStringify(): (input: unknown) => string {
1639
+ halt("createAssertStringify");
1640
+ }
1641
+ Object.assign(createAssertStringify, assertStringify);
1642
+
1643
+ /**
1644
+ * Creates a reusable {@link isStringify} function.
1645
+ *
1646
+ * @danger You have to specify the generic argument `T`
1647
+ * @return Nothing until specifying the generic argument `T`
1648
+ * @throws compile error
1649
+ *
1650
+ * @author Jeongho Nam - https://github.com/samchon
1651
+ */
1652
+ export function createIsStringify(): never;
1653
+
1654
+ /**
1655
+ * Creates a reusable {@link isStringify} function.
1656
+ *
1657
+ * @template T Type of the input value
1658
+ * @returns A reusable `isStringify` function
1659
+ *
1660
+ * @author Jeongho Nam - https://github.com/samchon
1661
+ */
1662
+ export function createIsStringify<T>(): (input: unknown) => string | null;
1663
+
1664
+ /**
1665
+ * @internal
1666
+ */
1667
+ export function createIsStringify(): (input: unknown) => string | null {
1668
+ halt("createIsStringify");
1669
+ }
1670
+ Object.assign(createIsStringify, isStringify);
1671
+
1672
+ /**
1673
+ * Creates a reusable {@link validateStringify} function.
1674
+ *
1675
+ * @danger You have to specify the generic argument `T`
1676
+ * @return Nothing until specifying the generic argument `T`
1677
+ * @throws compile error
1678
+ *
1679
+ * @author Jeongho Nam - https://github.com/samchon
1680
+ */
1681
+ export function createValidateStringify(): never;
1682
+
1683
+ /**
1684
+ * Creates a reusable {@link validateStringify} function.
1685
+ *
1686
+ * @template T Type of the input value
1687
+ * @returns A reusable `validateStringify` function
1688
+
1689
+ * @author Jeongho Nam - https://github.com/samchon
1690
+ */
1691
+ export function createValidateStringify<T>(): (
1692
+ input: unknown,
1693
+ ) => IValidation<string>;
1694
+
1695
+ /**
1696
+ * @internal
1697
+ */
1698
+ export function createValidateStringify(): (
1699
+ input: unknown,
1700
+ ) => IValidation<string> {
1701
+ halt("createValidateStringify");
1702
+ }
1703
+ Object.assign(createValidateStringify, validateStringify);
1704
+
1705
+ /* -----------------------------------------------------------
1706
+ MISCELLANEOUS
1707
+ ----------------------------------------------------------- */
1708
+ /**
1709
+ * Creates a reusable {@link random} function.
1710
+ *
1711
+ * @danger You have to specify the generic argument `T`
1712
+ * @param generator Random data generator
1713
+ * @return Nothing until specifying the generic argument `T`
1714
+ * @throws compile error
1715
+ *
1716
+ * @author Jeongho Nam - https://github.com/samchon
1717
+ */
1718
+ export function createRandom(generator?: Partial<IRandomGenerator>): never;
1719
+
1720
+ /**
1721
+ * Creates a resuable {@link random} function.
1722
+ *
1723
+ * @template T Type of the input value
1724
+ * @param generator Random data generator
1725
+ * @returns A reusable `random` function
1726
+ *
1727
+ * @author Jeongho Nam - https://github.com/samchon
1728
+ */
1729
+ export function createRandom<T>(
1730
+ generator?: Partial<IRandomGenerator>,
1731
+ ): () => Primitive<T>;
1732
+
1733
+ /**
1734
+ * @internal
1735
+ */
1736
+ export function createRandom(): never {
1737
+ halt("createRandom");
1738
+ }
1739
+ Object.assign(createRandom, random);
1740
+
1741
+ /**
1742
+ * Creates a reusable {@link clone} function.
1743
+ *
1744
+ * @danger You have to specify the generic argument `T`
1745
+ * @return Nothing until specifying the generic argument `T`
1746
+ * @throws compile error
1747
+ *
1748
+ * @author Jeongho Nam - https://github.com/samchon
1749
+ */
1750
+ export function createClone(): never;
1751
+
1752
+ /**
1753
+ * Creates a resuable {@link clone} function.
1754
+ *
1755
+ * @template T Type of the input value
1756
+ * @returns A reusable `clone` function
1757
+ *
1758
+ * @author Jeongho Nam - https://github.com/samchon
1759
+ */
1760
+ export function createClone<T>(): (input: T) => Primitive<T>;
1761
+
1762
+ /**
1763
+ * @internal
1764
+ */
1765
+ export function createClone(): never {
1766
+ halt("createClone");
1767
+ }
1768
+ Object.assign(createClone, clone);
1769
+
1770
+ /**
1771
+ * Creates a reusable {@link assertClone} function.
1772
+ *
1773
+ * @danger You have to specify the generic argument `T`
1774
+ * @return Nothing until specifying the generic argument `T`
1775
+ * @throws compile error
1776
+ *
1777
+ * @author Jeongho Nam - https://github.com/samchon
1778
+ */
1779
+ export function createAssertClone(): never;
1780
+
1781
+ /**
1782
+ * Creates a resuable {@link assertClone} function.
1783
+ *
1784
+ * @template T Type of the input value
1785
+ * @returns A reusable `clone` function
1786
+ *
1787
+ * @author Jeongho Nam - https://github.com/samchon
1788
+ */
1789
+ export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
1790
+
1791
+ /**
1792
+ * @internal
1793
+ */
1794
+ export function createAssertClone(): never {
1795
+ halt("createAssertClone");
1796
+ }
1797
+ Object.assign(createAssertClone, assertClone);
1798
+
1799
+ /**
1800
+ * Creates a reusable {@link isClone} function.
1801
+ *
1802
+ * @danger You have to specify the generic argument `T`
1803
+ * @return Nothing until specifying the generic argument `T`
1804
+ * @throws compile error
1805
+ *
1806
+ * @author Jeongho Nam - https://github.com/samchon
1807
+ */
1808
+ export function createIsClone(): never;
1809
+
1810
+ /**
1811
+ * Creates a resuable {@link isClone} function.
1812
+ *
1813
+ * @template T Type of the input value
1814
+ * @returns A reusable `clone` function
1815
+ *
1816
+ * @author Jeongho Nam - https://github.com/samchon
1817
+ */
1818
+ export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
1819
+
1820
+ /**
1821
+ * @internal
1822
+ */
1823
+ export function createIsClone(): never {
1824
+ halt("createIsClone");
1825
+ }
1826
+ Object.assign(createIsClone, isClone);
1827
+
1828
+ /**
1829
+ * Creates a reusable {@link validateClone} function.
1830
+ *
1831
+ * @danger You have to specify the generic argument `T`
1832
+ * @return Nothing until specifying the generic argument `T`
1833
+ * @throws compile error
1834
+ *
1835
+ * @author Jeongho Nam - https://github.com/samchon
1836
+ */
1837
+ export function createValidateClone(): never;
1838
+
1839
+ /**
1840
+ * Creates a resuable {@link validateClone} function.
1841
+ *
1842
+ * @template T Type of the input value
1843
+ * @returns A reusable `clone` function
1844
+ *
1845
+ * @author Jeongho Nam - https://github.com/samchon
1846
+ */
1847
+ export function createValidateClone<T>(): (
1848
+ input: unknown,
1849
+ ) => IValidation<Primitive<T>>;
1850
+
1851
+ /**
1852
+ * @internal
1853
+ */
1854
+ export function createValidateClone(): never {
1855
+ halt("createValidateClone");
1856
+ }
1857
+ Object.assign(createValidateClone, validateClone);
1858
+
1859
+ /**
1860
+ * Creates a reusable {@link prune} function.
1861
+ *
1862
+ * @danger You have to specify the generic argument `T`
1863
+ * @return Nothing until specifying the generic argument `T`
1864
+ * @throws compile error
1865
+ *
1866
+ * @author Jeongho Nam - https://github.com/samchon
1867
+ */
1868
+ export function createPrune(): never;
1869
+
1870
+ /**
1871
+ * Creates a resuable {@link prune} function.
1872
+ *
1873
+ * @template T Type of the input value
1874
+ * @returns A reusable `prune` function
1875
+ *
1876
+ * @author Jeongho Nam - https://github.com/samchon
1877
+ */
1878
+ export function createPrune<T extends object>(): (input: T) => void;
1879
+
1880
+ /**
1881
+ * @internal
1882
+ */
1883
+ export function createPrune<T extends object>(): (input: T) => void {
1884
+ halt("createPrune");
1885
+ }
1886
+ Object.assign(createPrune, prune);
1887
+
1888
+ /**
1889
+ * Creates a reusable {@link assertPrune} function.
1890
+ *
1891
+ * @danger You have to specify the generic argument `T`
1892
+ * @return Nothing until specifying the generic argument `T`
1893
+ * @throws compile error
1894
+ *
1895
+ * @author Jeongho Nam - https://github.com/samchon
1896
+ */
1897
+ export function createAssertPrune(): never;
1898
+
1899
+ /**
1900
+ * Creates a resuable {@link assertPrune} function.
1901
+ *
1902
+ * @template T Type of the input value
1903
+ * @returns A reusable `isPrune` function
1904
+ *
1905
+ * @author Jeongho Nam - https://github.com/samchon
1906
+ */
1907
+ export function createAssertPrune<T extends object>(): (input: T) => T;
1908
+
1909
+ /**
1910
+ * @internal
1911
+ */
1912
+ export function createAssertPrune<T extends object>(): (input: T) => T {
1913
+ halt("createAssertPrune");
1914
+ }
1915
+ Object.assign(createAssertPrune, assertPrune);
1916
+
1917
+ /**
1918
+ * Creates a reusable {@link isPrune} function.
1919
+ *
1920
+ * @danger You have to specify the generic argument `T`
1921
+ * @return Nothing until specifying the generic argument `T`
1922
+ * @throws compile error
1923
+ *
1924
+ * @author Jeongho Nam - https://github.com/samchon
1925
+ */
1926
+ export function createIsPrune(): never;
1927
+
1928
+ /**
1929
+ * Creates a resuable {@link isPrune} function.
1930
+ *
1931
+ * @template T Type of the input value
1932
+ * @returns A reusable `isPrune` function
1933
+ *
1934
+ * @author Jeongho Nam - https://github.com/samchon
1935
+ */
1936
+ export function createIsPrune<T extends object>(): (input: T) => input is T;
1937
+
1938
+ /**
1939
+ * @internal
1940
+ */
1941
+ export function createIsPrune<T extends object>(): (input: T) => input is T {
1942
+ halt("createIsPrune");
1943
+ }
1944
+ Object.assign(createIsPrune, isPrune);
1945
+
1946
+ /**
1947
+ * Creates a reusable {@link validatePrune} function.
1948
+ *
1949
+ * @danger You have to specify the generic argument `T`
1950
+ * @return Nothing until specifying the generic argument `T`
1951
+ * @throws compile error
1952
+ *
1953
+ * @author Jeongho Nam - https://github.com/samchon
1954
+ */
1955
+ export function createValidatePrune(): never;
1956
+
1957
+ /**
1958
+ * Creates a resuable {@link validatePrune} function.
1959
+ *
1960
+ * @template T Type of the input value
1961
+ * @returns A reusable `validatePrune` function
1962
+ *
1963
+ * @author Jeongho Nam - https://github.com/samchon
1964
+ */
1965
+ export function createValidatePrune<T extends object>(): (
1966
+ input: T,
1967
+ ) => IValidation<T>;
1968
+
1969
+ /**
1970
+ * @internal
1971
+ */
1972
+ export function createValidatePrune<T extends object>(): (
1973
+ input: T,
1974
+ ) => IValidation<T> {
1975
+ halt("createValidatePrune");
1976
+ }
1977
+ Object.assign(createValidatePrune, validatePrune);
1978
+
1979
+ /**
1980
+ * @internal
1981
+ */
1982
+ function halt(name: string): never {
1983
+ throw new Error(
1984
+ `Error on typia.${name}(): no transform has been configured. Configure the "tsconfig.json" file following the [README.md#setup](https://github.com/samchon/typia#setup)`,
1985
+ );
1986
+ }