typia 12.0.0-dev.20260309 → 12.0.0-dev.20260311

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 (134) hide show
  1. package/lib/executable/setup/PluginConfigurator.js +3 -3
  2. package/lib/executable/setup/PluginConfigurator.mjs +3 -3
  3. package/lib/executable/setup/PluginConfigurator.mjs.map +1 -1
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/executable/typia.mjs +15 -15
  6. package/package.json +5 -5
  7. package/src/TypeGuardError.ts +145 -145
  8. package/src/executable/TypiaGenerateWizard.ts +82 -82
  9. package/src/executable/TypiaPatchWizard.ts +45 -45
  10. package/src/executable/TypiaSetupWizard.ts +171 -171
  11. package/src/executable/setup/ArgumentParser.ts +42 -42
  12. package/src/executable/setup/CommandExecutor.ts +8 -8
  13. package/src/executable/setup/FileRetriever.ts +19 -19
  14. package/src/executable/setup/PackageManager.ts +87 -87
  15. package/src/executable/setup/PluginConfigurator.ts +74 -74
  16. package/src/executable/typia.ts +55 -55
  17. package/src/functional.ts +600 -600
  18. package/src/http.ts +843 -843
  19. package/src/index.ts +4 -4
  20. package/src/internal/_IProtobufWriter.ts +18 -18
  21. package/src/internal/_ProtobufReader.ts +187 -187
  22. package/src/internal/_ProtobufSizer.ts +137 -137
  23. package/src/internal/_ProtobufWriter.ts +135 -135
  24. package/src/internal/_accessExpressionAsString.ts +46 -46
  25. package/src/internal/_assertGuard.ts +13 -13
  26. package/src/internal/_coerceLlmArguments.ts +7 -7
  27. package/src/internal/_createStandardSchema.ts +133 -133
  28. package/src/internal/_functionalTypeGuardErrorFactory.ts +4 -4
  29. package/src/internal/_httpFormDataReadArray.ts +4 -4
  30. package/src/internal/_httpFormDataReadBigint.ts +18 -18
  31. package/src/internal/_httpFormDataReadBlob.ts +10 -10
  32. package/src/internal/_httpFormDataReadBoolean.ts +16 -16
  33. package/src/internal/_httpFormDataReadFile.ts +10 -10
  34. package/src/internal/_httpFormDataReadNumber.ts +15 -15
  35. package/src/internal/_httpFormDataReadString.ts +10 -10
  36. package/src/internal/_httpHeaderReadBigint.ts +10 -10
  37. package/src/internal/_httpHeaderReadBoolean.ts +8 -8
  38. package/src/internal/_httpHeaderReadNumber.ts +7 -7
  39. package/src/internal/_httpParameterReadBigint.ts +10 -10
  40. package/src/internal/_httpParameterReadBoolean.ts +8 -8
  41. package/src/internal/_httpParameterReadNumber.ts +7 -7
  42. package/src/internal/_httpParameterReadString.ts +2 -2
  43. package/src/internal/_httpQueryParseURLSearchParams.ts +12 -12
  44. package/src/internal/_httpQueryReadArray.ts +4 -4
  45. package/src/internal/_httpQueryReadBigint.ts +12 -12
  46. package/src/internal/_httpQueryReadBoolean.ts +14 -14
  47. package/src/internal/_httpQueryReadNumber.ts +9 -9
  48. package/src/internal/_httpQueryReadString.ts +4 -4
  49. package/src/internal/_isBetween.ts +2 -2
  50. package/src/internal/_isBigintString.ts +8 -8
  51. package/src/internal/_isFormatByte.ts +7 -7
  52. package/src/internal/_isFormatDate.ts +3 -3
  53. package/src/internal/_isFormatDateTime.ts +4 -4
  54. package/src/internal/_isFormatDuration.ts +4 -4
  55. package/src/internal/_isFormatEmail.ts +4 -4
  56. package/src/internal/_isFormatHostname.ts +4 -4
  57. package/src/internal/_isFormatIdnEmail.ts +4 -4
  58. package/src/internal/_isFormatIdnHostname.ts +4 -4
  59. package/src/internal/_isFormatIpv4.ts +4 -4
  60. package/src/internal/_isFormatIpv6.ts +4 -4
  61. package/src/internal/_isFormatIri.ts +3 -3
  62. package/src/internal/_isFormatIriReference.ts +4 -4
  63. package/src/internal/_isFormatJsonPointer.ts +3 -3
  64. package/src/internal/_isFormatPassword.ts +1 -1
  65. package/src/internal/_isFormatRegex.ts +8 -8
  66. package/src/internal/_isFormatRelativeJsonPointer.ts +4 -4
  67. package/src/internal/_isFormatTime.ts +4 -4
  68. package/src/internal/_isFormatUri.ts +6 -6
  69. package/src/internal/_isFormatUriReference.ts +5 -5
  70. package/src/internal/_isFormatUriTemplate.ts +4 -4
  71. package/src/internal/_isFormatUrl.ts +4 -4
  72. package/src/internal/_isFormatUuid.ts +3 -3
  73. package/src/internal/_isTypeFloat.ts +5 -5
  74. package/src/internal/_isTypeInt32.ts +5 -5
  75. package/src/internal/_isTypeInt64.ts +5 -5
  76. package/src/internal/_isTypeUint32.ts +5 -5
  77. package/src/internal/_isTypeUint64.ts +5 -5
  78. package/src/internal/_isUniqueItems.ts +159 -159
  79. package/src/internal/_jsonStringifyNumber.ts +12 -12
  80. package/src/internal/_jsonStringifyRest.ts +3 -3
  81. package/src/internal/_jsonStringifyString.ts +42 -42
  82. package/src/internal/_jsonStringifyTail.ts +2 -2
  83. package/src/internal/_llmApplicationFinalize.ts +24 -24
  84. package/src/internal/_miscCloneAny.ts +46 -46
  85. package/src/internal/_notationAny.ts +37 -37
  86. package/src/internal/_notationCamel.ts +13 -13
  87. package/src/internal/_notationPascal.ts +8 -8
  88. package/src/internal/_notationSnake.ts +43 -43
  89. package/src/internal/_parseLlmArguments.ts +7 -7
  90. package/src/internal/_randomArray.ts +21 -21
  91. package/src/internal/_randomBigint.ts +6 -6
  92. package/src/internal/_randomBoolean.ts +1 -1
  93. package/src/internal/_randomFormatByte.ts +3 -3
  94. package/src/internal/_randomFormatDate.ts +18 -18
  95. package/src/internal/_randomFormatDatetime.ts +16 -16
  96. package/src/internal/_randomFormatDuration.ts +27 -27
  97. package/src/internal/_randomFormatEmail.ts +11 -11
  98. package/src/internal/_randomFormatHostname.ts +6 -6
  99. package/src/internal/_randomFormatIdnEmail.ts +3 -3
  100. package/src/internal/_randomFormatIdnHostname.ts +3 -3
  101. package/src/internal/_randomFormatIpv4.ts +11 -11
  102. package/src/internal/_randomFormatIpv6.ts +11 -11
  103. package/src/internal/_randomFormatIri.ts +3 -3
  104. package/src/internal/_randomFormatIriReference.ts +3 -3
  105. package/src/internal/_randomFormatJsonPointer.ts +7 -7
  106. package/src/internal/_randomFormatPassword.ts +8 -8
  107. package/src/internal/_randomFormatRegex.ts +4 -4
  108. package/src/internal/_randomFormatRelativeJsonPointer.ts +8 -8
  109. package/src/internal/_randomFormatTime.ts +14 -14
  110. package/src/internal/_randomFormatUri.ts +3 -3
  111. package/src/internal/_randomFormatUriReference.ts +3 -3
  112. package/src/internal/_randomFormatUriTemplate.ts +3 -3
  113. package/src/internal/_randomFormatUrl.ts +11 -11
  114. package/src/internal/_randomFormatUuid.ts +6 -6
  115. package/src/internal/_randomInteger.ts +53 -53
  116. package/src/internal/_randomNumber.ts +80 -80
  117. package/src/internal/_randomPattern.ts +10 -10
  118. package/src/internal/_randomPick.ts +9 -9
  119. package/src/internal/_randomString.ts +24 -24
  120. package/src/internal/_throwTypeGuardError.ts +5 -5
  121. package/src/internal/_validateReport.ts +21 -21
  122. package/src/internal/private/__notationCapitalize.ts +2 -2
  123. package/src/internal/private/__notationUnsnake.ts +24 -24
  124. package/src/json.ts +553 -553
  125. package/src/llm.ts +408 -408
  126. package/src/misc.ts +448 -448
  127. package/src/module.ts +811 -811
  128. package/src/notations.ts +624 -624
  129. package/src/programmers/TypiaProgrammer.ts +8 -8
  130. package/src/protobuf.ts +499 -499
  131. package/src/re-exports.ts +33 -33
  132. package/src/reflect.ts +75 -75
  133. package/src/transform.ts +5 -5
  134. package/src/transformers/NoTransformConfigurationError.ts +16 -16
package/src/functional.ts CHANGED
@@ -1,600 +1,600 @@
1
- import { IValidation } from "@typia/interface";
2
-
3
- import { TypeGuardError } from "./TypeGuardError";
4
- import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
5
-
6
- /* ===========================================================
7
- FUNCTIONAL
8
- - ASSERT
9
- - IS
10
- - VALIDATE
11
- ==============================================================
12
- ASSERT
13
- ----------------------------------------------------------- */
14
- /**
15
- * Wraps function to assert both parameters and return value.
16
- *
17
- * Wraps the target function and validates all parameters before calling and
18
- * return value after calling through {@link assert}. Throws on first mismatch.
19
- *
20
- * Error path format:
21
- *
22
- * - Parameter errors: `$input.parameters[0].property`
23
- * - Return errors: `$input.return.property`
24
- *
25
- * Related functions:
26
- *
27
- * - {@link assertParameters} — Validates parameters only
28
- * - {@link assertReturn} — Validates return value only
29
- * - {@link validateFunction} — Collects all errors instead of throwing
30
- * - {@link assertEqualsFunction} — Also rejects extra properties
31
- *
32
- * @template T Target function type
33
- * @param func Function to wrap
34
- * @param errorFactory Custom error factory receiving
35
- * {@link TypeGuardError.IProps}
36
- * @returns Wrapped function with same signature
37
- * @throws {TypeGuardError} When parameter or return value type mismatch
38
- */
39
- export function assertFunction<T extends (...args: any[]) => any>(
40
- func: T,
41
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
42
- ): T;
43
-
44
- /** @internal */
45
- export function assertFunction(): never {
46
- NoTransformConfigurationError("functional.assertFunction");
47
- }
48
-
49
- /**
50
- * Wraps function to assert parameters only.
51
- *
52
- * Wraps the target function and validates all parameters before calling through
53
- * {@link assert}. Return value is not validated. Throws on first mismatch.
54
- *
55
- * Error path format: `$input.parameters[0].property`
56
- *
57
- * Related functions:
58
- *
59
- * - {@link assertFunction} — Also validates return value
60
- * - {@link assertReturn} — Validates return value only
61
- * - {@link validateParameters} — Collects all errors instead of throwing
62
- * - {@link assertEqualsParameters} — Also rejects extra properties
63
- *
64
- * @template T Target function type
65
- * @param func Function to wrap
66
- * @param errorFactory Custom error factory receiving
67
- * {@link TypeGuardError.IProps}
68
- * @returns Wrapped function with same signature
69
- * @throws {TypeGuardError} When parameter type mismatch
70
- */
71
- export function assertParameters<T extends (...args: any[]) => any>(
72
- func: T,
73
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
74
- ): T;
75
-
76
- /** @internal */
77
- export function assertParameters(): never {
78
- NoTransformConfigurationError("functional.assertParameters");
79
- }
80
-
81
- /**
82
- * Wraps function to assert return value only.
83
- *
84
- * Wraps the target function and validates return value after calling through
85
- * {@link assert}. Parameters are not validated. Throws on mismatch.
86
- *
87
- * Error path format: `$input.return.property`
88
- *
89
- * Related functions:
90
- *
91
- * - {@link assertFunction} — Also validates parameters
92
- * - {@link assertParameters} — Validates parameters only
93
- * - {@link validateReturn} — Collects all errors instead of throwing
94
- * - {@link assertEqualsReturn} — Also rejects extra properties
95
- *
96
- * @template T Target function type
97
- * @param func Function to wrap
98
- * @param errorFactory Custom error factory receiving
99
- * {@link TypeGuardError.IProps}
100
- * @returns Wrapped function with same signature
101
- * @throws {TypeGuardError} When return value type mismatch
102
- */
103
- export function assertReturn<T extends (...args: any[]) => any>(
104
- func: T,
105
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
106
- ): T;
107
-
108
- /** @internal */
109
- export function assertReturn(): never {
110
- NoTransformConfigurationError("functional.assertReturn");
111
- }
112
-
113
- /**
114
- * Wraps function to assert parameters and return value with strict equality.
115
- *
116
- * Wraps the target function and validates through {@link assertEquals}. Also
117
- * rejects extra properties not defined in type. Throws on first mismatch.
118
- *
119
- * Error path format:
120
- *
121
- * - Parameter errors: `$input.parameters[0].property`
122
- * - Return errors: `$input.return.property`
123
- *
124
- * Related functions:
125
- *
126
- * - {@link assertFunction} — Allows extra properties
127
- * - {@link assertEqualsParameters} — Validates parameters only
128
- * - {@link assertEqualsReturn} — Validates return value only
129
- * - {@link validateEqualsFunction} — Collects all errors instead of throwing
130
- *
131
- * @template T Target function type
132
- * @param func Function to wrap
133
- * @param errorFactory Custom error factory receiving
134
- * {@link TypeGuardError.IProps}
135
- * @returns Wrapped function with same signature
136
- * @throws {TypeGuardError} When type mismatch or extra property detected
137
- */
138
- export function assertEqualsFunction<T extends (...args: any[]) => any>(
139
- func: T,
140
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
141
- ): T;
142
-
143
- /** @internal */
144
- export function assertEqualsFunction(): never {
145
- NoTransformConfigurationError("functional.assertEqualsFunction");
146
- }
147
-
148
- /**
149
- * Wraps function to assert parameters with strict equality.
150
- *
151
- * Wraps the target function and validates parameters through
152
- * {@link assertEquals}. Also rejects extra properties. Return value is not
153
- * validated.
154
- *
155
- * Error path format: `$input.parameters[0].property`
156
- *
157
- * Related functions:
158
- *
159
- * - {@link assertParameters} — Allows extra properties
160
- * - {@link assertEqualsFunction} — Also validates return value
161
- * - {@link validateEqualsParameters} — Collects all errors instead of throwing
162
- *
163
- * @template T Target function type
164
- * @param func Function to wrap
165
- * @param errorFactory Custom error factory receiving
166
- * {@link TypeGuardError.IProps}
167
- * @returns Wrapped function with same signature
168
- * @throws {TypeGuardError} When type mismatch or extra property detected
169
- */
170
- export function assertEqualsParameters<T extends (...args: any[]) => any>(
171
- func: T,
172
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
173
- ): T;
174
-
175
- /** @internal */
176
- export function assertEqualsParameters(): never {
177
- NoTransformConfigurationError("functional.assertEqualsParameters");
178
- }
179
-
180
- /**
181
- * Wraps function to assert return value with strict equality.
182
- *
183
- * Wraps the target function and validates return value through
184
- * {@link assertEquals}. Also rejects extra properties. Parameters are not
185
- * validated.
186
- *
187
- * Error path format: `$input.return.property`
188
- *
189
- * Related functions:
190
- *
191
- * - {@link assertReturn} — Allows extra properties
192
- * - {@link assertEqualsFunction} — Also validates parameters
193
- * - {@link validateEqualsReturn} — Collects all errors instead of throwing
194
- *
195
- * @template T Target function type
196
- * @param func Function to wrap
197
- * @param errorFactory Custom error factory receiving
198
- * {@link TypeGuardError.IProps}
199
- * @returns Wrapped function with same signature
200
- * @throws {TypeGuardError} When type mismatch or extra property detected
201
- */
202
- export function assertEqualsReturn<T extends (...args: any[]) => any>(
203
- func: T,
204
- errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
205
- ): T;
206
-
207
- /** @internal */
208
- export function assertEqualsReturn(): never {
209
- NoTransformConfigurationError("functional.assertEqualsReturn");
210
- }
211
-
212
- /* -----------------------------------------------------------
213
- IS
214
- ----------------------------------------------------------- */
215
- /**
216
- * Wraps function to test both parameters and return value.
217
- *
218
- * Wraps the target function and checks all parameters before calling and return
219
- * value after calling through {@link is}. Returns `null` on mismatch.
220
- *
221
- * Related functions:
222
- *
223
- * - {@link isParameters} — Tests parameters only
224
- * - {@link isReturn} — Tests return value only
225
- * - {@link assertFunction} — Throws with error details on mismatch
226
- * - {@link validateFunction} — Returns all error details
227
- * - {@link equalsFunction} — Also rejects extra properties
228
- *
229
- * @template T Target function type
230
- * @param func Function to wrap
231
- * @returns Wrapped function returning `Output | null`
232
- */
233
- export function isFunction<T extends (...args: any[]) => any>(
234
- func: T,
235
- ): T extends (...args: infer Arguments) => infer Output
236
- ? Output extends Promise<infer R>
237
- ? (...args: Arguments) => Promise<R | null>
238
- : (...args: Arguments) => Output | null
239
- : never;
240
-
241
- /** @internal */
242
- export function isFunction(): never {
243
- NoTransformConfigurationError("functional.isFunction");
244
- }
245
-
246
- /**
247
- * Wraps function to test parameters only.
248
- *
249
- * Wraps the target function and checks all parameters before calling through
250
- * {@link is}. Return value is not checked. Returns `null` on mismatch.
251
- *
252
- * Related functions:
253
- *
254
- * - {@link isFunction} — Also tests return value
255
- * - {@link isReturn} — Tests return value only
256
- * - {@link assertParameters} — Throws with error details
257
- * - {@link validateParameters} — Returns all error details
258
- * - {@link equalsParameters} — Also rejects extra properties
259
- *
260
- * @template T Target function type
261
- * @param func Function to wrap
262
- * @returns Wrapped function returning `Output | null`
263
- */
264
- export function isParameters<T extends (...args: any[]) => any>(
265
- func: T,
266
- ): T extends (...args: infer Arguments) => infer Output
267
- ? Output extends Promise<infer R>
268
- ? (...args: Arguments) => Promise<R | null>
269
- : (...args: Arguments) => Output | null
270
- : never;
271
-
272
- /** @internal */
273
- export function isParameters(): never {
274
- NoTransformConfigurationError("functional.isParameters");
275
- }
276
-
277
- /**
278
- * Wraps function to test return value only.
279
- *
280
- * Wraps the target function and checks return value after calling through
281
- * {@link is}. Parameters are not checked. Returns `null` on mismatch.
282
- *
283
- * Related functions:
284
- *
285
- * - {@link isFunction} — Also tests parameters
286
- * - {@link isParameters} — Tests parameters only
287
- * - {@link assertReturn} — Throws with error details
288
- * - {@link validateReturn} — Returns all error details
289
- * - {@link equalsReturn} — Also rejects extra properties
290
- *
291
- * @template T Target function type
292
- * @param func Function to wrap
293
- * @returns Wrapped function returning `Output | null`
294
- */
295
- export function isReturn<T extends (...args: any[]) => any>(
296
- func: T,
297
- ): T extends (...args: infer Arguments) => infer Output
298
- ? Output extends Promise<infer R>
299
- ? (...args: Arguments) => Promise<R | null>
300
- : (...args: Arguments) => Output | null
301
- : never;
302
-
303
- /** @internal */
304
- export function isReturn(): never {
305
- NoTransformConfigurationError("functional.isReturn");
306
- }
307
-
308
- /**
309
- * Wraps function to test parameters and return value with strict equality.
310
- *
311
- * Wraps the target function and checks through {@link equals}. Also rejects
312
- * extra properties not defined in type. Returns `null` on mismatch.
313
- *
314
- * Related functions:
315
- *
316
- * - {@link isFunction} — Allows extra properties
317
- * - {@link equalsParameters} — Tests parameters only
318
- * - {@link equalsReturn} — Tests return value only
319
- * - {@link assertEqualsFunction} — Throws with error details
320
- * - {@link validateEqualsFunction} — Returns all error details
321
- *
322
- * @template T Target function type
323
- * @param func Function to wrap
324
- * @returns Wrapped function returning `Output | null`
325
- */
326
- export function equalsFunction<T extends (...args: any[]) => any>(
327
- func: T,
328
- ): T extends (...args: infer Arguments) => infer Output
329
- ? Output extends Promise<infer R>
330
- ? (...args: Arguments) => Promise<R | null>
331
- : (...args: Arguments) => Output | null
332
- : never;
333
-
334
- /** @internal */
335
- export function equalsFunction(): never {
336
- NoTransformConfigurationError("functional.equalsFunction");
337
- }
338
-
339
- /**
340
- * Wraps function to test parameters with strict equality.
341
- *
342
- * Wraps the target function and checks parameters through {@link equals}. Also
343
- * rejects extra properties. Return value is not checked.
344
- *
345
- * Related functions:
346
- *
347
- * - {@link isParameters} — Allows extra properties
348
- * - {@link equalsFunction} — Also tests return value
349
- * - {@link equalsReturn} — Tests return value only
350
- * - {@link assertEqualsParameters} — Throws with error details
351
- * - {@link validateEqualsParameters} — Returns all error details
352
- *
353
- * @template T Target function type
354
- * @param func Function to wrap
355
- * @returns Wrapped function returning `Output | null`
356
- */
357
- export function equalsParameters<T extends (...args: any[]) => any>(
358
- func: T,
359
- ): T extends (...args: infer Arguments) => infer Output
360
- ? Output extends Promise<infer R>
361
- ? (...args: Arguments) => Promise<R | null>
362
- : (...args: Arguments) => Output | null
363
- : never;
364
-
365
- /** @internal */
366
- export function equalsParameters(): never {
367
- NoTransformConfigurationError("functional.equalsParameters");
368
- }
369
-
370
- /**
371
- * Wraps function to test return value with strict equality.
372
- *
373
- * Wraps the target function and checks return value through {@link equals}. Also
374
- * rejects extra properties. Parameters are not checked.
375
- *
376
- * Related functions:
377
- *
378
- * - {@link isReturn} — Allows extra properties
379
- * - {@link equalsFunction} — Also tests parameters
380
- * - {@link equalsParameters} — Tests parameters only
381
- * - {@link assertEqualsReturn} — Throws with error details
382
- * - {@link validateEqualsReturn} — Returns all error details
383
- *
384
- * @template T Target function type
385
- * @param func Function to wrap
386
- * @returns Wrapped function returning `Output | null`
387
- */
388
- export function equalsReturn<T extends (...args: any[]) => any>(
389
- func: T,
390
- ): T extends (...args: infer Arguments) => infer Output
391
- ? Output extends Promise<infer R>
392
- ? (...args: Arguments) => Promise<R | null>
393
- : (...args: Arguments) => Output | null
394
- : never;
395
-
396
- /** @internal */
397
- export function equalsReturn(): never {
398
- NoTransformConfigurationError("functional.equalsReturn");
399
- }
400
-
401
- /* -----------------------------------------------------------
402
- VALIDATE
403
- ----------------------------------------------------------- */
404
- /**
405
- * Wraps function to validate both parameters and return value.
406
- *
407
- * Wraps the target function and validates all parameters before calling and
408
- * return value after calling through {@link validate}. Collects all errors.
409
- *
410
- * Error path format:
411
- *
412
- * - Parameter errors: `$input.parameters[0].property`
413
- * - Return errors: `$input.return.property`
414
- *
415
- * Related functions:
416
- *
417
- * - {@link validateParameters} — Validates parameters only
418
- * - {@link validateReturn} — Validates return value only
419
- * - {@link assertFunction} — Throws on first error
420
- * - {@link validateEqualsFunction} — Also rejects extra properties
421
- *
422
- * @template T Target function type
423
- * @param func Function to wrap
424
- * @returns Wrapped function returning {@link IValidation}
425
- */
426
- export function validateFunction<T extends (...args: any[]) => any>(
427
- func: T,
428
- ): T extends (...args: infer Arguments) => infer Output
429
- ? Output extends Promise<infer R>
430
- ? (...args: Arguments) => Promise<IValidation<R>>
431
- : (...args: Arguments) => IValidation<Output>
432
- : never;
433
-
434
- /** @internal */
435
- export function validateFunction(): never {
436
- NoTransformConfigurationError("functional.validateFunction");
437
- }
438
-
439
- /**
440
- * Wraps function to validate parameters only.
441
- *
442
- * Wraps the target function and validates all parameters before calling through
443
- * {@link validate}. Return value is not validated. Collects all errors.
444
- *
445
- * Error path format: `$input.parameters[0].property`
446
- *
447
- * Related functions:
448
- *
449
- * - {@link validateFunction} — Also validates return value
450
- * - {@link validateReturn} — Validates return value only
451
- * - {@link assertParameters} — Throws on first error
452
- * - {@link validateEqualsParameters} — Also rejects extra properties
453
- *
454
- * @template T Target function type
455
- * @param func Function to wrap
456
- * @returns Wrapped function returning {@link IValidation}
457
- */
458
- export function validateParameters<T extends (...args: any[]) => any>(
459
- func: T,
460
- ): T extends (...args: infer Arguments) => infer Output
461
- ? Output extends Promise<infer R>
462
- ? (...args: Arguments) => Promise<IValidation<R>>
463
- : (...args: Arguments) => IValidation<Output>
464
- : never;
465
-
466
- /** @internal */
467
- export function validateParameters(): never {
468
- NoTransformConfigurationError("functional.validateParameters");
469
- }
470
-
471
- /**
472
- * Wraps function to validate return value only.
473
- *
474
- * Wraps the target function and validates return value after calling through
475
- * {@link validate}. Parameters are not validated. Collects all errors.
476
- *
477
- * Error path format: `$input.return.property`
478
- *
479
- * Related functions:
480
- *
481
- * - {@link validateFunction} — Also validates parameters
482
- * - {@link validateParameters} — Validates parameters only
483
- * - {@link assertReturn} — Throws on first error
484
- * - {@link validateEqualsReturn} — Also rejects extra properties
485
- *
486
- * @template T Target function type
487
- * @param func Function to wrap
488
- * @returns Wrapped function returning {@link IValidation}
489
- */
490
- export function validateReturn<T extends (...args: any[]) => any>(
491
- func: T,
492
- ): T extends (...args: infer Arguments) => infer Output
493
- ? Output extends Promise<infer R>
494
- ? (...args: Arguments) => Promise<IValidation<R>>
495
- : (...args: Arguments) => IValidation<Output>
496
- : never;
497
-
498
- /** @internal */
499
- export function validateReturn(): never {
500
- NoTransformConfigurationError("functional.validateReturn");
501
- }
502
-
503
- /**
504
- * Wraps function to validate parameters and return value with strict equality.
505
- *
506
- * Wraps the target function and validates through {@link validateEquals}. Also
507
- * rejects extra properties not defined in type. Collects all errors.
508
- *
509
- * Error path format:
510
- *
511
- * - Parameter errors: `$input.parameters[0].property`
512
- * - Return errors: `$input.return.property`
513
- *
514
- * Related functions:
515
- *
516
- * - {@link validateFunction} — Allows extra properties
517
- * - {@link validateEqualsParameters} — Validates parameters only
518
- * - {@link validateEqualsReturn} — Validates return value only
519
- * - {@link assertEqualsFunction} — Throws on first error
520
- *
521
- * @template T Target function type
522
- * @param func Function to wrap
523
- * @returns Wrapped function returning {@link IValidation}
524
- */
525
- export function validateEqualsFunction<T extends (...args: any[]) => any>(
526
- func: T,
527
- ): T extends (...args: infer Arguments) => infer Output
528
- ? Output extends Promise<infer R>
529
- ? (...args: Arguments) => Promise<IValidation<R>>
530
- : (...args: Arguments) => IValidation<Output>
531
- : never;
532
-
533
- /** @internal */
534
- export function validateEqualsFunction(): never {
535
- NoTransformConfigurationError("functional.validateEqualsFunction");
536
- }
537
-
538
- /**
539
- * Wraps function to validate parameters with strict equality.
540
- *
541
- * Wraps the target function and validates parameters through
542
- * {@link validateEquals}. Also rejects extra properties. Return value is not
543
- * validated.
544
- *
545
- * Error path format: `$input.parameters[0].property`
546
- *
547
- * Related functions:
548
- *
549
- * - {@link validateParameters} — Allows extra properties
550
- * - {@link validateEqualsFunction} — Also validates return value
551
- * - {@link assertEqualsParameters} — Throws on first error
552
- *
553
- * @template T Target function type
554
- * @param func Function to wrap
555
- * @returns Wrapped function returning {@link IValidation}
556
- */
557
- export function validateEqualsParameters<T extends (...args: any[]) => any>(
558
- func: T,
559
- ): T extends (...args: infer Arguments) => infer Output
560
- ? Output extends Promise<infer R>
561
- ? (...args: Arguments) => Promise<IValidation<R>>
562
- : (...args: Arguments) => IValidation<Output>
563
- : never;
564
-
565
- /** @internal */
566
- export function validateEqualsParameters(): never {
567
- NoTransformConfigurationError("functional.validateEqualsParameters");
568
- }
569
-
570
- /**
571
- * Wraps function to validate return value with strict equality.
572
- *
573
- * Wraps the target function and validates return value through
574
- * {@link validateEquals}. Also rejects extra properties. Parameters are not
575
- * validated.
576
- *
577
- * Error path format: `$input.return.property`
578
- *
579
- * Related functions:
580
- *
581
- * - {@link validateReturn} — Allows extra properties
582
- * - {@link validateEqualsFunction} — Also validates parameters
583
- * - {@link assertEqualsReturn} — Throws on first error
584
- *
585
- * @template T Target function type
586
- * @param func Function to wrap
587
- * @returns Wrapped function returning {@link IValidation}
588
- */
589
- export function validateEqualsReturn<T extends (...args: any[]) => any>(
590
- func: T,
591
- ): T extends (...args: infer Arguments) => infer Output
592
- ? Output extends Promise<infer R>
593
- ? (...args: Arguments) => Promise<IValidation<R>>
594
- : (...args: Arguments) => IValidation<Output>
595
- : never;
596
-
597
- /** @internal */
598
- export function validateEqualsReturn(): never {
599
- NoTransformConfigurationError("functional.validateEqualsReturn");
600
- }
1
+ import { IValidation } from "@typia/interface";
2
+
3
+ import { TypeGuardError } from "./TypeGuardError";
4
+ import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
5
+
6
+ /* ===========================================================
7
+ FUNCTIONAL
8
+ - ASSERT
9
+ - IS
10
+ - VALIDATE
11
+ ==============================================================
12
+ ASSERT
13
+ ----------------------------------------------------------- */
14
+ /**
15
+ * Wraps function to assert both parameters and return value.
16
+ *
17
+ * Wraps the target function and validates all parameters before calling and
18
+ * return value after calling through {@link assert}. Throws on first mismatch.
19
+ *
20
+ * Error path format:
21
+ *
22
+ * - Parameter errors: `$input.parameters[0].property`
23
+ * - Return errors: `$input.return.property`
24
+ *
25
+ * Related functions:
26
+ *
27
+ * - {@link assertParameters} — Validates parameters only
28
+ * - {@link assertReturn} — Validates return value only
29
+ * - {@link validateFunction} — Collects all errors instead of throwing
30
+ * - {@link assertEqualsFunction} — Also rejects extra properties
31
+ *
32
+ * @template T Target function type
33
+ * @param func Function to wrap
34
+ * @param errorFactory Custom error factory receiving
35
+ * {@link TypeGuardError.IProps}
36
+ * @returns Wrapped function with same signature
37
+ * @throws {TypeGuardError} When parameter or return value type mismatch
38
+ */
39
+ export function assertFunction<T extends (...args: any[]) => any>(
40
+ func: T,
41
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
42
+ ): T;
43
+
44
+ /** @internal */
45
+ export function assertFunction(): never {
46
+ NoTransformConfigurationError("functional.assertFunction");
47
+ }
48
+
49
+ /**
50
+ * Wraps function to assert parameters only.
51
+ *
52
+ * Wraps the target function and validates all parameters before calling through
53
+ * {@link assert}. Return value is not validated. Throws on first mismatch.
54
+ *
55
+ * Error path format: `$input.parameters[0].property`
56
+ *
57
+ * Related functions:
58
+ *
59
+ * - {@link assertFunction} — Also validates return value
60
+ * - {@link assertReturn} — Validates return value only
61
+ * - {@link validateParameters} — Collects all errors instead of throwing
62
+ * - {@link assertEqualsParameters} — Also rejects extra properties
63
+ *
64
+ * @template T Target function type
65
+ * @param func Function to wrap
66
+ * @param errorFactory Custom error factory receiving
67
+ * {@link TypeGuardError.IProps}
68
+ * @returns Wrapped function with same signature
69
+ * @throws {TypeGuardError} When parameter type mismatch
70
+ */
71
+ export function assertParameters<T extends (...args: any[]) => any>(
72
+ func: T,
73
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
74
+ ): T;
75
+
76
+ /** @internal */
77
+ export function assertParameters(): never {
78
+ NoTransformConfigurationError("functional.assertParameters");
79
+ }
80
+
81
+ /**
82
+ * Wraps function to assert return value only.
83
+ *
84
+ * Wraps the target function and validates return value after calling through
85
+ * {@link assert}. Parameters are not validated. Throws on mismatch.
86
+ *
87
+ * Error path format: `$input.return.property`
88
+ *
89
+ * Related functions:
90
+ *
91
+ * - {@link assertFunction} — Also validates parameters
92
+ * - {@link assertParameters} — Validates parameters only
93
+ * - {@link validateReturn} — Collects all errors instead of throwing
94
+ * - {@link assertEqualsReturn} — Also rejects extra properties
95
+ *
96
+ * @template T Target function type
97
+ * @param func Function to wrap
98
+ * @param errorFactory Custom error factory receiving
99
+ * {@link TypeGuardError.IProps}
100
+ * @returns Wrapped function with same signature
101
+ * @throws {TypeGuardError} When return value type mismatch
102
+ */
103
+ export function assertReturn<T extends (...args: any[]) => any>(
104
+ func: T,
105
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
106
+ ): T;
107
+
108
+ /** @internal */
109
+ export function assertReturn(): never {
110
+ NoTransformConfigurationError("functional.assertReturn");
111
+ }
112
+
113
+ /**
114
+ * Wraps function to assert parameters and return value with strict equality.
115
+ *
116
+ * Wraps the target function and validates through {@link assertEquals}. Also
117
+ * rejects extra properties not defined in type. Throws on first mismatch.
118
+ *
119
+ * Error path format:
120
+ *
121
+ * - Parameter errors: `$input.parameters[0].property`
122
+ * - Return errors: `$input.return.property`
123
+ *
124
+ * Related functions:
125
+ *
126
+ * - {@link assertFunction} — Allows extra properties
127
+ * - {@link assertEqualsParameters} — Validates parameters only
128
+ * - {@link assertEqualsReturn} — Validates return value only
129
+ * - {@link validateEqualsFunction} — Collects all errors instead of throwing
130
+ *
131
+ * @template T Target function type
132
+ * @param func Function to wrap
133
+ * @param errorFactory Custom error factory receiving
134
+ * {@link TypeGuardError.IProps}
135
+ * @returns Wrapped function with same signature
136
+ * @throws {TypeGuardError} When type mismatch or extra property detected
137
+ */
138
+ export function assertEqualsFunction<T extends (...args: any[]) => any>(
139
+ func: T,
140
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
141
+ ): T;
142
+
143
+ /** @internal */
144
+ export function assertEqualsFunction(): never {
145
+ NoTransformConfigurationError("functional.assertEqualsFunction");
146
+ }
147
+
148
+ /**
149
+ * Wraps function to assert parameters with strict equality.
150
+ *
151
+ * Wraps the target function and validates parameters through
152
+ * {@link assertEquals}. Also rejects extra properties. Return value is not
153
+ * validated.
154
+ *
155
+ * Error path format: `$input.parameters[0].property`
156
+ *
157
+ * Related functions:
158
+ *
159
+ * - {@link assertParameters} — Allows extra properties
160
+ * - {@link assertEqualsFunction} — Also validates return value
161
+ * - {@link validateEqualsParameters} — Collects all errors instead of throwing
162
+ *
163
+ * @template T Target function type
164
+ * @param func Function to wrap
165
+ * @param errorFactory Custom error factory receiving
166
+ * {@link TypeGuardError.IProps}
167
+ * @returns Wrapped function with same signature
168
+ * @throws {TypeGuardError} When type mismatch or extra property detected
169
+ */
170
+ export function assertEqualsParameters<T extends (...args: any[]) => any>(
171
+ func: T,
172
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
173
+ ): T;
174
+
175
+ /** @internal */
176
+ export function assertEqualsParameters(): never {
177
+ NoTransformConfigurationError("functional.assertEqualsParameters");
178
+ }
179
+
180
+ /**
181
+ * Wraps function to assert return value with strict equality.
182
+ *
183
+ * Wraps the target function and validates return value through
184
+ * {@link assertEquals}. Also rejects extra properties. Parameters are not
185
+ * validated.
186
+ *
187
+ * Error path format: `$input.return.property`
188
+ *
189
+ * Related functions:
190
+ *
191
+ * - {@link assertReturn} — Allows extra properties
192
+ * - {@link assertEqualsFunction} — Also validates parameters
193
+ * - {@link validateEqualsReturn} — Collects all errors instead of throwing
194
+ *
195
+ * @template T Target function type
196
+ * @param func Function to wrap
197
+ * @param errorFactory Custom error factory receiving
198
+ * {@link TypeGuardError.IProps}
199
+ * @returns Wrapped function with same signature
200
+ * @throws {TypeGuardError} When type mismatch or extra property detected
201
+ */
202
+ export function assertEqualsReturn<T extends (...args: any[]) => any>(
203
+ func: T,
204
+ errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
205
+ ): T;
206
+
207
+ /** @internal */
208
+ export function assertEqualsReturn(): never {
209
+ NoTransformConfigurationError("functional.assertEqualsReturn");
210
+ }
211
+
212
+ /* -----------------------------------------------------------
213
+ IS
214
+ ----------------------------------------------------------- */
215
+ /**
216
+ * Wraps function to test both parameters and return value.
217
+ *
218
+ * Wraps the target function and checks all parameters before calling and return
219
+ * value after calling through {@link is}. Returns `null` on mismatch.
220
+ *
221
+ * Related functions:
222
+ *
223
+ * - {@link isParameters} — Tests parameters only
224
+ * - {@link isReturn} — Tests return value only
225
+ * - {@link assertFunction} — Throws with error details on mismatch
226
+ * - {@link validateFunction} — Returns all error details
227
+ * - {@link equalsFunction} — Also rejects extra properties
228
+ *
229
+ * @template T Target function type
230
+ * @param func Function to wrap
231
+ * @returns Wrapped function returning `Output | null`
232
+ */
233
+ export function isFunction<T extends (...args: any[]) => any>(
234
+ func: T,
235
+ ): T extends (...args: infer Arguments) => infer Output
236
+ ? Output extends Promise<infer R>
237
+ ? (...args: Arguments) => Promise<R | null>
238
+ : (...args: Arguments) => Output | null
239
+ : never;
240
+
241
+ /** @internal */
242
+ export function isFunction(): never {
243
+ NoTransformConfigurationError("functional.isFunction");
244
+ }
245
+
246
+ /**
247
+ * Wraps function to test parameters only.
248
+ *
249
+ * Wraps the target function and checks all parameters before calling through
250
+ * {@link is}. Return value is not checked. Returns `null` on mismatch.
251
+ *
252
+ * Related functions:
253
+ *
254
+ * - {@link isFunction} — Also tests return value
255
+ * - {@link isReturn} — Tests return value only
256
+ * - {@link assertParameters} — Throws with error details
257
+ * - {@link validateParameters} — Returns all error details
258
+ * - {@link equalsParameters} — Also rejects extra properties
259
+ *
260
+ * @template T Target function type
261
+ * @param func Function to wrap
262
+ * @returns Wrapped function returning `Output | null`
263
+ */
264
+ export function isParameters<T extends (...args: any[]) => any>(
265
+ func: T,
266
+ ): T extends (...args: infer Arguments) => infer Output
267
+ ? Output extends Promise<infer R>
268
+ ? (...args: Arguments) => Promise<R | null>
269
+ : (...args: Arguments) => Output | null
270
+ : never;
271
+
272
+ /** @internal */
273
+ export function isParameters(): never {
274
+ NoTransformConfigurationError("functional.isParameters");
275
+ }
276
+
277
+ /**
278
+ * Wraps function to test return value only.
279
+ *
280
+ * Wraps the target function and checks return value after calling through
281
+ * {@link is}. Parameters are not checked. Returns `null` on mismatch.
282
+ *
283
+ * Related functions:
284
+ *
285
+ * - {@link isFunction} — Also tests parameters
286
+ * - {@link isParameters} — Tests parameters only
287
+ * - {@link assertReturn} — Throws with error details
288
+ * - {@link validateReturn} — Returns all error details
289
+ * - {@link equalsReturn} — Also rejects extra properties
290
+ *
291
+ * @template T Target function type
292
+ * @param func Function to wrap
293
+ * @returns Wrapped function returning `Output | null`
294
+ */
295
+ export function isReturn<T extends (...args: any[]) => any>(
296
+ func: T,
297
+ ): T extends (...args: infer Arguments) => infer Output
298
+ ? Output extends Promise<infer R>
299
+ ? (...args: Arguments) => Promise<R | null>
300
+ : (...args: Arguments) => Output | null
301
+ : never;
302
+
303
+ /** @internal */
304
+ export function isReturn(): never {
305
+ NoTransformConfigurationError("functional.isReturn");
306
+ }
307
+
308
+ /**
309
+ * Wraps function to test parameters and return value with strict equality.
310
+ *
311
+ * Wraps the target function and checks through {@link equals}. Also rejects
312
+ * extra properties not defined in type. Returns `null` on mismatch.
313
+ *
314
+ * Related functions:
315
+ *
316
+ * - {@link isFunction} — Allows extra properties
317
+ * - {@link equalsParameters} — Tests parameters only
318
+ * - {@link equalsReturn} — Tests return value only
319
+ * - {@link assertEqualsFunction} — Throws with error details
320
+ * - {@link validateEqualsFunction} — Returns all error details
321
+ *
322
+ * @template T Target function type
323
+ * @param func Function to wrap
324
+ * @returns Wrapped function returning `Output | null`
325
+ */
326
+ export function equalsFunction<T extends (...args: any[]) => any>(
327
+ func: T,
328
+ ): T extends (...args: infer Arguments) => infer Output
329
+ ? Output extends Promise<infer R>
330
+ ? (...args: Arguments) => Promise<R | null>
331
+ : (...args: Arguments) => Output | null
332
+ : never;
333
+
334
+ /** @internal */
335
+ export function equalsFunction(): never {
336
+ NoTransformConfigurationError("functional.equalsFunction");
337
+ }
338
+
339
+ /**
340
+ * Wraps function to test parameters with strict equality.
341
+ *
342
+ * Wraps the target function and checks parameters through {@link equals}. Also
343
+ * rejects extra properties. Return value is not checked.
344
+ *
345
+ * Related functions:
346
+ *
347
+ * - {@link isParameters} — Allows extra properties
348
+ * - {@link equalsFunction} — Also tests return value
349
+ * - {@link equalsReturn} — Tests return value only
350
+ * - {@link assertEqualsParameters} — Throws with error details
351
+ * - {@link validateEqualsParameters} — Returns all error details
352
+ *
353
+ * @template T Target function type
354
+ * @param func Function to wrap
355
+ * @returns Wrapped function returning `Output | null`
356
+ */
357
+ export function equalsParameters<T extends (...args: any[]) => any>(
358
+ func: T,
359
+ ): T extends (...args: infer Arguments) => infer Output
360
+ ? Output extends Promise<infer R>
361
+ ? (...args: Arguments) => Promise<R | null>
362
+ : (...args: Arguments) => Output | null
363
+ : never;
364
+
365
+ /** @internal */
366
+ export function equalsParameters(): never {
367
+ NoTransformConfigurationError("functional.equalsParameters");
368
+ }
369
+
370
+ /**
371
+ * Wraps function to test return value with strict equality.
372
+ *
373
+ * Wraps the target function and checks return value through {@link equals}. Also
374
+ * rejects extra properties. Parameters are not checked.
375
+ *
376
+ * Related functions:
377
+ *
378
+ * - {@link isReturn} — Allows extra properties
379
+ * - {@link equalsFunction} — Also tests parameters
380
+ * - {@link equalsParameters} — Tests parameters only
381
+ * - {@link assertEqualsReturn} — Throws with error details
382
+ * - {@link validateEqualsReturn} — Returns all error details
383
+ *
384
+ * @template T Target function type
385
+ * @param func Function to wrap
386
+ * @returns Wrapped function returning `Output | null`
387
+ */
388
+ export function equalsReturn<T extends (...args: any[]) => any>(
389
+ func: T,
390
+ ): T extends (...args: infer Arguments) => infer Output
391
+ ? Output extends Promise<infer R>
392
+ ? (...args: Arguments) => Promise<R | null>
393
+ : (...args: Arguments) => Output | null
394
+ : never;
395
+
396
+ /** @internal */
397
+ export function equalsReturn(): never {
398
+ NoTransformConfigurationError("functional.equalsReturn");
399
+ }
400
+
401
+ /* -----------------------------------------------------------
402
+ VALIDATE
403
+ ----------------------------------------------------------- */
404
+ /**
405
+ * Wraps function to validate both parameters and return value.
406
+ *
407
+ * Wraps the target function and validates all parameters before calling and
408
+ * return value after calling through {@link validate}. Collects all errors.
409
+ *
410
+ * Error path format:
411
+ *
412
+ * - Parameter errors: `$input.parameters[0].property`
413
+ * - Return errors: `$input.return.property`
414
+ *
415
+ * Related functions:
416
+ *
417
+ * - {@link validateParameters} — Validates parameters only
418
+ * - {@link validateReturn} — Validates return value only
419
+ * - {@link assertFunction} — Throws on first error
420
+ * - {@link validateEqualsFunction} — Also rejects extra properties
421
+ *
422
+ * @template T Target function type
423
+ * @param func Function to wrap
424
+ * @returns Wrapped function returning {@link IValidation}
425
+ */
426
+ export function validateFunction<T extends (...args: any[]) => any>(
427
+ func: T,
428
+ ): T extends (...args: infer Arguments) => infer Output
429
+ ? Output extends Promise<infer R>
430
+ ? (...args: Arguments) => Promise<IValidation<R>>
431
+ : (...args: Arguments) => IValidation<Output>
432
+ : never;
433
+
434
+ /** @internal */
435
+ export function validateFunction(): never {
436
+ NoTransformConfigurationError("functional.validateFunction");
437
+ }
438
+
439
+ /**
440
+ * Wraps function to validate parameters only.
441
+ *
442
+ * Wraps the target function and validates all parameters before calling through
443
+ * {@link validate}. Return value is not validated. Collects all errors.
444
+ *
445
+ * Error path format: `$input.parameters[0].property`
446
+ *
447
+ * Related functions:
448
+ *
449
+ * - {@link validateFunction} — Also validates return value
450
+ * - {@link validateReturn} — Validates return value only
451
+ * - {@link assertParameters} — Throws on first error
452
+ * - {@link validateEqualsParameters} — Also rejects extra properties
453
+ *
454
+ * @template T Target function type
455
+ * @param func Function to wrap
456
+ * @returns Wrapped function returning {@link IValidation}
457
+ */
458
+ export function validateParameters<T extends (...args: any[]) => any>(
459
+ func: T,
460
+ ): T extends (...args: infer Arguments) => infer Output
461
+ ? Output extends Promise<infer R>
462
+ ? (...args: Arguments) => Promise<IValidation<R>>
463
+ : (...args: Arguments) => IValidation<Output>
464
+ : never;
465
+
466
+ /** @internal */
467
+ export function validateParameters(): never {
468
+ NoTransformConfigurationError("functional.validateParameters");
469
+ }
470
+
471
+ /**
472
+ * Wraps function to validate return value only.
473
+ *
474
+ * Wraps the target function and validates return value after calling through
475
+ * {@link validate}. Parameters are not validated. Collects all errors.
476
+ *
477
+ * Error path format: `$input.return.property`
478
+ *
479
+ * Related functions:
480
+ *
481
+ * - {@link validateFunction} — Also validates parameters
482
+ * - {@link validateParameters} — Validates parameters only
483
+ * - {@link assertReturn} — Throws on first error
484
+ * - {@link validateEqualsReturn} — Also rejects extra properties
485
+ *
486
+ * @template T Target function type
487
+ * @param func Function to wrap
488
+ * @returns Wrapped function returning {@link IValidation}
489
+ */
490
+ export function validateReturn<T extends (...args: any[]) => any>(
491
+ func: T,
492
+ ): T extends (...args: infer Arguments) => infer Output
493
+ ? Output extends Promise<infer R>
494
+ ? (...args: Arguments) => Promise<IValidation<R>>
495
+ : (...args: Arguments) => IValidation<Output>
496
+ : never;
497
+
498
+ /** @internal */
499
+ export function validateReturn(): never {
500
+ NoTransformConfigurationError("functional.validateReturn");
501
+ }
502
+
503
+ /**
504
+ * Wraps function to validate parameters and return value with strict equality.
505
+ *
506
+ * Wraps the target function and validates through {@link validateEquals}. Also
507
+ * rejects extra properties not defined in type. Collects all errors.
508
+ *
509
+ * Error path format:
510
+ *
511
+ * - Parameter errors: `$input.parameters[0].property`
512
+ * - Return errors: `$input.return.property`
513
+ *
514
+ * Related functions:
515
+ *
516
+ * - {@link validateFunction} — Allows extra properties
517
+ * - {@link validateEqualsParameters} — Validates parameters only
518
+ * - {@link validateEqualsReturn} — Validates return value only
519
+ * - {@link assertEqualsFunction} — Throws on first error
520
+ *
521
+ * @template T Target function type
522
+ * @param func Function to wrap
523
+ * @returns Wrapped function returning {@link IValidation}
524
+ */
525
+ export function validateEqualsFunction<T extends (...args: any[]) => any>(
526
+ func: T,
527
+ ): T extends (...args: infer Arguments) => infer Output
528
+ ? Output extends Promise<infer R>
529
+ ? (...args: Arguments) => Promise<IValidation<R>>
530
+ : (...args: Arguments) => IValidation<Output>
531
+ : never;
532
+
533
+ /** @internal */
534
+ export function validateEqualsFunction(): never {
535
+ NoTransformConfigurationError("functional.validateEqualsFunction");
536
+ }
537
+
538
+ /**
539
+ * Wraps function to validate parameters with strict equality.
540
+ *
541
+ * Wraps the target function and validates parameters through
542
+ * {@link validateEquals}. Also rejects extra properties. Return value is not
543
+ * validated.
544
+ *
545
+ * Error path format: `$input.parameters[0].property`
546
+ *
547
+ * Related functions:
548
+ *
549
+ * - {@link validateParameters} — Allows extra properties
550
+ * - {@link validateEqualsFunction} — Also validates return value
551
+ * - {@link assertEqualsParameters} — Throws on first error
552
+ *
553
+ * @template T Target function type
554
+ * @param func Function to wrap
555
+ * @returns Wrapped function returning {@link IValidation}
556
+ */
557
+ export function validateEqualsParameters<T extends (...args: any[]) => any>(
558
+ func: T,
559
+ ): T extends (...args: infer Arguments) => infer Output
560
+ ? Output extends Promise<infer R>
561
+ ? (...args: Arguments) => Promise<IValidation<R>>
562
+ : (...args: Arguments) => IValidation<Output>
563
+ : never;
564
+
565
+ /** @internal */
566
+ export function validateEqualsParameters(): never {
567
+ NoTransformConfigurationError("functional.validateEqualsParameters");
568
+ }
569
+
570
+ /**
571
+ * Wraps function to validate return value with strict equality.
572
+ *
573
+ * Wraps the target function and validates return value through
574
+ * {@link validateEquals}. Also rejects extra properties. Parameters are not
575
+ * validated.
576
+ *
577
+ * Error path format: `$input.return.property`
578
+ *
579
+ * Related functions:
580
+ *
581
+ * - {@link validateReturn} — Allows extra properties
582
+ * - {@link validateEqualsFunction} — Also validates parameters
583
+ * - {@link assertEqualsReturn} — Throws on first error
584
+ *
585
+ * @template T Target function type
586
+ * @param func Function to wrap
587
+ * @returns Wrapped function returning {@link IValidation}
588
+ */
589
+ export function validateEqualsReturn<T extends (...args: any[]) => any>(
590
+ func: T,
591
+ ): T extends (...args: infer Arguments) => infer Output
592
+ ? Output extends Promise<infer R>
593
+ ? (...args: Arguments) => Promise<IValidation<R>>
594
+ : (...args: Arguments) => IValidation<Output>
595
+ : never;
596
+
597
+ /** @internal */
598
+ export function validateEqualsReturn(): never {
599
+ NoTransformConfigurationError("functional.validateEqualsReturn");
600
+ }