typia 7.0.0-dev.20241009-2 → 7.0.0-dev.20241010

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 (151) hide show
  1. package/lib/factories/JsonMetadataFactory.d.ts +5 -1
  2. package/lib/factories/JsonMetadataFactory.js +4 -1
  3. package/lib/factories/JsonMetadataFactory.js.map +1 -1
  4. package/lib/internal/{$httpFormDataReadArray.js → $httpFormdataReadArray.js} +1 -1
  5. package/lib/internal/$httpFormdataReadArray.js.map +1 -0
  6. package/lib/programmers/CheckerProgrammer.js +4 -1
  7. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  8. package/lib/programmers/FeatureProgrammer.d.ts +4 -1
  9. package/lib/programmers/FeatureProgrammer.js +2 -2
  10. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  11. package/lib/programmers/RandomProgrammer.js +12 -9
  12. package/lib/programmers/RandomProgrammer.js.map +1 -1
  13. package/lib/programmers/TypiaProgrammer.js +4 -1
  14. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  15. package/lib/programmers/internal/prune_object_properties.js +3 -2
  16. package/lib/programmers/internal/prune_object_properties.js.map +1 -1
  17. package/lib/programmers/json/JsonAssertParseProgrammer.js +2 -2
  18. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
  19. package/lib/programmers/misc/MiscCloneProgrammer.js +4 -1
  20. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  21. package/lib/programmers/misc/MiscPruneProgrammer.js +4 -1
  22. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  23. package/lib/programmers/notations/NotationGeneralProgrammer.js +4 -1
  24. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  25. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
  26. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
  27. package/lib/transformers/FileTransformer.js +0 -6
  28. package/lib/transformers/FileTransformer.js.map +1 -1
  29. package/lib/transformers/ImportTransformer.d.ts +4 -1
  30. package/lib/transformers/ImportTransformer.js +34 -30
  31. package/lib/transformers/ImportTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/IRandomGenerator.ts +49 -49
  34. package/src/factories/ExpressionFactory.ts +164 -164
  35. package/src/factories/JsonMetadataFactory.ts +25 -15
  36. package/src/factories/LiteralFactory.ts +50 -50
  37. package/src/factories/MetadataCommentTagFactory.ts +650 -650
  38. package/src/functional.ts +750 -750
  39. package/src/http.ts +1042 -1042
  40. package/src/internal/$IProtobufWriter.ts +18 -18
  41. package/src/internal/$ProtobufReader.ts +194 -194
  42. package/src/internal/$ProtobufSizer.ts +151 -151
  43. package/src/internal/$ProtobufWriter.ts +145 -145
  44. package/src/internal/$accessExpressionAsString.ts +46 -46
  45. package/src/internal/$assertGuard.ts +13 -13
  46. package/src/internal/$functionalTypeGuardErrorFactory.ts +4 -4
  47. package/src/internal/$httpFormDataReadBigint.ts +18 -18
  48. package/src/internal/$httpFormDataReadBlob.ts +10 -10
  49. package/src/internal/$httpFormDataReadBoolean.ts +16 -16
  50. package/src/internal/$httpFormDataReadFile.ts +10 -10
  51. package/src/internal/$httpFormDataReadNumber.ts +15 -15
  52. package/src/internal/$httpFormDataReadString.ts +10 -10
  53. package/src/internal/{$httpFormDataReadArray.ts → $httpFormdataReadArray.ts} +4 -4
  54. package/src/internal/$httpHeaderReadBigint.ts +10 -10
  55. package/src/internal/$httpHeaderReadBoolean.ts +8 -8
  56. package/src/internal/$httpHeaderReadNumber.ts +7 -7
  57. package/src/internal/$httpParameterBigint.ts +10 -10
  58. package/src/internal/$httpParameterBoolean.ts +8 -8
  59. package/src/internal/$httpParameterNumber.ts +7 -7
  60. package/src/internal/$httpParameterString.ts +2 -2
  61. package/src/internal/$httpQueryParseURLSearchParams.ts +10 -10
  62. package/src/internal/$httpQueryReadArray.ts +4 -4
  63. package/src/internal/$httpQueryReadBigint.ts +12 -12
  64. package/src/internal/$httpQueryReadBoolean.ts +14 -14
  65. package/src/internal/$httpQueryReadNumber.ts +9 -9
  66. package/src/internal/$httpQueryReadString.ts +4 -4
  67. package/src/internal/$isBetween.ts +2 -2
  68. package/src/internal/$isBigintString.ts +8 -8
  69. package/src/internal/$jsonStringifyNumber.ts +12 -12
  70. package/src/internal/$jsonStringifyRest.ts +3 -3
  71. package/src/internal/$jsonStringifyString.ts +42 -42
  72. package/src/internal/$jsonStringifyTail.ts +2 -2
  73. package/src/internal/$llmApplicationFinalize.ts +18 -18
  74. package/src/internal/$miscCloneAny.ts +48 -48
  75. package/src/internal/$notationAny.ts +37 -37
  76. package/src/internal/$notationCamel.ts +13 -13
  77. package/src/internal/$notationPascal.ts +8 -8
  78. package/src/internal/$notationSnake.ts +43 -43
  79. package/src/internal/$randomArray.ts +21 -21
  80. package/src/internal/$randomBigint.ts +6 -6
  81. package/src/internal/$randomBoolean.ts +1 -1
  82. package/src/internal/$randomFormatByte.ts +3 -3
  83. package/src/internal/$randomFormatDate.ts +18 -18
  84. package/src/internal/$randomFormatDatetime.ts +16 -16
  85. package/src/internal/$randomFormatDuration.ts +27 -27
  86. package/src/internal/$randomFormatEmail.ts +11 -11
  87. package/src/internal/$randomFormatHostname.ts +6 -6
  88. package/src/internal/$randomFormatIdnEmail.ts +3 -3
  89. package/src/internal/$randomFormatIdnHostname.ts +3 -3
  90. package/src/internal/$randomFormatIpv4.ts +11 -11
  91. package/src/internal/$randomFormatIpv6.ts +11 -11
  92. package/src/internal/$randomFormatIri.ts +3 -3
  93. package/src/internal/$randomFormatIriReference.ts +3 -3
  94. package/src/internal/$randomFormatJsonPointer.ts +7 -7
  95. package/src/internal/$randomFormatPassword.ts +8 -8
  96. package/src/internal/$randomFormatRegex.ts +4 -4
  97. package/src/internal/$randomFormatRelativeJsonPointer.ts +8 -8
  98. package/src/internal/$randomFormatTime.ts +14 -14
  99. package/src/internal/$randomFormatUri.ts +3 -3
  100. package/src/internal/$randomFormatUriReference.ts +3 -3
  101. package/src/internal/$randomFormatUriTemplate.ts +3 -3
  102. package/src/internal/$randomFormatUrl.ts +11 -11
  103. package/src/internal/$randomFormatUuid.ts +6 -6
  104. package/src/internal/$randomInteger.ts +47 -47
  105. package/src/internal/$randomNumber.ts +74 -74
  106. package/src/internal/$randomPattern.ts +10 -10
  107. package/src/internal/$randomPick.ts +9 -9
  108. package/src/internal/$randomString.ts +24 -24
  109. package/src/internal/$throwTypeGuardError.ts +5 -5
  110. package/src/internal/$validateReport.ts +13 -13
  111. package/src/internal/private/$__notationCapitalize.ts +2 -2
  112. package/src/internal/private/$__notationUnsnake.ts +24 -24
  113. package/src/json.ts +651 -651
  114. package/src/llm.ts +178 -178
  115. package/src/misc.ts +658 -658
  116. package/src/module.ts +933 -933
  117. package/src/notations.ts +827 -827
  118. package/src/programmers/CheckerProgrammer.ts +4 -1
  119. package/src/programmers/FeatureProgrammer.ts +619 -616
  120. package/src/programmers/RandomProgrammer.ts +24 -16
  121. package/src/programmers/TypiaProgrammer.ts +4 -1
  122. package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +153 -153
  123. package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +125 -125
  124. package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +115 -115
  125. package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +119 -119
  126. package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +274 -274
  127. package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +135 -135
  128. package/src/programmers/helpers/FunctionProgrammer.ts +67 -67
  129. package/src/programmers/helpers/RandomJoiner.ts +168 -168
  130. package/src/programmers/helpers/StringifyJoinder.ts +115 -115
  131. package/src/programmers/helpers/disable_function_programmer_declare.ts +32 -32
  132. package/src/programmers/internal/check_dynamic_key.ts +201 -201
  133. package/src/programmers/internal/check_dynamic_properties.ts +208 -208
  134. package/src/programmers/internal/check_object.ts +75 -75
  135. package/src/programmers/internal/feature_object_entries.ts +61 -61
  136. package/src/programmers/internal/prune_object_properties.ts +71 -63
  137. package/src/programmers/json/JsonAssertParseProgrammer.ts +14 -11
  138. package/src/programmers/llm/LlmApplicationProgrammer.ts +235 -235
  139. package/src/programmers/llm/LlmSchemaProgrammer.ts +51 -51
  140. package/src/programmers/misc/MiscCloneProgrammer.ts +4 -1
  141. package/src/programmers/misc/MiscPruneProgrammer.ts +4 -1
  142. package/src/programmers/notations/NotationGeneralProgrammer.ts +4 -1
  143. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -1
  144. package/src/protobuf.ts +868 -868
  145. package/src/reflect.ts +57 -57
  146. package/src/transformers/FileTransformer.ts +0 -6
  147. package/src/transformers/ImportTransformer.ts +59 -44
  148. package/src/utils/NamingConvention.ts +94 -94
  149. package/src/utils/StringUtil.ts +16 -16
  150. package/lib/internal/$httpFormDataReadArray.js.map +0 -1
  151. /package/lib/internal/{$httpFormDataReadArray.d.ts → $httpFormdataReadArray.d.ts} +0 -0
package/src/json.ts CHANGED
@@ -1,651 +1,651 @@
1
- import { IJsonApplication } from "./schemas/json/IJsonApplication";
2
-
3
- import { IValidation } from "./IValidation";
4
- import { Primitive } from "./Primitive";
5
- import { TypeGuardError } from "./TypeGuardError";
6
-
7
- /* ===========================================================
8
- JSON
9
- - SCHEMA
10
- - PARSE
11
- - STRINGIFY
12
- - FACTORY FUNCTIONS
13
- ==============================================================
14
- SCHEMA
15
- ----------------------------------------------------------- */
16
- /**
17
- * > You must configure the generic argument `Types`.
18
- *
19
- * JSON Schema Application.
20
- *
21
- * Creates a JSON schema application which contains both main JSON schemas and
22
- * components. Note that, all of the named types are stored in the
23
- * {@link IJsonApplication.components} property for the `$ref` referencing.
24
- *
25
- * Also, you can specify the OpenAPI version by configuring the second generic
26
- * argument `Version`. For reference, the default version is `"3.1"`, and key
27
- * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
28
- *
29
- * @template Types Tuple of target types
30
- * @template Purpose Purpose of the JSON schema
31
- * @template Surplus Allow surplus properties starting with `x-typia-` or not
32
- * @return JSON schema application
33
- *
34
- * @author Jeongho Nam - https://github.com/samchon
35
- */
36
- export function application(): never;
37
-
38
- /**
39
- * JSON Schema Application.
40
- *
41
- * Creates a JSON schema application which contains both main JSON schemas and
42
- * components. Note that, all of the named types are stored in the
43
- * {@link IJsonApplication.components} property for the `$ref` referencing.
44
- *
45
- * Also, you can specify the OpenAPI version by configuring the second generic
46
- * argument `Version`. For reference, the default version is `"3.1"`, and key
47
- * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
48
- *
49
- * @template Types Tuple of target types
50
- * @template Version Version of OpenAPI specification. Default is 3.1
51
- * @return JSON schema application
52
- *
53
- * @author Jeongho Nam - https://github.com/samchon
54
- */
55
- export function application<
56
- Types extends unknown[],
57
- Version extends "3.0" | "3.1" = "3.1",
58
- >(): IJsonApplication<Version, Types>;
59
-
60
- /**
61
- * @internal
62
- */
63
- export function application(): never {
64
- halt("application");
65
- }
66
-
67
- /* -----------------------------------------------------------
68
- PARSE
69
- ----------------------------------------------------------- */
70
- /**
71
- * > You must configure the generic argument `T`.
72
- *
73
- * Safe `JSON.parse()` function with type assertion.
74
- *
75
- * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
76
- * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
77
- * to a `T` typed instance with type assertion.
78
- *
79
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
80
- * throws {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
81
- * there's no problem on the parsed value, the parsed value would be returned.
82
- *
83
- * @template T Expected type of parsed value
84
- * @param input JSON string
85
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
86
- * @returns Parsed value
87
- *
88
- * @author Jeongho Nam - https://github.com/samchon
89
- */
90
- export function assertParse(
91
- input: string,
92
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
93
- ): never;
94
-
95
- /**
96
- * Safe `JSON.parse()` function with type assertion.
97
- *
98
- * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
99
- * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
100
- * to a `T` typed instance with type assertion.
101
- *
102
- * In such reason, when parsed JSON string value is not matched with the type `T`,
103
- * it throws {@link TypeGuardError} or custom error generated by *errorFactory*.
104
- * Otherwise, there's no problem on the parsed value, the parsed value would be
105
- * returned.
106
- *
107
- * @template T Expected type of parsed value
108
- * @param input JSON string
109
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
110
- * @returns Parsed value
111
- *
112
- * @author Jeongho Nam - https://github.com/samchon
113
- */
114
- export function assertParse<T>(
115
- input: string,
116
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
117
- ): Primitive<T>;
118
-
119
- /**
120
- * @internal
121
- */
122
- export function assertParse<T>(): Primitive<T> {
123
- halt("assertParse");
124
- }
125
-
126
- /**
127
- * > You must configure the generic argument `T`.
128
- *
129
- * Safe `JSON.parse()` function with type checking.
130
- *
131
- * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
132
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
133
- * instance with type checking.
134
- *
135
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
136
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
137
- * value would be returned.
138
- *
139
- * @template T Expected type of parsed value
140
- * @param input JSON string
141
- * @returns Parsed value when exact type, otherwise `null`
142
- *
143
- * @author Jeongho Nam - https://github.com/samchon
144
- */
145
- export function isParse(input: string): never;
146
-
147
- /**
148
- * Safe `JSON.parse()` function with type checking.
149
- *
150
- * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
151
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
152
- * instance with type checking.
153
- *
154
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
155
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
156
- * value would be returned.
157
- *
158
- * @template T Expected type of parsed value
159
- * @param input JSON string
160
- * @returns Parsed value when exact type, otherwise `null`
161
- *
162
- * @author Jeongho Nam - https://github.com/samchon
163
- */
164
- export function isParse<T>(input: string): Primitive<T> | null;
165
-
166
- /**
167
- * @internal
168
- */
169
- export function isParse<T>(): Primitive<T> | null {
170
- halt("isParse");
171
- }
172
-
173
- /**
174
- * > You must configure the generic argument `T`.
175
- *
176
- * Safe `JSON.parse()` function with detailed type validation.
177
- *
178
- * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
179
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
180
- * to a `T` typed instance with detailed type validation.
181
- *
182
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
183
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
184
- * there's no problem on the parsed value, the parsed value would be stored in `data`
185
- * property of the output {@link IValidation.ISuccess} instance.
186
- *
187
- * @template T Expected type of parsed value
188
- * @param input JSON string
189
- * @returns Validation result with JSON parsed value
190
- *
191
- * @author Jeongho Nam - https://github.com/samchon
192
- */
193
- export function validateParse(input: string): never;
194
-
195
- /**
196
- * Safe `JSON.parse()` function with detailed type validation.
197
- *
198
- * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
199
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
200
- * to a `T` typed instance with detailed type validation.
201
- *
202
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
203
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
204
- * there's no problem on the parsed value, the parsed value would be stored in `data`
205
- * property of the output {@link IValidation.ISuccess} instance.
206
- *
207
- * @template T Expected type of parsed value
208
- * @param input JSON string
209
- * @returns Validation result with JSON parsed value
210
- *
211
- * @author Jeongho Nam - https://github.com/samchon
212
- */
213
- export function validateParse<T>(input: string): IValidation<Primitive<T>>;
214
-
215
- /**
216
- * @internal
217
- */
218
- export function validateParse<T>(): IValidation<Primitive<T>> {
219
- halt("validateParse");
220
- }
221
-
222
- /* -----------------------------------------------------------
223
- STRINGIFY
224
- ----------------------------------------------------------- */
225
- /**
226
- * 8x faster `JSON.stringify()` function.
227
- *
228
- * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x
229
- * faster than the native `JSON.stringify()` function. The 5x faster principle is
230
- * because it writes an optimized JSON conversion plan, only for the type `T`.
231
- *
232
- * For reference, this `typia.json.stringify()` does not validate the input value type.
233
- * It just believes that the input value is following the type `T`. Therefore, if you
234
- * can't ensure the input value type, it would be better to call one of below
235
- * functions instead.
236
- *
237
- * - {@link assertStringify}
238
- * - {@link isStringify}
239
- * - {@link validateStringify}
240
- *
241
- * @template T Type of the input value
242
- * @param input A value to be converted
243
- * @return JSON string value
244
- *
245
- * @author Jeongho Nam - https://github.com/samchon
246
- */
247
- export function stringify<T>(input: T): string;
248
-
249
- /**
250
- * @internal
251
- */
252
- export function stringify(): never {
253
- halt("stringify");
254
- }
255
-
256
- /**
257
- * 5x faster `JSON.stringify()` function with type assertion.
258
- *
259
- * `typia.json.assertStringify()` is a combination function of {@link assert} and
260
- * {@link stringify}. Therefore, it converts an input value to
261
- * JSON (JavaScript Object Notation) string, with type assertion.
262
- *
263
- * In such reason, when `input` value is not matched with the type `T`, it throws an
264
- * {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
265
- * there's no problem on the `input` value, JSON string would be returned.
266
- *
267
- * For reference, with type assertion, it is even 5x times faster than the native
268
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
269
- * with confidence.
270
- *
271
- * @template T Type of the input value
272
- * @param input A value to be asserted and converted
273
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
274
- * @return JSON string value
275
- *
276
- * @author Jeongho Nam - https://github.com/samchon
277
- */
278
- export function assertStringify<T>(
279
- input: T,
280
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
281
- ): string;
282
-
283
- /**
284
- * 5x faster `JSON.stringify()` function with type assertion.
285
- *
286
- * `typia.json.assertStringify()` is a combination function of {@link assert} and
287
- * {@link stringify}. Therefore, it converts an input value to
288
- * JSON (JavaScript Object Notation) string, with type assertion.
289
- *
290
- * In such reason, when `input` value is not matched with the type `T`, it throws an
291
- * {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
292
- * there's no problem on the `input` value, JSON string would be returned.
293
- *
294
- * For reference, with type assertion, it is even 5x times faster than the native
295
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
296
- * with confidence.
297
- *
298
- * @template T Type of the input value
299
- * @param input A value to be asserted and converted
300
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
301
- * @return JSON string value
302
- *
303
- * @author Jeongho Nam - https://github.com/samchon
304
- */
305
- export function assertStringify<T>(
306
- input: T,
307
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
308
- ): unknown;
309
-
310
- /**
311
- * @internal
312
- */
313
- export function assertStringify(): string {
314
- halt("assertStringify");
315
- }
316
-
317
- /**
318
- * 7x faster `JSON.stringify()` function with type checking.
319
- *
320
- * `typia.json.stringify()` is a combination function of {@link is} and
321
- * {@link stringify}. Therefore, it converts an input value to JSON
322
- * (JavaScript Object Notation) string, with type checking.
323
- *
324
- * In such reason, when `input` value is not matched with the type `T`, it returns
325
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string
326
- * would be returned.
327
- *
328
- * For reference, with type checking, it is even 7x times faster than the native
329
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
330
- * with confidence.
331
- *
332
- * @template T Type of the input value
333
- * @param input A value to be checked and converted
334
- * @return JSON string value when exact type, otherwise null
335
- *
336
- * @author Jeongho Nam - https://github.com/samchon
337
- */
338
- export function isStringify<T>(input: T): string | null;
339
-
340
- /**
341
- * 7x faster `JSON.stringify()` function with type checking.
342
- *
343
- * `typia.json.isStringify()` is a combination function of {@link is} and
344
- * {@link stringify}. Therefore, it converts an input value to JSON
345
- * (JavaScript Object Notation) string, with type checking.
346
- *
347
- * In such reason, when `input` value is not matched with the type `T`, it returns
348
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string
349
- * would be returned.
350
- *
351
- * For reference, with type checking, it is even 7x times faster than the native
352
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
353
- * with confidence.
354
- *
355
- * @template T Type of the input value
356
- * @param input A value to be checked and converted
357
- * @return JSON string value when exact type, otherwise null
358
- *
359
- * @author Jeongho Nam - https://github.com/samchon
360
- */
361
- export function isStringify<T>(input: unknown): string | null;
362
-
363
- /**
364
- * @internal
365
- */
366
- export function isStringify(): string | null {
367
- halt("isStringify");
368
- }
369
-
370
- /**
371
- * 5x faster `JSON.stringify()` function with detailed type validation.
372
- *
373
- * `typia.json.validateStringify()` is a combination function of {@link validate} and
374
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
375
- * Notation) string, with detailed type validation.
376
- *
377
- * In such reason, when `input` value is not matched with the type `T`, it returns
378
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
379
- * there's no problem on the `input` value, JSON string would be stored in `data`
380
- * property of the output {@link IValidation.ISuccess} instance.
381
- *
382
- * For reference, with detailed type validation, it is even 5x times faster than the
383
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
384
- * conversion with confidence.
385
- *
386
- * @template T Type of the input value
387
- * @param input A value to be checked and converted
388
- * @returns Validation result with JSON string value
389
- *
390
- * @author Jeongho Nam - https://github.com/samchon
391
- */
392
- export function validateStringify<T>(input: T): IValidation<string>;
393
-
394
- /**
395
- * 5x faster `JSON.stringify()` function with detailed type validation.
396
- *
397
- * `typia.json.validateStringify()` is a combination function of {@link validate} and
398
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
399
- * Notation) string, with detailed type validation.
400
- *
401
- * In such reason, when `input` value is not matched with the type `T`, it returns
402
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
403
- * there's no problem on the `input` value, JSON string would be stored in `data`
404
- * property of the output {@link IValidation.ISuccess} instance.
405
- *
406
- * For reference, with detailed type validation, it is even 5x times faster than the
407
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
408
- * conversion with confidence.
409
- *
410
- * @template T Type of the input value
411
- * @param input A value to be checked and converted
412
- * @returns Validation result with JSON string value
413
- *
414
- * @author Jeongho Nam - https://github.com/samchon
415
- */
416
- export function validateStringify<T>(input: unknown): IValidation<string>;
417
-
418
- /**
419
- * @internal
420
- */
421
- export function validateStringify(): IValidation<string> {
422
- halt("validateStringify");
423
- }
424
-
425
- /* -----------------------------------------------------------
426
- FACTORY FUNCTIONS
427
- ----------------------------------------------------------- */
428
- /**
429
- * Creates a reusable {@link isParse} function.
430
- *
431
- * @danger You must configure the generic argument `T`
432
- * @returns Nothing until you configure the generic argument `T`
433
- * @throws compile error
434
- *
435
- * @author Jeongho Nam - https://github.com/samchon
436
- */
437
- export function createIsParse(): never;
438
-
439
- /**
440
- * Creates a reusable {@link isParse} function.
441
- *
442
- * @template T Expected type of parsed value
443
- * @returns A reusable `isParse` function
444
- *
445
- * @author Jeongho Nam - https://github.com/samchon
446
- */
447
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
448
-
449
- /**
450
- * @internal
451
- */
452
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
453
- halt("createIsParse");
454
- }
455
-
456
- /**
457
- * Creates a reusable {@link assertParse} function.
458
- *
459
- * @danger You must configure the generic argument `T`
460
- * @returns Nothing until you configure the generic argument `T`
461
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
462
- * @throws compile error
463
- *
464
- * @author Jeongho Nam - https://github.com/samchon
465
- */
466
- export function createAssertParse(
467
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
468
- ): never;
469
-
470
- /**
471
- * Creates a reusable {@link assertParse} function.
472
- *
473
- * @template T Expected type of parsed value
474
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
475
- * @returns A reusable `assertParse` function
476
- *
477
- * @author Jeongho Nam - https://github.com/samchon
478
- */
479
- export function createAssertParse<T>(
480
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
481
- ): (input: string) => Primitive<T>;
482
-
483
- /**
484
- * @internal
485
- */
486
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
487
- halt("createAssertParse");
488
- }
489
-
490
- /**
491
- * Creates a reusable {@link validateParse} function.
492
- *
493
- * @danger You must configure the generic argument `T`
494
- * @returns Nothing until you configure the generic argument `T`
495
- * @throws compile error
496
- *
497
- * @author Jeongho Nam - https://github.com/samchon
498
- */
499
- export function createValidateParse(): never;
500
-
501
- /**
502
- * Creates a reusable {@link validateParse} function.
503
- *
504
- * @template T Expected type of parsed value
505
- * @returns A reusable `validateParse` function
506
- *
507
- * @author Jeongho Nam - https://github.com/samchon
508
- */
509
- export function createValidateParse<T>(): (
510
- input: string,
511
- ) => IValidation<Primitive<T>>;
512
-
513
- /**
514
- * @internal
515
- */
516
- export function createValidateParse<T>(): (
517
- input: string,
518
- ) => IValidation<Primitive<T>> {
519
- halt("createValidateParse");
520
- }
521
-
522
- /**
523
- * Creates a reusable {@link stringify} function.
524
- *
525
- * @danger You must configure the generic argument `T`
526
- * @returns Nothing until you configure the generic argument `T`
527
- * @throws compile error
528
- *
529
- * @author Jeongho Nam - https://github.com/samchon
530
- */
531
- export function createStringify(): never;
532
-
533
- /**
534
- * Creates a reusable {@link stringify} function.
535
- *
536
- * @template T Type of the input value
537
- * @returns A reusable `stringify` function
538
- *
539
- * @author Jeongho Nam - https://github.com/samchon
540
- */
541
- export function createStringify<T>(): (input: T) => string;
542
-
543
- /**
544
- * @internal
545
- */
546
- export function createStringify<T>(): (input: T) => string {
547
- halt("createStringify");
548
- }
549
-
550
- /**
551
- * Creates a reusable {@link assertStringify} function.
552
- *
553
- * @danger You must configure the generic argument `T`
554
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
555
- * @returns Nothing until you configure the generic argument `T`
556
- * @throws compile error
557
- *
558
- * @author Jeongho Nam - https://github.com/samchon
559
- */
560
- export function createAssertStringify(
561
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
562
- ): never;
563
-
564
- /**
565
- * Creates a reusable {@link assertStringify} function.
566
- *
567
- * @template T Type of the input value
568
- * @param errorFactory Custom error factory. Default is `TypeGuardError`
569
- * @returns A reusable `assertStringify` function
570
- *
571
- * @author Jeongho Nam - https://github.com/samchon
572
- */
573
- export function createAssertStringify<T>(
574
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
575
- ): (input: unknown) => string;
576
-
577
- /**
578
- * @internal
579
- */
580
- export function createAssertStringify(): (input: unknown) => string {
581
- halt("createAssertStringify");
582
- }
583
-
584
- /**
585
- * Creates a reusable {@link isStringify} function.
586
- *
587
- * @danger You must configure the generic argument `T`
588
- * @returns Nothing until you configure the generic argument `T`
589
- * @throws compile error
590
- *
591
- * @author Jeongho Nam - https://github.com/samchon
592
- */
593
- export function createIsStringify(): never;
594
-
595
- /**
596
- * Creates a reusable {@link isStringify} function.
597
- *
598
- * @template T Type of the input value
599
- * @returns A reusable `isStringify` function
600
- *
601
- * @author Jeongho Nam - https://github.com/samchon
602
- */
603
- export function createIsStringify<T>(): (input: unknown) => string | null;
604
-
605
- /**
606
- * @internal
607
- */
608
- export function createIsStringify(): (input: unknown) => string | null {
609
- halt("createIsStringify");
610
- }
611
-
612
- /**
613
- * Creates a reusable {@link validateStringify} function.
614
- *
615
- * @danger You must configure the generic argument `T`
616
- * @returns Nothing until you configure the generic argument `T`
617
- * @throws compile error
618
- *
619
- * @author Jeongho Nam - https://github.com/samchon
620
- */
621
- export function createValidateStringify(): never;
622
-
623
- /**
624
- * Creates a reusable {@link validateStringify} function.
625
- *
626
- * @template T Type of the input value
627
- * @returns A reusable `validateStringify` function
628
-
629
- * @author Jeongho Nam - https://github.com/samchon
630
- */
631
- export function createValidateStringify<T>(): (
632
- input: unknown,
633
- ) => IValidation<string>;
634
-
635
- /**
636
- * @internal
637
- */
638
- export function createValidateStringify(): (
639
- input: unknown,
640
- ) => IValidation<string> {
641
- halt("createValidateStringify");
642
- }
643
-
644
- /**
645
- * @internal
646
- */
647
- function halt(name: string): never {
648
- throw new Error(
649
- `Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
650
- );
651
- }
1
+ import { IJsonApplication } from "./schemas/json/IJsonApplication";
2
+
3
+ import { IValidation } from "./IValidation";
4
+ import { Primitive } from "./Primitive";
5
+ import { TypeGuardError } from "./TypeGuardError";
6
+
7
+ /* ===========================================================
8
+ JSON
9
+ - SCHEMA
10
+ - PARSE
11
+ - STRINGIFY
12
+ - FACTORY FUNCTIONS
13
+ ==============================================================
14
+ SCHEMA
15
+ ----------------------------------------------------------- */
16
+ /**
17
+ * > You must configure the generic argument `Types`.
18
+ *
19
+ * JSON Schema Application.
20
+ *
21
+ * Creates a JSON schema application which contains both main JSON schemas and
22
+ * components. Note that, all of the named types are stored in the
23
+ * {@link IJsonApplication.components} property for the `$ref` referencing.
24
+ *
25
+ * Also, you can specify the OpenAPI version by configuring the second generic
26
+ * argument `Version`. For reference, the default version is `"3.1"`, and key
27
+ * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
28
+ *
29
+ * @template Types Tuple of target types
30
+ * @template Purpose Purpose of the JSON schema
31
+ * @template Surplus Allow surplus properties starting with `x-typia-` or not
32
+ * @return JSON schema application
33
+ *
34
+ * @author Jeongho Nam - https://github.com/samchon
35
+ */
36
+ export function application(): never;
37
+
38
+ /**
39
+ * JSON Schema Application.
40
+ *
41
+ * Creates a JSON schema application which contains both main JSON schemas and
42
+ * components. Note that, all of the named types are stored in the
43
+ * {@link IJsonApplication.components} property for the `$ref` referencing.
44
+ *
45
+ * Also, you can specify the OpenAPI version by configuring the second generic
46
+ * argument `Version`. For reference, the default version is `"3.1"`, and key
47
+ * different of `"3.0"` and `"3.1"` is whether supporting the tuple type or not.
48
+ *
49
+ * @template Types Tuple of target types
50
+ * @template Version Version of OpenAPI specification. Default is 3.1
51
+ * @return JSON schema application
52
+ *
53
+ * @author Jeongho Nam - https://github.com/samchon
54
+ */
55
+ export function application<
56
+ Types extends unknown[],
57
+ Version extends "3.0" | "3.1" = "3.1",
58
+ >(): IJsonApplication<Version, Types>;
59
+
60
+ /**
61
+ * @internal
62
+ */
63
+ export function application(): never {
64
+ halt("application");
65
+ }
66
+
67
+ /* -----------------------------------------------------------
68
+ PARSE
69
+ ----------------------------------------------------------- */
70
+ /**
71
+ * > You must configure the generic argument `T`.
72
+ *
73
+ * Safe `JSON.parse()` function with type assertion.
74
+ *
75
+ * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
76
+ * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
77
+ * to a `T` typed instance with type assertion.
78
+ *
79
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
80
+ * throws {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
81
+ * there's no problem on the parsed value, the parsed value would be returned.
82
+ *
83
+ * @template T Expected type of parsed value
84
+ * @param input JSON string
85
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
86
+ * @returns Parsed value
87
+ *
88
+ * @author Jeongho Nam - https://github.com/samchon
89
+ */
90
+ export function assertParse(
91
+ input: string,
92
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
93
+ ): never;
94
+
95
+ /**
96
+ * Safe `JSON.parse()` function with type assertion.
97
+ *
98
+ * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
99
+ * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
100
+ * to a `T` typed instance with type assertion.
101
+ *
102
+ * In such reason, when parsed JSON string value is not matched with the type `T`,
103
+ * it throws {@link TypeGuardError} or custom error generated by *errorFactory*.
104
+ * Otherwise, there's no problem on the parsed value, the parsed value would be
105
+ * returned.
106
+ *
107
+ * @template T Expected type of parsed value
108
+ * @param input JSON string
109
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
110
+ * @returns Parsed value
111
+ *
112
+ * @author Jeongho Nam - https://github.com/samchon
113
+ */
114
+ export function assertParse<T>(
115
+ input: string,
116
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
117
+ ): Primitive<T>;
118
+
119
+ /**
120
+ * @internal
121
+ */
122
+ export function assertParse<T>(): Primitive<T> {
123
+ halt("assertParse");
124
+ }
125
+
126
+ /**
127
+ * > You must configure the generic argument `T`.
128
+ *
129
+ * Safe `JSON.parse()` function with type checking.
130
+ *
131
+ * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
132
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
133
+ * instance with type checking.
134
+ *
135
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
136
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
137
+ * value would be returned.
138
+ *
139
+ * @template T Expected type of parsed value
140
+ * @param input JSON string
141
+ * @returns Parsed value when exact type, otherwise `null`
142
+ *
143
+ * @author Jeongho Nam - https://github.com/samchon
144
+ */
145
+ export function isParse(input: string): never;
146
+
147
+ /**
148
+ * Safe `JSON.parse()` function with type checking.
149
+ *
150
+ * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
151
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
152
+ * instance with type checking.
153
+ *
154
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
155
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
156
+ * value would be returned.
157
+ *
158
+ * @template T Expected type of parsed value
159
+ * @param input JSON string
160
+ * @returns Parsed value when exact type, otherwise `null`
161
+ *
162
+ * @author Jeongho Nam - https://github.com/samchon
163
+ */
164
+ export function isParse<T>(input: string): Primitive<T> | null;
165
+
166
+ /**
167
+ * @internal
168
+ */
169
+ export function isParse<T>(): Primitive<T> | null {
170
+ halt("isParse");
171
+ }
172
+
173
+ /**
174
+ * > You must configure the generic argument `T`.
175
+ *
176
+ * Safe `JSON.parse()` function with detailed type validation.
177
+ *
178
+ * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
179
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
180
+ * to a `T` typed instance with detailed type validation.
181
+ *
182
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
183
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
184
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
185
+ * property of the output {@link IValidation.ISuccess} instance.
186
+ *
187
+ * @template T Expected type of parsed value
188
+ * @param input JSON string
189
+ * @returns Validation result with JSON parsed value
190
+ *
191
+ * @author Jeongho Nam - https://github.com/samchon
192
+ */
193
+ export function validateParse(input: string): never;
194
+
195
+ /**
196
+ * Safe `JSON.parse()` function with detailed type validation.
197
+ *
198
+ * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
199
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
200
+ * to a `T` typed instance with detailed type validation.
201
+ *
202
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
203
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
204
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
205
+ * property of the output {@link IValidation.ISuccess} instance.
206
+ *
207
+ * @template T Expected type of parsed value
208
+ * @param input JSON string
209
+ * @returns Validation result with JSON parsed value
210
+ *
211
+ * @author Jeongho Nam - https://github.com/samchon
212
+ */
213
+ export function validateParse<T>(input: string): IValidation<Primitive<T>>;
214
+
215
+ /**
216
+ * @internal
217
+ */
218
+ export function validateParse<T>(): IValidation<Primitive<T>> {
219
+ halt("validateParse");
220
+ }
221
+
222
+ /* -----------------------------------------------------------
223
+ STRINGIFY
224
+ ----------------------------------------------------------- */
225
+ /**
226
+ * 8x faster `JSON.stringify()` function.
227
+ *
228
+ * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x
229
+ * faster than the native `JSON.stringify()` function. The 5x faster principle is
230
+ * because it writes an optimized JSON conversion plan, only for the type `T`.
231
+ *
232
+ * For reference, this `typia.json.stringify()` does not validate the input value type.
233
+ * It just believes that the input value is following the type `T`. Therefore, if you
234
+ * can't ensure the input value type, it would be better to call one of below
235
+ * functions instead.
236
+ *
237
+ * - {@link assertStringify}
238
+ * - {@link isStringify}
239
+ * - {@link validateStringify}
240
+ *
241
+ * @template T Type of the input value
242
+ * @param input A value to be converted
243
+ * @return JSON string value
244
+ *
245
+ * @author Jeongho Nam - https://github.com/samchon
246
+ */
247
+ export function stringify<T>(input: T): string;
248
+
249
+ /**
250
+ * @internal
251
+ */
252
+ export function stringify(): never {
253
+ halt("stringify");
254
+ }
255
+
256
+ /**
257
+ * 5x faster `JSON.stringify()` function with type assertion.
258
+ *
259
+ * `typia.json.assertStringify()` is a combination function of {@link assert} and
260
+ * {@link stringify}. Therefore, it converts an input value to
261
+ * JSON (JavaScript Object Notation) string, with type assertion.
262
+ *
263
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
264
+ * {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
265
+ * there's no problem on the `input` value, JSON string would be returned.
266
+ *
267
+ * For reference, with type assertion, it is even 5x times faster than the native
268
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
269
+ * with confidence.
270
+ *
271
+ * @template T Type of the input value
272
+ * @param input A value to be asserted and converted
273
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
274
+ * @return JSON string value
275
+ *
276
+ * @author Jeongho Nam - https://github.com/samchon
277
+ */
278
+ export function assertStringify<T>(
279
+ input: T,
280
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
281
+ ): string;
282
+
283
+ /**
284
+ * 5x faster `JSON.stringify()` function with type assertion.
285
+ *
286
+ * `typia.json.assertStringify()` is a combination function of {@link assert} and
287
+ * {@link stringify}. Therefore, it converts an input value to
288
+ * JSON (JavaScript Object Notation) string, with type assertion.
289
+ *
290
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
291
+ * {@link TypeGuardError} or custom error generated by *errorFactory*. Otherwise,
292
+ * there's no problem on the `input` value, JSON string would be returned.
293
+ *
294
+ * For reference, with type assertion, it is even 5x times faster than the native
295
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
296
+ * with confidence.
297
+ *
298
+ * @template T Type of the input value
299
+ * @param input A value to be asserted and converted
300
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
301
+ * @return JSON string value
302
+ *
303
+ * @author Jeongho Nam - https://github.com/samchon
304
+ */
305
+ export function assertStringify<T>(
306
+ input: T,
307
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
308
+ ): unknown;
309
+
310
+ /**
311
+ * @internal
312
+ */
313
+ export function assertStringify(): string {
314
+ halt("assertStringify");
315
+ }
316
+
317
+ /**
318
+ * 7x faster `JSON.stringify()` function with type checking.
319
+ *
320
+ * `typia.json.stringify()` is a combination function of {@link is} and
321
+ * {@link stringify}. Therefore, it converts an input value to JSON
322
+ * (JavaScript Object Notation) string, with type checking.
323
+ *
324
+ * In such reason, when `input` value is not matched with the type `T`, it returns
325
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string
326
+ * would be returned.
327
+ *
328
+ * For reference, with type checking, it is even 7x times faster than the native
329
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
330
+ * with confidence.
331
+ *
332
+ * @template T Type of the input value
333
+ * @param input A value to be checked and converted
334
+ * @return JSON string value when exact type, otherwise null
335
+ *
336
+ * @author Jeongho Nam - https://github.com/samchon
337
+ */
338
+ export function isStringify<T>(input: T): string | null;
339
+
340
+ /**
341
+ * 7x faster `JSON.stringify()` function with type checking.
342
+ *
343
+ * `typia.json.isStringify()` is a combination function of {@link is} and
344
+ * {@link stringify}. Therefore, it converts an input value to JSON
345
+ * (JavaScript Object Notation) string, with type checking.
346
+ *
347
+ * In such reason, when `input` value is not matched with the type `T`, it returns
348
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string
349
+ * would be returned.
350
+ *
351
+ * For reference, with type checking, it is even 7x times faster than the native
352
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
353
+ * with confidence.
354
+ *
355
+ * @template T Type of the input value
356
+ * @param input A value to be checked and converted
357
+ * @return JSON string value when exact type, otherwise null
358
+ *
359
+ * @author Jeongho Nam - https://github.com/samchon
360
+ */
361
+ export function isStringify<T>(input: unknown): string | null;
362
+
363
+ /**
364
+ * @internal
365
+ */
366
+ export function isStringify(): string | null {
367
+ halt("isStringify");
368
+ }
369
+
370
+ /**
371
+ * 5x faster `JSON.stringify()` function with detailed type validation.
372
+ *
373
+ * `typia.json.validateStringify()` is a combination function of {@link validate} and
374
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
375
+ * Notation) string, with detailed type validation.
376
+ *
377
+ * In such reason, when `input` value is not matched with the type `T`, it returns
378
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
379
+ * there's no problem on the `input` value, JSON string would be stored in `data`
380
+ * property of the output {@link IValidation.ISuccess} instance.
381
+ *
382
+ * For reference, with detailed type validation, it is even 5x times faster than the
383
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
384
+ * conversion with confidence.
385
+ *
386
+ * @template T Type of the input value
387
+ * @param input A value to be checked and converted
388
+ * @returns Validation result with JSON string value
389
+ *
390
+ * @author Jeongho Nam - https://github.com/samchon
391
+ */
392
+ export function validateStringify<T>(input: T): IValidation<string>;
393
+
394
+ /**
395
+ * 5x faster `JSON.stringify()` function with detailed type validation.
396
+ *
397
+ * `typia.json.validateStringify()` is a combination function of {@link validate} and
398
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
399
+ * Notation) string, with detailed type validation.
400
+ *
401
+ * In such reason, when `input` value is not matched with the type `T`, it returns
402
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
403
+ * there's no problem on the `input` value, JSON string would be stored in `data`
404
+ * property of the output {@link IValidation.ISuccess} instance.
405
+ *
406
+ * For reference, with detailed type validation, it is even 5x times faster than the
407
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
408
+ * conversion with confidence.
409
+ *
410
+ * @template T Type of the input value
411
+ * @param input A value to be checked and converted
412
+ * @returns Validation result with JSON string value
413
+ *
414
+ * @author Jeongho Nam - https://github.com/samchon
415
+ */
416
+ export function validateStringify<T>(input: unknown): IValidation<string>;
417
+
418
+ /**
419
+ * @internal
420
+ */
421
+ export function validateStringify(): IValidation<string> {
422
+ halt("validateStringify");
423
+ }
424
+
425
+ /* -----------------------------------------------------------
426
+ FACTORY FUNCTIONS
427
+ ----------------------------------------------------------- */
428
+ /**
429
+ * Creates a reusable {@link isParse} function.
430
+ *
431
+ * @danger You must configure the generic argument `T`
432
+ * @returns Nothing until you configure the generic argument `T`
433
+ * @throws compile error
434
+ *
435
+ * @author Jeongho Nam - https://github.com/samchon
436
+ */
437
+ export function createIsParse(): never;
438
+
439
+ /**
440
+ * Creates a reusable {@link isParse} function.
441
+ *
442
+ * @template T Expected type of parsed value
443
+ * @returns A reusable `isParse` function
444
+ *
445
+ * @author Jeongho Nam - https://github.com/samchon
446
+ */
447
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null;
448
+
449
+ /**
450
+ * @internal
451
+ */
452
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null {
453
+ halt("createIsParse");
454
+ }
455
+
456
+ /**
457
+ * Creates a reusable {@link assertParse} function.
458
+ *
459
+ * @danger You must configure the generic argument `T`
460
+ * @returns Nothing until you configure the generic argument `T`
461
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
462
+ * @throws compile error
463
+ *
464
+ * @author Jeongho Nam - https://github.com/samchon
465
+ */
466
+ export function createAssertParse(
467
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
468
+ ): never;
469
+
470
+ /**
471
+ * Creates a reusable {@link assertParse} function.
472
+ *
473
+ * @template T Expected type of parsed value
474
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
475
+ * @returns A reusable `assertParse` function
476
+ *
477
+ * @author Jeongho Nam - https://github.com/samchon
478
+ */
479
+ export function createAssertParse<T>(
480
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
481
+ ): (input: string) => Primitive<T>;
482
+
483
+ /**
484
+ * @internal
485
+ */
486
+ export function createAssertParse<T>(): (input: string) => Primitive<T> {
487
+ halt("createAssertParse");
488
+ }
489
+
490
+ /**
491
+ * Creates a reusable {@link validateParse} function.
492
+ *
493
+ * @danger You must configure the generic argument `T`
494
+ * @returns Nothing until you configure the generic argument `T`
495
+ * @throws compile error
496
+ *
497
+ * @author Jeongho Nam - https://github.com/samchon
498
+ */
499
+ export function createValidateParse(): never;
500
+
501
+ /**
502
+ * Creates a reusable {@link validateParse} function.
503
+ *
504
+ * @template T Expected type of parsed value
505
+ * @returns A reusable `validateParse` function
506
+ *
507
+ * @author Jeongho Nam - https://github.com/samchon
508
+ */
509
+ export function createValidateParse<T>(): (
510
+ input: string,
511
+ ) => IValidation<Primitive<T>>;
512
+
513
+ /**
514
+ * @internal
515
+ */
516
+ export function createValidateParse<T>(): (
517
+ input: string,
518
+ ) => IValidation<Primitive<T>> {
519
+ halt("createValidateParse");
520
+ }
521
+
522
+ /**
523
+ * Creates a reusable {@link stringify} function.
524
+ *
525
+ * @danger You must configure the generic argument `T`
526
+ * @returns Nothing until you configure the generic argument `T`
527
+ * @throws compile error
528
+ *
529
+ * @author Jeongho Nam - https://github.com/samchon
530
+ */
531
+ export function createStringify(): never;
532
+
533
+ /**
534
+ * Creates a reusable {@link stringify} function.
535
+ *
536
+ * @template T Type of the input value
537
+ * @returns A reusable `stringify` function
538
+ *
539
+ * @author Jeongho Nam - https://github.com/samchon
540
+ */
541
+ export function createStringify<T>(): (input: T) => string;
542
+
543
+ /**
544
+ * @internal
545
+ */
546
+ export function createStringify<T>(): (input: T) => string {
547
+ halt("createStringify");
548
+ }
549
+
550
+ /**
551
+ * Creates a reusable {@link assertStringify} function.
552
+ *
553
+ * @danger You must configure the generic argument `T`
554
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
555
+ * @returns Nothing until you configure the generic argument `T`
556
+ * @throws compile error
557
+ *
558
+ * @author Jeongho Nam - https://github.com/samchon
559
+ */
560
+ export function createAssertStringify(
561
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
562
+ ): never;
563
+
564
+ /**
565
+ * Creates a reusable {@link assertStringify} function.
566
+ *
567
+ * @template T Type of the input value
568
+ * @param errorFactory Custom error factory. Default is `TypeGuardError`
569
+ * @returns A reusable `assertStringify` function
570
+ *
571
+ * @author Jeongho Nam - https://github.com/samchon
572
+ */
573
+ export function createAssertStringify<T>(
574
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
575
+ ): (input: unknown) => string;
576
+
577
+ /**
578
+ * @internal
579
+ */
580
+ export function createAssertStringify(): (input: unknown) => string {
581
+ halt("createAssertStringify");
582
+ }
583
+
584
+ /**
585
+ * Creates a reusable {@link isStringify} function.
586
+ *
587
+ * @danger You must configure the generic argument `T`
588
+ * @returns Nothing until you configure the generic argument `T`
589
+ * @throws compile error
590
+ *
591
+ * @author Jeongho Nam - https://github.com/samchon
592
+ */
593
+ export function createIsStringify(): never;
594
+
595
+ /**
596
+ * Creates a reusable {@link isStringify} function.
597
+ *
598
+ * @template T Type of the input value
599
+ * @returns A reusable `isStringify` function
600
+ *
601
+ * @author Jeongho Nam - https://github.com/samchon
602
+ */
603
+ export function createIsStringify<T>(): (input: unknown) => string | null;
604
+
605
+ /**
606
+ * @internal
607
+ */
608
+ export function createIsStringify(): (input: unknown) => string | null {
609
+ halt("createIsStringify");
610
+ }
611
+
612
+ /**
613
+ * Creates a reusable {@link validateStringify} function.
614
+ *
615
+ * @danger You must configure the generic argument `T`
616
+ * @returns Nothing until you configure the generic argument `T`
617
+ * @throws compile error
618
+ *
619
+ * @author Jeongho Nam - https://github.com/samchon
620
+ */
621
+ export function createValidateStringify(): never;
622
+
623
+ /**
624
+ * Creates a reusable {@link validateStringify} function.
625
+ *
626
+ * @template T Type of the input value
627
+ * @returns A reusable `validateStringify` function
628
+
629
+ * @author Jeongho Nam - https://github.com/samchon
630
+ */
631
+ export function createValidateStringify<T>(): (
632
+ input: unknown,
633
+ ) => IValidation<string>;
634
+
635
+ /**
636
+ * @internal
637
+ */
638
+ export function createValidateStringify(): (
639
+ input: unknown,
640
+ ) => IValidation<string> {
641
+ halt("createValidateStringify");
642
+ }
643
+
644
+ /**
645
+ * @internal
646
+ */
647
+ function halt(name: string): never {
648
+ throw new Error(
649
+ `Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
650
+ );
651
+ }