typia 5.5.0-dev.20240304 → 5.5.0-dev.20240306
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.
- package/lib/functional.d.ts +329 -0
- package/lib/functional.js +99 -234
- package/lib/functional.js.map +1 -1
- package/lib/http.d.ts +15 -6
- package/lib/http.js.map +1 -1
- package/lib/json.d.ts +17 -8
- package/lib/json.js.map +1 -1
- package/lib/misc.d.ts +18 -8
- package/lib/misc.js.map +1 -1
- package/lib/module.d.ts +17 -0
- package/lib/module.js.map +1 -1
- package/lib/notations.d.ts +12 -0
- package/lib/notations.js.map +1 -1
- package/lib/programmers/AssertProgrammer.d.ts +1 -0
- package/lib/programmers/AssertProgrammer.js +5 -2
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +3 -1
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/TypiaProgrammer.js +1 -8
- package/lib/programmers/TypiaProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.d.ts +8 -2
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js +22 -16
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.d.ts +1 -1
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js +8 -4
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.d.ts +1 -1
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js +8 -7
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalIsFunctionProgrammer.d.ts +6 -0
- package/lib/programmers/functional/FunctionalIsFunctionProgrammer.js +54 -0
- package/lib/programmers/functional/FunctionalIsFunctionProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalIsParametersProgrammer.d.ts +7 -0
- package/lib/programmers/functional/FunctionalIsParametersProgrammer.js +79 -0
- package/lib/programmers/functional/FunctionalIsParametersProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalIsReturnProgrammer.d.ts +10 -0
- package/lib/programmers/functional/FunctionalIsReturnProgrammer.js +71 -0
- package/lib/programmers/functional/FunctionalIsReturnProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.d.ts +10 -0
- package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.js +61 -0
- package/lib/programmers/functional/FunctionalValidateFunctionProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalValidateParametersProgrammer.d.ts +7 -0
- package/lib/programmers/functional/FunctionalValidateParametersProgrammer.js +104 -0
- package/lib/programmers/functional/FunctionalValidateParametersProgrammer.js.map +1 -0
- package/lib/programmers/functional/FunctionalValidateReturnProgrammer.d.ts +10 -0
- package/lib/programmers/functional/FunctionalValidateReturnProgrammer.js +74 -0
- package/lib/programmers/functional/FunctionalValidateReturnProgrammer.js.map +1 -0
- package/lib/programmers/http/HttpAssertFormDataProgrammer.js +3 -1
- package/lib/programmers/http/HttpAssertFormDataProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertHeadersProgrammer.js +3 -1
- package/lib/programmers/http/HttpAssertHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpAssertQueryProgrammer.js +3 -1
- package/lib/programmers/http/HttpAssertQueryProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpFormDataProgrammer.js +3 -1
- package/lib/programmers/http/HttpFormDataProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js +3 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpIsFormDataProgrammer.js +3 -1
- package/lib/programmers/http/HttpIsFormDataProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpIsHeadersProgrammer.js +3 -1
- package/lib/programmers/http/HttpIsHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpIsQueryProgrammer.js +3 -1
- package/lib/programmers/http/HttpIsQueryProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpQueryProgrammer.js +3 -1
- package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js +3 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonIsParseProgrammer.js +3 -1
- package/lib/programmers/json/JsonIsParseProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js +3 -1
- package/lib/programmers/misc/MiscAssertCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +3 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscIsCloneProgrammer.js +3 -1
- package/lib/programmers/misc/MiscIsCloneProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js +3 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +3 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js +3 -1
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +1 -1
- package/lib/protobuf.d.ts +8 -0
- package/lib/protobuf.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +104 -12
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/utils/StringUtil/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil/StringUtil.js +7 -1
- package/lib/utils/StringUtil/StringUtil.js.map +1 -1
- package/package.json +2 -1
- package/src/functional.ts +542 -246
- package/src/http.ts +15 -6
- package/src/json.ts +17 -8
- package/src/misc.ts +18 -8
- package/src/module.ts +17 -0
- package/src/notations.ts +12 -0
- package/src/programmers/AssertProgrammer.ts +24 -22
- package/src/programmers/RandomProgrammer.ts +12 -4
- package/src/programmers/TypiaProgrammer.ts +1 -11
- package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +64 -55
- package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +13 -5
- package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +10 -8
- package/src/programmers/functional/FunctionalIsFunctionProgrammer.ts +45 -0
- package/src/programmers/functional/FunctionalIsParametersProgrammer.ts +78 -0
- package/src/programmers/functional/FunctionalIsReturnProgrammer.ts +91 -0
- package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +91 -0
- package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +212 -0
- package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +115 -0
- package/src/programmers/http/HttpAssertFormDataProgrammer.ts +12 -4
- package/src/programmers/http/HttpAssertHeadersProgrammer.ts +12 -4
- package/src/programmers/http/HttpAssertQueryProgrammer.ts +12 -4
- package/src/programmers/http/HttpFormDataProgrammer.ts +12 -4
- package/src/programmers/http/HttpHeadersProgrammer.ts +12 -4
- package/src/programmers/http/HttpIsFormDataProgrammer.ts +12 -4
- package/src/programmers/http/HttpIsHeadersProgrammer.ts +12 -4
- package/src/programmers/http/HttpIsQueryProgrammer.ts +12 -4
- package/src/programmers/http/HttpQueryProgrammer.ts +12 -4
- package/src/programmers/json/JsonAssertParseProgrammer.ts +12 -4
- package/src/programmers/json/JsonIsParseProgrammer.ts +12 -4
- package/src/programmers/misc/MiscAssertCloneProgrammer.ts +12 -4
- package/src/programmers/misc/MiscCloneProgrammer.ts +12 -4
- package/src/programmers/misc/MiscIsCloneProgrammer.ts +12 -4
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +12 -4
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +12 -4
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +12 -4
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +1 -1
- package/src/protobuf.ts +8 -0
- package/src/transformers/CallExpressionTransformer.ts +95 -12
- package/src/utils/StringUtil/StringUtil.ts +5 -0
package/lib/functional.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IValidation } from "./IValidation";
|
|
1
2
|
import { TypeGuardError } from "./TypeGuardError";
|
|
2
3
|
/**
|
|
3
4
|
* Asserts a function.
|
|
@@ -195,3 +196,331 @@ export { assertEqualsParametersPure as assertEqualsParameters };
|
|
|
195
196
|
declare function assertEqualsReturn<T extends (...args: any[]) => any>(func: T, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): T;
|
|
196
197
|
declare const assertEqualsReturnPure: typeof assertEqualsReturn;
|
|
197
198
|
export { assertEqualsReturnPure as assertEqualsReturn };
|
|
199
|
+
/**
|
|
200
|
+
* Tests a function.
|
|
201
|
+
*
|
|
202
|
+
* Tests a function, by wrapping the function and checking its parameters and
|
|
203
|
+
* return value through {@link is} function. If some parameter or return value
|
|
204
|
+
* does not match the expected type, it returns `null`. Otherwise there's no
|
|
205
|
+
* type error, it returns the result of the function.
|
|
206
|
+
*
|
|
207
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
208
|
+
* detailed type error reason(s), then use {@link assertFunction} or
|
|
209
|
+
* {@link validateFunction} instead.
|
|
210
|
+
*
|
|
211
|
+
* On the other hand, if you don't want to allow any superfluous properties,
|
|
212
|
+
* utilize {@link equalsFunction}, {@link assertEqualsFunction} or
|
|
213
|
+
* {@link validateEqualsFunction} instead.
|
|
214
|
+
*
|
|
215
|
+
* @template T Target function type
|
|
216
|
+
* @param func Target function to test
|
|
217
|
+
* @returns The wrapper function with type tests
|
|
218
|
+
*
|
|
219
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
220
|
+
*/
|
|
221
|
+
declare function isFunction<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
222
|
+
declare const isFunctionPure: typeof isFunction;
|
|
223
|
+
export { isFunctionPure as isFunction };
|
|
224
|
+
/**
|
|
225
|
+
* Tests parameters.
|
|
226
|
+
*
|
|
227
|
+
* Tests a function, by wrapping the function and checking its parameters through
|
|
228
|
+
* {@link is} function. If some parameter does not match the expected type, it
|
|
229
|
+
* returns `null`. Otherwise there's no type error, it returns the result of the
|
|
230
|
+
* function.
|
|
231
|
+
*
|
|
232
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
233
|
+
* detailed type error reason(s), then use {@link assertParameters} or
|
|
234
|
+
* {@link validateParameters} instead.
|
|
235
|
+
*
|
|
236
|
+
* On the other hand, if you don't want to allow any superfluous properties,
|
|
237
|
+
* utilize {@link equalsParameters}, {@link assertEqualsParameters} or
|
|
238
|
+
* {@link validateEqualsParameters} instead.
|
|
239
|
+
*
|
|
240
|
+
* @template T Target function type
|
|
241
|
+
* @param func Target function to test
|
|
242
|
+
* @returns The wrapper function with type tests
|
|
243
|
+
*
|
|
244
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
245
|
+
*/
|
|
246
|
+
declare function isParameters<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
247
|
+
declare const isParametersPure: typeof isParameters;
|
|
248
|
+
export { isParametersPure as isParameters };
|
|
249
|
+
/**
|
|
250
|
+
* Tests return value.
|
|
251
|
+
*
|
|
252
|
+
* Tests a function, by wrapping the function and checking its return value through
|
|
253
|
+
* {@link is} function. If the return value does not match the expected type, it
|
|
254
|
+
* returns `null`. Otherwise there's no type error, it returns the result of the
|
|
255
|
+
* function.
|
|
256
|
+
*
|
|
257
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
258
|
+
* detailed type error reason(s), then use {@link assertReturn} or
|
|
259
|
+
* {@link validateReturn} instead.
|
|
260
|
+
*
|
|
261
|
+
* On the other hand, if you don't want to allow any superfluous properties,
|
|
262
|
+
* utilize {@link equalsReturn}, {@link assertEqualsReturn} or
|
|
263
|
+
* {@link validateEqualsReturn} instead.
|
|
264
|
+
*
|
|
265
|
+
* @template T Target function type
|
|
266
|
+
* @param func Target function to test
|
|
267
|
+
* @returns The wrapper function with type tests
|
|
268
|
+
*
|
|
269
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
270
|
+
*/
|
|
271
|
+
declare function isReturn<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
272
|
+
declare const isReturnPure: typeof isReturn;
|
|
273
|
+
export { isReturnPure as isReturn };
|
|
274
|
+
/**
|
|
275
|
+
* Tests a function with strict equality.
|
|
276
|
+
*
|
|
277
|
+
* Tests a function with strict equality, by wrapping the function and checking its
|
|
278
|
+
* parameters and return value through {@link isEquals} function. If some parameter
|
|
279
|
+
* or return value does not match the expected type, it returns `null`. Otherwise
|
|
280
|
+
* there's no type error, it returns the result of the function.
|
|
281
|
+
*
|
|
282
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
283
|
+
* detailed type error reason(s), then use {@link assertEqualsFunction} or
|
|
284
|
+
* {@link validateEqualsFunction} instead.
|
|
285
|
+
*
|
|
286
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
287
|
+
* {@link isFunction}, {@link assertFunction} or {@link validateFunction} instead.
|
|
288
|
+
*
|
|
289
|
+
* @template T Target function type
|
|
290
|
+
* @param func Target function to test
|
|
291
|
+
* @returns The wrapper function with type tests
|
|
292
|
+
*
|
|
293
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
294
|
+
*/
|
|
295
|
+
declare function equalsFunction<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
296
|
+
declare const equalsFunctionPure: typeof equalsFunction;
|
|
297
|
+
export { equalsFunctionPure as equalsFunction };
|
|
298
|
+
/**
|
|
299
|
+
* Tests parameters with strict equality.
|
|
300
|
+
*
|
|
301
|
+
* Tests a function, by wrapping the function and checking its parameters through
|
|
302
|
+
* {@link isEquals} function. If some parameter does not match the expected type,
|
|
303
|
+
* it returns `null`. Otherwise there's no type error, it returns the result of the
|
|
304
|
+
* function.
|
|
305
|
+
*
|
|
306
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
307
|
+
* detailed type error reason(s), then use {@link assertEqualsParameters} or
|
|
308
|
+
* {@link validateEqualsParameters} instead.
|
|
309
|
+
*
|
|
310
|
+
* @template T Target function type
|
|
311
|
+
* @param func Target function to test
|
|
312
|
+
* @returns The wrapper function with type tests
|
|
313
|
+
*
|
|
314
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
315
|
+
*/
|
|
316
|
+
declare function equalsParameters<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
317
|
+
declare const equalsParametersPure: typeof equalsParameters;
|
|
318
|
+
export { equalsParametersPure as equalsParameters };
|
|
319
|
+
/**
|
|
320
|
+
* Tests return value with strict equality.
|
|
321
|
+
*
|
|
322
|
+
* Tests a function, by wrapping the function and checking its return value through
|
|
323
|
+
* {@link isEquals} function. If the return value does not match the expected type,
|
|
324
|
+
* it returns `null`. Otherwise there's no type error, it returns the result of the
|
|
325
|
+
* function.
|
|
326
|
+
*
|
|
327
|
+
* By the way, if you want is not just testing type checking, but also finding
|
|
328
|
+
* detailed type error reason(s), then use {@link assertEqualsReturn} or
|
|
329
|
+
* {@link validateEqualsReturn} instead.
|
|
330
|
+
*
|
|
331
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
332
|
+
* {@link isReturn}, {@link assertReturn} or {@link validateReturn} instead.
|
|
333
|
+
*
|
|
334
|
+
* @template T Target function type
|
|
335
|
+
* @param func Target function to test
|
|
336
|
+
* @returns The wrapper function with type tests
|
|
337
|
+
*
|
|
338
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
339
|
+
*/
|
|
340
|
+
declare function equalsReturn<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<R | null> : (...args: Arguments) => Output | null : never;
|
|
341
|
+
declare const equalsReturnPure: typeof equalsReturn;
|
|
342
|
+
export { equalsReturnPure as equalsReturn };
|
|
343
|
+
/**
|
|
344
|
+
* Validates a function.
|
|
345
|
+
*
|
|
346
|
+
* Validates a function, by wrapping the function and checking its parameters and
|
|
347
|
+
* return value through {@link validate} function. If some parameter or return value
|
|
348
|
+
* does not match the expected type, it returns {@link IValidation.IError} typed
|
|
349
|
+
* object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
|
|
350
|
+
* typed object instead.
|
|
351
|
+
*
|
|
352
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
353
|
+
* individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
354
|
+
* some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
355
|
+
* the path would start from `$input.return`.
|
|
356
|
+
*
|
|
357
|
+
* - `$input.parameters[0].~`
|
|
358
|
+
* - `$input.return.~`
|
|
359
|
+
*
|
|
360
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
361
|
+
* the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
|
|
362
|
+
* want is just validating parameters or return value only, you can use
|
|
363
|
+
* {@link validateParameters} or {@link validateReturn} instead.
|
|
364
|
+
*
|
|
365
|
+
* On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
366
|
+
* {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
|
|
367
|
+
*
|
|
368
|
+
* @template T Target function type
|
|
369
|
+
* @param func Target function to validate
|
|
370
|
+
* @returns The wrapper function with type validations
|
|
371
|
+
*
|
|
372
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
373
|
+
*/
|
|
374
|
+
declare function validateFunction<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
375
|
+
declare const validateFunctionPure: typeof validateFunction;
|
|
376
|
+
export { validateFunctionPure as validateFunction };
|
|
377
|
+
/**
|
|
378
|
+
* Validates parameters.
|
|
379
|
+
*
|
|
380
|
+
* Validates a function, by wrapping the function and checking its parameters through
|
|
381
|
+
* {@link validate} function. If some parameter does not match the expected type, it
|
|
382
|
+
* returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
383
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
384
|
+
*
|
|
385
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
386
|
+
* individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
387
|
+
* some parameter, the path would start from `$input.parameters[number]`.
|
|
388
|
+
*
|
|
389
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
390
|
+
* the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
|
|
391
|
+
* want is not only validating parameters, but also validating return value, you can
|
|
392
|
+
* use {@link validateFunction} instead.
|
|
393
|
+
*
|
|
394
|
+
* On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
395
|
+
* {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
|
|
396
|
+
*
|
|
397
|
+
* @template T Target function type
|
|
398
|
+
* @param func Target function to validate
|
|
399
|
+
* @returns The wrapper function with type validations
|
|
400
|
+
*
|
|
401
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
402
|
+
*/
|
|
403
|
+
declare function validateParameters<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
404
|
+
declare const validateParametersPure: typeof validateParameters;
|
|
405
|
+
export { validateParametersPure as validateParameters };
|
|
406
|
+
/**
|
|
407
|
+
* Validates return value.
|
|
408
|
+
*
|
|
409
|
+
* Validates a function, by wrapping the function and checking its return value through
|
|
410
|
+
* {@link validate} function. If the return value does not match the expected type, it
|
|
411
|
+
* returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
412
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
413
|
+
*
|
|
414
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
415
|
+
* individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
416
|
+
* the return value, the path would start from `$input.return`.
|
|
417
|
+
*
|
|
418
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
419
|
+
* the 1st type error, then use {@link assertReturn} instead. Otherwise, what you want
|
|
420
|
+
* is not only validating return value, but also validating parameters, you can use
|
|
421
|
+
* {@link validateFunction} instead.
|
|
422
|
+
*
|
|
423
|
+
* On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
424
|
+
* {@link validateEqualsReturn} or {@link assertEqualsReturn} instead.
|
|
425
|
+
*
|
|
426
|
+
* @template T Target function type
|
|
427
|
+
* @param func Target function to validate
|
|
428
|
+
* @returns The wrapper function with type validations
|
|
429
|
+
*
|
|
430
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
431
|
+
*/
|
|
432
|
+
declare function validateReturn<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
433
|
+
declare const validateReturnPure: typeof validateReturn;
|
|
434
|
+
export { validateReturnPure as validateReturn };
|
|
435
|
+
/**
|
|
436
|
+
* Validates a function with strict equality.
|
|
437
|
+
*
|
|
438
|
+
* Validates a function with strict equality, by wrapping the function and checking
|
|
439
|
+
* its parameters and return value through {@link validateEquals} function. If some
|
|
440
|
+
* parameter or return value does not match the expected type, it returns
|
|
441
|
+
* {@link IValidation.IError} typed object. Otherwise there's no type error, it
|
|
442
|
+
* returns {@link IValidation.ISuccess} typed object instead.
|
|
443
|
+
*
|
|
444
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
445
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
446
|
+
* from some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
447
|
+
* the path would start from `$input.return`.
|
|
448
|
+
*
|
|
449
|
+
* - `$input.parameters[0].~`
|
|
450
|
+
* - `$input.return.~`
|
|
451
|
+
*
|
|
452
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
453
|
+
* the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
|
|
454
|
+
* you want is just validating parameters or return value only, you can use
|
|
455
|
+
* {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
|
|
456
|
+
*
|
|
457
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
458
|
+
* {@link validateFunction} or {@link assertFunction} instead.
|
|
459
|
+
*
|
|
460
|
+
* @template T Target function type
|
|
461
|
+
* @param func Target function to validate
|
|
462
|
+
* @returns The wrapper function with type validations
|
|
463
|
+
*
|
|
464
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
465
|
+
*/
|
|
466
|
+
declare function validateEqualsFunction<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
467
|
+
declare const validateEqualsFunctionPure: typeof validateEqualsFunction;
|
|
468
|
+
export { validateEqualsFunctionPure as validateEqualsFunction };
|
|
469
|
+
/**
|
|
470
|
+
* Validates parameters with strict equality.
|
|
471
|
+
*
|
|
472
|
+
* Validates a function, by wrapping the function and checking its parameters through
|
|
473
|
+
* {@link validateEquals} function. If some parameter does not match the expected type,
|
|
474
|
+
* it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
475
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
476
|
+
*
|
|
477
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
478
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
479
|
+
* from some parameter, the path would start from `$input.parameters[number]`.
|
|
480
|
+
*
|
|
481
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
482
|
+
* the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
|
|
483
|
+
* what you want is not only validating parameters, but also validating return value,
|
|
484
|
+
* you can use {@link validateEqualsFunction} instead.
|
|
485
|
+
*
|
|
486
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
487
|
+
* {@link validateParameters} or {@link assertParameters} instead.
|
|
488
|
+
*
|
|
489
|
+
* @template T Target function type
|
|
490
|
+
* @param func Target function to validate
|
|
491
|
+
* @returns The wrapper function with type validations
|
|
492
|
+
*
|
|
493
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
494
|
+
*/
|
|
495
|
+
declare function validateEqualsParameters<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
496
|
+
declare const validateEqualsParametersPure: typeof validateEqualsParameters;
|
|
497
|
+
export { validateEqualsParametersPure as validateEqualsParameters };
|
|
498
|
+
/**
|
|
499
|
+
* Validates return value with strict equality.
|
|
500
|
+
*
|
|
501
|
+
* Validates a function, by wrapping the function and checking its return value through
|
|
502
|
+
* {@link validateEquals} function. If the return value does not match the expected type,
|
|
503
|
+
* it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
504
|
+
* it returns {@link IValidation.ISuccess} typed object instead.
|
|
505
|
+
*
|
|
506
|
+
* For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
507
|
+
* individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
508
|
+
* from the return value, the path would start from `$input.return`.
|
|
509
|
+
*
|
|
510
|
+
* By the way, if what you want is not finding every type errors, but just finding
|
|
511
|
+
* the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
|
|
512
|
+
* want is not only validating return value, but also validating parameters, you can use
|
|
513
|
+
* {@link validateEqualsFunction} instead.
|
|
514
|
+
*
|
|
515
|
+
* On the other hand, if you want to allow any superfluous properties, utilize
|
|
516
|
+
* {@link validateReturn} or {@link assertReturn} instead.
|
|
517
|
+
*
|
|
518
|
+
* @template T Target function type
|
|
519
|
+
* @param func Target function to validate
|
|
520
|
+
* @returns The wrapper function with type validations
|
|
521
|
+
*
|
|
522
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
523
|
+
*/
|
|
524
|
+
declare function validateEqualsReturn<T extends (...args: any[]) => any>(func: T): T extends (...args: infer Arguments) => infer Output ? Output extends Promise<infer R> ? (...args: Arguments) => Promise<IValidation<R>> : (...args: Arguments) => IValidation<Output> : never;
|
|
525
|
+
declare const validateEqualsReturnPure: typeof validateEqualsReturn;
|
|
526
|
+
export { validateEqualsReturnPure as validateEqualsReturn };
|