typia 9.7.2 → 10.0.0-dev.20251107
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/LICENSE +21 -21
- package/README.md +153 -153
- package/lib/factories/ProtobufFactory.js +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -1
- package/lib/programmers/internal/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- package/package.json +121 -121
- package/src/AssertionGuard.ts +41 -41
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -337
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -90
- package/src/Resolved.ts +72 -72
- package/src/SnakeCase.ts +127 -127
- package/src/TypeGuardError.ts +216 -216
- package/src/factories/MetadataCollection.ts +270 -270
- package/src/factories/MetadataCommentTagFactory.ts +632 -632
- package/src/factories/MetadataFactory.ts +402 -402
- package/src/factories/ProtobufFactory.ts +873 -873
- package/src/functional.ts +705 -705
- package/src/http.ts +972 -972
- package/src/internal/_ProtobufReader.ts +188 -188
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -643
- package/src/llm.ts +615 -615
- package/src/misc.ts +594 -594
- package/src/module.ts +889 -889
- package/src/notations.ts +751 -751
- package/src/programmers/FeatureProgrammer.ts +605 -605
- package/src/programmers/ImportProgrammer.ts +179 -179
- package/src/programmers/RandomProgrammer.ts +1195 -1195
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -43
- package/src/programmers/internal/check_bigint.ts +46 -46
- package/src/programmers/internal/check_dynamic_key.ts +197 -197
- package/src/programmers/internal/check_dynamic_properties.ts +231 -231
- package/src/programmers/internal/check_everything.ts +21 -21
- package/src/programmers/internal/check_native.ts +23 -23
- package/src/programmers/internal/check_number.ts +108 -108
- package/src/programmers/internal/check_object.ts +72 -72
- package/src/programmers/internal/check_string.ts +46 -46
- package/src/programmers/internal/check_template.ts +46 -46
- package/src/programmers/internal/check_union_array_like.ts +331 -331
- package/src/programmers/internal/decode_union_object.ts +110 -110
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/json_schema_escaped.ts +78 -78
- package/src/programmers/internal/json_schema_object.ts +150 -150
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -40
- package/src/programmers/internal/postfix_of_tuple.ts +3 -3
- package/src/programmers/internal/prune_object_properties.ts +69 -69
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
- package/src/programmers/internal/stringify_native.ts +5 -5
- package/src/programmers/internal/stringify_regular_properties.ts +77 -77
- package/src/programmers/internal/template_to_pattern.ts +21 -21
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -820
- package/src/reflect.ts +46 -46
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
- package/src/schemas/metadata/Metadata.ts +669 -669
- package/src/schemas/metadata/MetadataAliasType.ts +57 -57
- package/src/schemas/metadata/MetadataApplication.ts +40 -40
- package/src/schemas/metadata/MetadataArray.ts +47 -47
- package/src/schemas/metadata/MetadataArrayType.ts +51 -51
- package/src/schemas/metadata/MetadataAtomic.ts +85 -85
- package/src/schemas/metadata/MetadataEscaped.ts +45 -45
- package/src/schemas/metadata/MetadataFunction.ts +45 -45
- package/src/schemas/metadata/MetadataObject.ts +46 -46
- package/src/schemas/metadata/MetadataObjectType.ts +137 -137
- package/src/schemas/metadata/MetadataParameter.ts +52 -52
- package/src/schemas/metadata/MetadataProperty.ts +53 -53
- package/src/schemas/metadata/MetadataTemplate.ts +78 -78
- package/src/schemas/metadata/MetadataTuple.ts +28 -28
- package/src/schemas/metadata/MetadataTupleType.ts +61 -61
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -44
- package/src/tags/ExclusiveMinimum.ts +44 -44
- package/src/tags/Format.ts +78 -78
- package/src/tags/JsonSchemaPlugin.ts +36 -36
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -25
- package/src/tags/Maximum.ts +39 -39
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -25
- package/src/tags/Minimum.ts +39 -39
- package/src/tags/MultipleOf.ts +42 -42
- package/src/tags/Pattern.ts +49 -49
- package/src/tags/Sequence.ts +37 -37
- package/src/tags/TagBase.ts +102 -102
- package/src/tags/Type.ts +64 -64
- package/src/tags/UniqueItems.ts +34 -34
- package/src/tags/internal/FormatCheatSheet.ts +71 -71
- package/src/transformers/ITransformOptions.ts +70 -70
- package/src/transformers/ImportTransformer.ts +253 -253
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/typings/Equal.ts +18 -18
package/src/module.ts
CHANGED
|
@@ -1,889 +1,889 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
|
|
3
|
-
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
4
|
-
|
|
5
|
-
import { AssertionGuard } from "./AssertionGuard";
|
|
6
|
-
import { IRandomGenerator } from "./IRandomGenerator";
|
|
7
|
-
import { IValidation } from "./IValidation";
|
|
8
|
-
import { Resolved } from "./Resolved";
|
|
9
|
-
import { TypeGuardError } from "./TypeGuardError";
|
|
10
|
-
|
|
11
|
-
export * as functional from "./functional";
|
|
12
|
-
export * as http from "./http";
|
|
13
|
-
export * as llm from "./llm";
|
|
14
|
-
export * as json from "./json";
|
|
15
|
-
export * as misc from "./misc";
|
|
16
|
-
export * as notations from "./notations";
|
|
17
|
-
export * as protobuf from "./protobuf";
|
|
18
|
-
export * as reflect from "./reflect";
|
|
19
|
-
export * as tags from "./tags";
|
|
20
|
-
|
|
21
|
-
export * from "./schemas/metadata/IJsDocTagInfo";
|
|
22
|
-
export * from "./schemas/json/IJsonApplication";
|
|
23
|
-
export * from "./schemas/json/IJsonSchemaCollection";
|
|
24
|
-
export * from "./schemas/json/IJsonSchemaUnit";
|
|
25
|
-
export * from "./AssertionGuard";
|
|
26
|
-
export * from "./IRandomGenerator";
|
|
27
|
-
export * from "./IValidation";
|
|
28
|
-
export * from "./TypeGuardError";
|
|
29
|
-
|
|
30
|
-
export * from "./Primitive";
|
|
31
|
-
export * from "./Resolved";
|
|
32
|
-
export * from "./CamelCase";
|
|
33
|
-
export * from "./PascalCase";
|
|
34
|
-
export * from "./SnakeCase";
|
|
35
|
-
export * from "./IReadableURLSearchParams";
|
|
36
|
-
|
|
37
|
-
/* -----------------------------------------------------------
|
|
38
|
-
BASIC VALIDATORS
|
|
39
|
-
----------------------------------------------------------- */
|
|
40
|
-
/**
|
|
41
|
-
* Asserts a value type.
|
|
42
|
-
*
|
|
43
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
44
|
-
* detailed reason, if the parametric value is not following the type `T`.
|
|
45
|
-
* Otherwise, if the value is following the type `T`, the input parameter will
|
|
46
|
-
* be returned.
|
|
47
|
-
*
|
|
48
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
49
|
-
* value is following the type `T` or not, you can choose the {@link is} function
|
|
50
|
-
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
51
|
-
* the way to go. Also, if you want to automatically cast the parametric value
|
|
52
|
-
* to the type `T` when there is no problem (perform the assertion guard of
|
|
53
|
-
* type).
|
|
54
|
-
*
|
|
55
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
56
|
-
* is not enrolled to the type `T`, you can use {@link assertEquals} function
|
|
57
|
-
* instead.
|
|
58
|
-
*
|
|
59
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
60
|
-
* @template T Type of the input value
|
|
61
|
-
* @param input A value to be asserted
|
|
62
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
63
|
-
* @returns Parametric input value
|
|
64
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
65
|
-
*/
|
|
66
|
-
export function assert<T>(
|
|
67
|
-
input: T,
|
|
68
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
69
|
-
): T;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Asserts a value type.
|
|
73
|
-
*
|
|
74
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
75
|
-
* detailed reason, if the parametric value is not following the type `T`.
|
|
76
|
-
* Otherwise, if the value is following the type `T`, the input parameter will
|
|
77
|
-
* be returned.
|
|
78
|
-
*
|
|
79
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
80
|
-
* value is following the type `T` or not, you can choose the {@link is} function
|
|
81
|
-
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
82
|
-
* the way to go.
|
|
83
|
-
*
|
|
84
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
85
|
-
* is not enrolled to the type `T`, you can use {@link assertEquals} function
|
|
86
|
-
* instead.
|
|
87
|
-
*
|
|
88
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
89
|
-
* @template T Type of the input value
|
|
90
|
-
* @param input A value to be asserted
|
|
91
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
92
|
-
* @returns Parametric input value casted as `T`
|
|
93
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
94
|
-
*/
|
|
95
|
-
export function assert<T>(
|
|
96
|
-
input: unknown,
|
|
97
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
98
|
-
): T;
|
|
99
|
-
|
|
100
|
-
/** @internal */
|
|
101
|
-
export function assert(): never {
|
|
102
|
-
NoTransformConfigurationError("assert");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Assertion guard of a value type.
|
|
107
|
-
*
|
|
108
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
109
|
-
* detailed reason, if the parametric value is not following the type `T`.
|
|
110
|
-
* Otherwise, if the value is following the type `T`, nothing will be returned,
|
|
111
|
-
* but the input value will be automatically casted to the type `T`. This is the
|
|
112
|
-
* concept of "Assertion Guard" of a value type.
|
|
113
|
-
*
|
|
114
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
115
|
-
* value is following the type `T` or not, you can choose the {@link is} function
|
|
116
|
-
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
117
|
-
* the way to go. Also, if you want to return the parametric value when there is
|
|
118
|
-
* no problem, you can use {@link assert} function instead.
|
|
119
|
-
*
|
|
120
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
121
|
-
* is not enrolled to the type `T`, you can use {@link assertGuardEquals}
|
|
122
|
-
* function instead.
|
|
123
|
-
*
|
|
124
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
125
|
-
* @template T Type of the input value
|
|
126
|
-
* @param input A value to be asserted
|
|
127
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
128
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
129
|
-
*/
|
|
130
|
-
export function assertGuard<T>(
|
|
131
|
-
input: T,
|
|
132
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
133
|
-
): asserts input is T;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Assertion guard of a value type.
|
|
137
|
-
*
|
|
138
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
139
|
-
* detailed reason, if the parametric value is not following the type `T`.
|
|
140
|
-
* Otherwise, if the value is following the type `T`, nothing will be returned,
|
|
141
|
-
* but the input value will be automatically casted to the type `T`. This is the
|
|
142
|
-
* concept of "Assertion Guard" of a value type.
|
|
143
|
-
*
|
|
144
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
145
|
-
* value is following the type `T` or not, you can choose the {@link is} function
|
|
146
|
-
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
147
|
-
* the way to go. Also, if you want to return the parametric value when there is
|
|
148
|
-
* no problem, you can use {@link assert} function instead.
|
|
149
|
-
*
|
|
150
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
151
|
-
* is not enrolled to the type `T`, you can use {@link assertGuardEquals}
|
|
152
|
-
* function instead.
|
|
153
|
-
*
|
|
154
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
155
|
-
* @template T Type of the input value
|
|
156
|
-
* @param input A value to be asserted
|
|
157
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
158
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
159
|
-
*/
|
|
160
|
-
export function assertGuard<T>(
|
|
161
|
-
input: unknown,
|
|
162
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
163
|
-
): asserts input is T;
|
|
164
|
-
|
|
165
|
-
/** @internal */
|
|
166
|
-
export function assertGuard(): never {
|
|
167
|
-
NoTransformConfigurationError("assertGuard");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Tests a value type.
|
|
172
|
-
*
|
|
173
|
-
* Tests a parametric value type and returns whether it's following the type `T`
|
|
174
|
-
* or not. If the parametric value is matched with the type `T`, `true` value
|
|
175
|
-
* will be returned. Otherwise, if the parametric value is not following the
|
|
176
|
-
* type `T`, `false` value will be returned.
|
|
177
|
-
*
|
|
178
|
-
* If what you want is not just knowing whether the parametric value is
|
|
179
|
-
* following the type `T` or not, but throwing an exception with a detailed
|
|
180
|
-
* reason, you can choose {@link assert} function instead. Also, if you want to
|
|
181
|
-
* know all the errors with detailed reasons, {@link validate} function will be
|
|
182
|
-
* useful.
|
|
183
|
-
*
|
|
184
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
185
|
-
* is not enrolled to the type `T`, you can use {@link equals} function instead.
|
|
186
|
-
*
|
|
187
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
188
|
-
* @template T Type of the input value
|
|
189
|
-
* @param input A value to be tested
|
|
190
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
191
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
192
|
-
*/
|
|
193
|
-
export function is<T>(input: T): input is T;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Tests a value type.
|
|
197
|
-
*
|
|
198
|
-
* Tests a parametric value type and returns whether it's following the type `T`
|
|
199
|
-
* or not. If the parametric value is matched with the type `T`, `true` value
|
|
200
|
-
* will be returned. Otherwise, if the parametric value is not following the
|
|
201
|
-
* type `T`, `false` value will be returned.
|
|
202
|
-
*
|
|
203
|
-
* If what you want is not just knowing whether the parametric value is
|
|
204
|
-
* following the type `T` or not, but throwing an exception with a detailed
|
|
205
|
-
* reason, you can choose {@link assert} function instead. Also, if you want to
|
|
206
|
-
* know all the errors with detailed reasons, {@link validate} function will be
|
|
207
|
-
* useful.
|
|
208
|
-
*
|
|
209
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
210
|
-
* is not enrolled to the type `T`, you can use {@link equals} function instead.
|
|
211
|
-
*
|
|
212
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
213
|
-
* @template T Type of the input value
|
|
214
|
-
* @param input A value to be tested
|
|
215
|
-
* @returns Whether the parametric value is following the type `T` or not
|
|
216
|
-
*/
|
|
217
|
-
export function is<T>(input: unknown): input is T;
|
|
218
|
-
|
|
219
|
-
/** @internal */
|
|
220
|
-
export function is(): never {
|
|
221
|
-
NoTransformConfigurationError("is");
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Validates a value type.
|
|
226
|
-
*
|
|
227
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
228
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
229
|
-
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
230
|
-
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
|
|
231
|
-
* will have the `true` value.
|
|
232
|
-
*
|
|
233
|
-
* If what you want is not finding all the errors, but asserting the parametric
|
|
234
|
-
* value type with exception throwing, you can choose {@link assert} function
|
|
235
|
-
* instead. Otherwise, if you just want to know whether the parametric value is
|
|
236
|
-
* matched with the type `T`, {@link is} function is the way to go.
|
|
237
|
-
*
|
|
238
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
239
|
-
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
240
|
-
* instead.
|
|
241
|
-
*
|
|
242
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
243
|
-
* @template T Type of the input value
|
|
244
|
-
* @param input A value to be validated
|
|
245
|
-
* @returns Validation result
|
|
246
|
-
*/
|
|
247
|
-
export function validate<T>(input: T): IValidation<T>;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Validates a value type.
|
|
251
|
-
*
|
|
252
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
253
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
254
|
-
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
255
|
-
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
|
|
256
|
-
* will have the `true` value.
|
|
257
|
-
*
|
|
258
|
-
* If what you want is not finding all the errors, but asserting the parametric
|
|
259
|
-
* value type with exception throwing, you can choose {@link assert} function
|
|
260
|
-
* instead. Otherwise, if you just want to know whether the parametric value is
|
|
261
|
-
* matched with the type `T`, {@link is} function is the way to go.
|
|
262
|
-
*
|
|
263
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
264
|
-
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
265
|
-
* instead.
|
|
266
|
-
*
|
|
267
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
268
|
-
* @template T Type of the input value
|
|
269
|
-
* @param input A value to be validated
|
|
270
|
-
* @returns Validation result
|
|
271
|
-
*/
|
|
272
|
-
export function validate<T>(input: unknown): IValidation<T>;
|
|
273
|
-
|
|
274
|
-
/** @internal */
|
|
275
|
-
export function validate(): never {
|
|
276
|
-
NoTransformConfigurationError("validate");
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/* -----------------------------------------------------------
|
|
280
|
-
STRICT VALIDATORS
|
|
281
|
-
----------------------------------------------------------- */
|
|
282
|
-
/**
|
|
283
|
-
* Asserts equality between a value and its type.
|
|
284
|
-
*
|
|
285
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
286
|
-
* detailed reason, if the parametric value is not following the type `T` or
|
|
287
|
-
* some superfluous property that is not listed on the type `T` has been found.
|
|
288
|
-
* Otherwise, the value is following the type `T` without any superfluous
|
|
289
|
-
* property, just input parameter would be returned.
|
|
290
|
-
*
|
|
291
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
292
|
-
* value is following the type `T` or not, you can choose the {@link equals}
|
|
293
|
-
* function instead. Otherwise, if you want to know all the errors,
|
|
294
|
-
* {@link validateEquals} is the way to go.
|
|
295
|
-
*
|
|
296
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
297
|
-
* enrolled to the type `T`, you can use {@link assert} function instead.
|
|
298
|
-
*
|
|
299
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
300
|
-
* @template T Type of the input value
|
|
301
|
-
* @param input A value to be asserted
|
|
302
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
303
|
-
* @returns Parametric input value
|
|
304
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
305
|
-
*/
|
|
306
|
-
export function assertEquals<T>(
|
|
307
|
-
input: T,
|
|
308
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
309
|
-
): T;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Asserts equality between a value and its type.
|
|
313
|
-
*
|
|
314
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
315
|
-
* detailed reason, if the parametric value is not following the type `T` or
|
|
316
|
-
* some superfluous property that is not listed on the type `T` has been found.
|
|
317
|
-
* Otherwise, the value is following the type `T` without any superfluous
|
|
318
|
-
* property, just input parameter would be returned.
|
|
319
|
-
*
|
|
320
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
321
|
-
* value is following the type `T` or not, you can choose the {@link equals}
|
|
322
|
-
* function instead. Otherwise, if you want to know all the errors,
|
|
323
|
-
* {@link validateEquals} is the way to go.
|
|
324
|
-
*
|
|
325
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
326
|
-
* enrolled to the type `T`, you can use {@link assert} function instead.
|
|
327
|
-
*
|
|
328
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
329
|
-
* @template T Type of the input value
|
|
330
|
-
* @param input A value to be asserted
|
|
331
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
332
|
-
* @returns Parametric input value casted as `T`
|
|
333
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
334
|
-
*/
|
|
335
|
-
export function assertEquals<T>(
|
|
336
|
-
input: unknown,
|
|
337
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
338
|
-
): T;
|
|
339
|
-
|
|
340
|
-
/** @internal */
|
|
341
|
-
export function assertEquals(): never {
|
|
342
|
-
NoTransformConfigurationError("assertEquals");
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Assertion guard of a type with equality.
|
|
347
|
-
*
|
|
348
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
349
|
-
* detailed reason, if the parametric value is not following the type `T` or
|
|
350
|
-
* some superfluous property that is not listed on the type `T` has been found.
|
|
351
|
-
*
|
|
352
|
-
* Otherwise, the value is following the type `T` without any superfluous
|
|
353
|
-
* property, nothing will be returned, but the input value would be
|
|
354
|
-
* automatically casted to the type `T`. This is the concept of "Assertion
|
|
355
|
-
* Guard" of a value type.
|
|
356
|
-
*
|
|
357
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
358
|
-
* value is following the type `T` or not, you can choose the {@link equals}
|
|
359
|
-
* function instead. Otherwise, if you want to know all the errors,
|
|
360
|
-
* {@link validateEquals} is the way to go. Also, if you want to returns the
|
|
361
|
-
* parametric value when no problem, you can use {@link assert} function
|
|
362
|
-
* instead.
|
|
363
|
-
*
|
|
364
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
365
|
-
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
366
|
-
*
|
|
367
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
-
* @template T Type of the input value
|
|
369
|
-
* @param input A value to be asserted
|
|
370
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
371
|
-
* @returns Parametric input value casted as `T`
|
|
372
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
373
|
-
*/
|
|
374
|
-
export function assertGuardEquals<T>(
|
|
375
|
-
input: T,
|
|
376
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
377
|
-
): asserts input is T;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Assertion guard of a type with equality.
|
|
381
|
-
*
|
|
382
|
-
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
383
|
-
* detailed reason, if the parametric value is not following the type `T` or
|
|
384
|
-
* some superfluous property that is not listed on the type `T` has been found.
|
|
385
|
-
*
|
|
386
|
-
* Otherwise, the value is following the type `T` without any superfluous
|
|
387
|
-
* property, nothing will be returned, but the input value would be
|
|
388
|
-
* automatically casted to the type `T`. This is the concept of "Assertion
|
|
389
|
-
* Guard" of a value type.
|
|
390
|
-
*
|
|
391
|
-
* If what you want is not asserting but just knowing whether the parametric
|
|
392
|
-
* value is following the type `T` or not, you can choose the {@link equals}
|
|
393
|
-
* function instead. Otherwise, if you want to know all the errors,
|
|
394
|
-
* {@link validateEquals} is the way to go. Also, if you want to returns the
|
|
395
|
-
* parametric value when no problem, you can use {@link assertEquals} function
|
|
396
|
-
* instead.
|
|
397
|
-
*
|
|
398
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
399
|
-
* enrolled to the type `T`, you can use {@link assertGuard} function instead.
|
|
400
|
-
*
|
|
401
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
402
|
-
* @template T Type of the input value
|
|
403
|
-
* @param input A value to be asserted
|
|
404
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
405
|
-
* @returns Parametric input value casted as `T`
|
|
406
|
-
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
407
|
-
*/
|
|
408
|
-
export function assertGuardEquals<T>(
|
|
409
|
-
input: unknown,
|
|
410
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
411
|
-
): asserts input is T;
|
|
412
|
-
|
|
413
|
-
/** @internal */
|
|
414
|
-
export function assertGuardEquals(): never {
|
|
415
|
-
NoTransformConfigurationError("assertGuardEquals");
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Tests equality between a value and its type.
|
|
420
|
-
*
|
|
421
|
-
* Tests a parametric value type and returns whether it's equivalent to the type
|
|
422
|
-
* `T` or not. If the parametric value is matched with the type `T` and there's
|
|
423
|
-
* not any superfluous property that is not listed on the type `T`, `true` value
|
|
424
|
-
* will be returned. Otherwise, if the parametric value is not following the
|
|
425
|
-
* type `T` or some superfluous property exists, `false` value will be
|
|
426
|
-
* returned.
|
|
427
|
-
*
|
|
428
|
-
* If what you want is not just knowing whether the parametric value is
|
|
429
|
-
* following the type `T` or not, but throwing an exception with a detailed
|
|
430
|
-
* reason, you can choose {@link assertEquals} function instead. Also, if you
|
|
431
|
-
* want to know all the errors with detailed reasons, {@link validateEquals}
|
|
432
|
-
* function will be useful.
|
|
433
|
-
*
|
|
434
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
435
|
-
* enrolled to the type `T`, you can use {@link is} function instead.
|
|
436
|
-
*
|
|
437
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
438
|
-
* @template T Type of the input value
|
|
439
|
-
* @param input A value to be tested
|
|
440
|
-
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
441
|
-
*/
|
|
442
|
-
export function equals<T>(input: T): input is T;
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Tests equality between a value and its type.
|
|
446
|
-
*
|
|
447
|
-
* Tests a parametric value type and returns whether it's equivalent to the type
|
|
448
|
-
* `T` or not. If the parametric value is matched with the type `T` and there's
|
|
449
|
-
* not any superfluous property that is not listed on the type `T`, `true` value
|
|
450
|
-
* will be returned. Otherwise, if the parametric value is not following the
|
|
451
|
-
* type `T` or some superfluous property exists, `false` value will be
|
|
452
|
-
* returned.
|
|
453
|
-
*
|
|
454
|
-
* If what you want is not just knowing whether the parametric value is
|
|
455
|
-
* following the type `T` or not, but throwing an exception with a detailed
|
|
456
|
-
* reason, you can choose {@link assertEquals} function instead. Also, if you
|
|
457
|
-
* want to know all the errors with detailed reasons, {@link validateEquals}
|
|
458
|
-
* function will be useful.
|
|
459
|
-
*
|
|
460
|
-
* On the other hand, if you want to allow superfluous property that is not
|
|
461
|
-
* enrolled to the type `T`, you can use {@link is} function instead.
|
|
462
|
-
*
|
|
463
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
464
|
-
* @template T Type of the input value
|
|
465
|
-
* @param input A value to be tested
|
|
466
|
-
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
467
|
-
*/
|
|
468
|
-
export function equals<T>(input: unknown): input is T;
|
|
469
|
-
|
|
470
|
-
/** @internal */
|
|
471
|
-
export function equals(): never {
|
|
472
|
-
NoTransformConfigurationError("equals");
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Validates equality between a value and its type.
|
|
477
|
-
*
|
|
478
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
479
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
480
|
-
* type `T` or some superfluous property that is not listed on the type `T` has
|
|
481
|
-
* been found. Of course, if the parametric value is following the type `T` and
|
|
482
|
-
* no superfluous property exists, the {@link IValidation.errors} array would be
|
|
483
|
-
* empty and {@link IValidation.success} would have the `true` value.
|
|
484
|
-
*
|
|
485
|
-
* If what you want is not finding all the error, but asserting the parametric
|
|
486
|
-
* value type with exception throwing, you can choose {@link assert} function
|
|
487
|
-
* instead. Otherwise, you just want to know whether the parametric value is
|
|
488
|
-
* matched with the type `T`, {@link is} function is the way to go.
|
|
489
|
-
*
|
|
490
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
491
|
-
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
492
|
-
* instead.
|
|
493
|
-
*
|
|
494
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
495
|
-
* @template Type Of the input value
|
|
496
|
-
* @param input A value to be validated
|
|
497
|
-
* @returns Validation result
|
|
498
|
-
*/
|
|
499
|
-
export function validateEquals<T>(input: T): IValidation<T>;
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Validates equality between a value and its type.
|
|
503
|
-
*
|
|
504
|
-
* Validates a parametric value type and archives all the type errors into an
|
|
505
|
-
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
506
|
-
* type `T` or some superfluous property that is not listed on the type `T` has
|
|
507
|
-
* been found. Of course, if the parametric value is following the type `T` and
|
|
508
|
-
* no superfluous property exists, the {@link IValidation.errors} array would be
|
|
509
|
-
* empty and {@link IValidation.success} would have the `true` value.
|
|
510
|
-
*
|
|
511
|
-
* If what you want is not finding all the error, but asserting the parametric
|
|
512
|
-
* value type with exception throwing, you can choose {@link assert} function
|
|
513
|
-
* instead. Otherwise, you just want to know whether the parametric value is
|
|
514
|
-
* matched with the type `T`, {@link is} function is the way to go.
|
|
515
|
-
*
|
|
516
|
-
* On the other hand, if you don't want to allow any superfluous property that
|
|
517
|
-
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
518
|
-
* instead.
|
|
519
|
-
*
|
|
520
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
521
|
-
* @template Type Of the input value
|
|
522
|
-
* @param input A value to be validated
|
|
523
|
-
* @returns Validation result
|
|
524
|
-
*/
|
|
525
|
-
export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
526
|
-
|
|
527
|
-
/** @internal */
|
|
528
|
-
export function validateEquals(): never {
|
|
529
|
-
NoTransformConfigurationError("validateEquals");
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/* -----------------------------------------------------------
|
|
533
|
-
RANDOM
|
|
534
|
-
----------------------------------------------------------- */
|
|
535
|
-
/**
|
|
536
|
-
* > You must configure the generic argument `T`.
|
|
537
|
-
*
|
|
538
|
-
* Generate random data.
|
|
539
|
-
*
|
|
540
|
-
* Generates a random data following type the `T`.
|
|
541
|
-
*
|
|
542
|
-
* For reference, this `typia.random()` function generates only primitive type.
|
|
543
|
-
* If there're some methods in the type `T` or its nested instances, those would
|
|
544
|
-
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
545
|
-
* will be generated instead.
|
|
546
|
-
*
|
|
547
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
548
|
-
* @template T Type of data to generate
|
|
549
|
-
* @param generator Random data generator
|
|
550
|
-
* @returns Randomly generated data
|
|
551
|
-
*/
|
|
552
|
-
export function random(generator?: Partial<IRandomGenerator>): never;
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Generate random data.
|
|
556
|
-
*
|
|
557
|
-
* Generates a random data following type the `T`.
|
|
558
|
-
*
|
|
559
|
-
* For reference, this `typia.random()` function generates only primitive type.
|
|
560
|
-
* If there're some methods in the type `T` or its nested instances, those would
|
|
561
|
-
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
562
|
-
* will be generated instead.
|
|
563
|
-
*
|
|
564
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
565
|
-
* @template T Type of data to generate
|
|
566
|
-
* @param generator Random data generator
|
|
567
|
-
* @returns Randomly generated data
|
|
568
|
-
*/
|
|
569
|
-
export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
|
|
570
|
-
|
|
571
|
-
/** @internal */
|
|
572
|
-
export function random(): never {
|
|
573
|
-
NoTransformConfigurationError("random");
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/* -----------------------------------------------------------
|
|
577
|
-
FACTORY FUNCTIONS
|
|
578
|
-
----------------------------------------------------------- */
|
|
579
|
-
/**
|
|
580
|
-
* Creates a reusable {@link assert} function.
|
|
581
|
-
*
|
|
582
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
583
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
584
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
585
|
-
* @throws Compile error
|
|
586
|
-
* @danger You must configure the generic argument `T`
|
|
587
|
-
*/
|
|
588
|
-
export function createAssert(
|
|
589
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
590
|
-
): never;
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Creates a reusable {@link assert} function.
|
|
594
|
-
*
|
|
595
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
596
|
-
* @template T Type of the input value
|
|
597
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
598
|
-
* @returns A reusable `assert` function
|
|
599
|
-
*/
|
|
600
|
-
export function createAssert<T>(
|
|
601
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
602
|
-
): (input: unknown) => T;
|
|
603
|
-
|
|
604
|
-
/** @internal */
|
|
605
|
-
export function createAssert<T>(): (input: unknown) => T {
|
|
606
|
-
NoTransformConfigurationError("createAssert");
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Creates a reusable {@link assertGuard} function.
|
|
611
|
-
*
|
|
612
|
-
* Note that, you've to declare the variable type of the factory function caller
|
|
613
|
-
* like below. If you don't declare the variable type, compilation error be
|
|
614
|
-
* thrown. This is the special rule of the TypeScript compiler.
|
|
615
|
-
*
|
|
616
|
-
* ```typescript
|
|
617
|
-
* // MUST DECLARE THE VARIABLE TYPE
|
|
618
|
-
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
|
|
619
|
-
*
|
|
620
|
-
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
621
|
-
* const func = typia.createAssertGuard<number>();
|
|
622
|
-
* ```
|
|
623
|
-
*
|
|
624
|
-
* > _Assertions require every name in the call target to be declared with an_
|
|
625
|
-
* > _explicit type annotation._
|
|
626
|
-
*
|
|
627
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
628
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
629
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
630
|
-
* @throws Compile error
|
|
631
|
-
* @danger You must configure the generic argument `T`
|
|
632
|
-
*/
|
|
633
|
-
export function createAssertGuard(
|
|
634
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
635
|
-
): never;
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Creates a reusable {@link assertGuard} function.
|
|
639
|
-
*
|
|
640
|
-
* Note that, you've to declare the variable type of the factory function caller
|
|
641
|
-
* like below. If you don't declare the variable type, compilation error be
|
|
642
|
-
* thrown. This is the special rule of the TypeScript compiler.
|
|
643
|
-
*
|
|
644
|
-
* ```typescript
|
|
645
|
-
* // MUST DECLARE THE VARIABLE TYPE
|
|
646
|
-
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
|
|
647
|
-
*
|
|
648
|
-
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
649
|
-
* const func = typia.createAssertGuard<number>();
|
|
650
|
-
* ```
|
|
651
|
-
*
|
|
652
|
-
* > _Assertions require every name in the call target to be declared with an_
|
|
653
|
-
* > _explicit type annotation._
|
|
654
|
-
*
|
|
655
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
656
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
657
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
658
|
-
* @throws Compile error
|
|
659
|
-
*/
|
|
660
|
-
export function createAssertGuard<T>(
|
|
661
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
662
|
-
): (input: unknown) => AssertionGuard<T>;
|
|
663
|
-
|
|
664
|
-
/** @internal */
|
|
665
|
-
export function createAssertGuard<T>(): (input: unknown) => AssertionGuard<T> {
|
|
666
|
-
NoTransformConfigurationError("createAssertGuard");
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/**
|
|
670
|
-
* Creates a reusable {@link is} function.
|
|
671
|
-
*
|
|
672
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
673
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
674
|
-
* @throws Compile error
|
|
675
|
-
* @danger You must configure the generic argument `T`
|
|
676
|
-
*/
|
|
677
|
-
export function createIs(): never;
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* Creates a reusable {@link is} function.
|
|
681
|
-
*
|
|
682
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
683
|
-
* @template T Type of the input value
|
|
684
|
-
* @returns A reusable `is` function
|
|
685
|
-
*/
|
|
686
|
-
export function createIs<T>(): (input: unknown) => input is T;
|
|
687
|
-
|
|
688
|
-
/** @internal */
|
|
689
|
-
export function createIs<T>(): (input: unknown) => input is T {
|
|
690
|
-
NoTransformConfigurationError("createIs");
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Creates a reusable {@link validate} function.
|
|
695
|
-
*
|
|
696
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
697
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
698
|
-
* @throws Compile error
|
|
699
|
-
* @danger You must configure the generic argument `T`
|
|
700
|
-
*/
|
|
701
|
-
export function createValidate(): never;
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Creates a reusable {@link validate} function.
|
|
705
|
-
*
|
|
706
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
707
|
-
* @template T Type of the input value
|
|
708
|
-
* @returns A reusable `validate` function
|
|
709
|
-
*/
|
|
710
|
-
export function createValidate<T>(): ((input: unknown) => IValidation<T>) &
|
|
711
|
-
StandardSchemaV1<unknown, T>;
|
|
712
|
-
|
|
713
|
-
/** @internal */
|
|
714
|
-
export function createValidate(): ((input: unknown) => IValidation) &
|
|
715
|
-
StandardSchemaV1<unknown, unknown> {
|
|
716
|
-
NoTransformConfigurationError("createValidate");
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Creates a reusable {@link assertEquals} function.
|
|
721
|
-
*
|
|
722
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
723
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
724
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
725
|
-
* @throws Compile error
|
|
726
|
-
* @danger You must configure the generic argument `T`
|
|
727
|
-
*/
|
|
728
|
-
export function createAssertEquals(
|
|
729
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
730
|
-
): never;
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Creates a reusable {@link assertEquals} function.
|
|
734
|
-
*
|
|
735
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
736
|
-
* @template T Type of the input value
|
|
737
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
738
|
-
* @returns A reusable `assertEquals` function
|
|
739
|
-
*/
|
|
740
|
-
export function createAssertEquals<T>(
|
|
741
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
742
|
-
): (input: unknown) => T;
|
|
743
|
-
|
|
744
|
-
/** @internal */
|
|
745
|
-
export function createAssertEquals<T>(): (input: unknown) => T {
|
|
746
|
-
NoTransformConfigurationError("createAssertEquals");
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Creates a reusable {@link assertGuardEquals} function.
|
|
751
|
-
*
|
|
752
|
-
* Note that, you've to declare the variable type of the factory function caller
|
|
753
|
-
* like below. If you don't declare the variable type, compilation error be
|
|
754
|
-
* thrown. This is the special rule of the TypeScript compiler.
|
|
755
|
-
*
|
|
756
|
-
* ```typescript
|
|
757
|
-
* // MUST DECLARE THE VARIABLE TYPE
|
|
758
|
-
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
|
|
759
|
-
*
|
|
760
|
-
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
761
|
-
* const func = typia.createAssertGuardEquals<number>();
|
|
762
|
-
* ```
|
|
763
|
-
*
|
|
764
|
-
* > _Assertions require every name in the call target to be declared with an_
|
|
765
|
-
* > _explicit type annotation._
|
|
766
|
-
*
|
|
767
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
768
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
769
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
770
|
-
* @throws Compile error
|
|
771
|
-
* @danger You must configure the generic argument `T`
|
|
772
|
-
*/
|
|
773
|
-
export function createAssertGuardEquals(
|
|
774
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
775
|
-
): never;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Creates a reusable {@link assertGuardEquals} function.
|
|
779
|
-
*
|
|
780
|
-
* Note that, you've to declare the variable type of the factory function caller
|
|
781
|
-
* like below. If you don't declare the variable type, compilation error be
|
|
782
|
-
* thrown. This is the special rule of the TypeScript compiler.
|
|
783
|
-
*
|
|
784
|
-
* ```typescript
|
|
785
|
-
* // MUST DECLARE THE VARIABLE TYPE
|
|
786
|
-
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
|
|
787
|
-
*
|
|
788
|
-
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
789
|
-
* const func = typia.createAssertGuardEquals<number>();
|
|
790
|
-
* ```
|
|
791
|
-
*
|
|
792
|
-
* > _Assertions require every name in the call target to be declared with an_
|
|
793
|
-
* > _explicit type annotation._
|
|
794
|
-
*
|
|
795
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
796
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
797
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
798
|
-
* @throws Compile error
|
|
799
|
-
*/
|
|
800
|
-
export function createAssertGuardEquals<T>(
|
|
801
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
802
|
-
): (input: unknown) => AssertionGuard<T>;
|
|
803
|
-
|
|
804
|
-
/** @internal */
|
|
805
|
-
export function createAssertGuardEquals<T>(): (
|
|
806
|
-
input: unknown,
|
|
807
|
-
) => AssertionGuard<T> {
|
|
808
|
-
NoTransformConfigurationError("createAssertGuardEquals");
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Creates a reusable {@link equals} function.
|
|
813
|
-
*
|
|
814
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
815
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
816
|
-
* @throws Compile error
|
|
817
|
-
* @danger You must configure the generic argument `T`
|
|
818
|
-
*/
|
|
819
|
-
export function createEquals(): never;
|
|
820
|
-
|
|
821
|
-
/**
|
|
822
|
-
* Creates a reusable {@link equals} function.
|
|
823
|
-
*
|
|
824
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
825
|
-
* @template T Type of the input value
|
|
826
|
-
* @returns A reusable `equals` function
|
|
827
|
-
*/
|
|
828
|
-
export function createEquals<T>(): (input: unknown) => input is T;
|
|
829
|
-
|
|
830
|
-
/** @internal */
|
|
831
|
-
export function createEquals<T>(): (input: unknown) => input is T {
|
|
832
|
-
NoTransformConfigurationError("createEquals");
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* Creates a reusable {@link validateEquals} function.
|
|
837
|
-
*
|
|
838
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
839
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
840
|
-
* @throws Compile error
|
|
841
|
-
* @danger You must configure the generic argument `T`
|
|
842
|
-
*/
|
|
843
|
-
export function createValidateEquals(): never;
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Creates a reusable {@link validateEquals} function.
|
|
847
|
-
*
|
|
848
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
849
|
-
* @template T Type of the input value
|
|
850
|
-
* @returns A reusable `validateEquals` function
|
|
851
|
-
*/
|
|
852
|
-
export function createValidateEquals<T>(): ((
|
|
853
|
-
input: unknown,
|
|
854
|
-
) => IValidation<T>) &
|
|
855
|
-
StandardSchemaV1<unknown, T>;
|
|
856
|
-
|
|
857
|
-
/** @internal */
|
|
858
|
-
export function createValidateEquals(): ((input: unknown) => IValidation) &
|
|
859
|
-
StandardSchemaV1<unknown, unknown> {
|
|
860
|
-
NoTransformConfigurationError("createValidateEquals");
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
/**
|
|
864
|
-
* Creates a reusable {@link random} function.
|
|
865
|
-
*
|
|
866
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
867
|
-
* @param generator Random data generator
|
|
868
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
869
|
-
* @throws Compile error
|
|
870
|
-
* @danger You must configure the generic argument `T`
|
|
871
|
-
*/
|
|
872
|
-
export function createRandom(generator?: Partial<IRandomGenerator>): never;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Creates a reusable {@link random} function.
|
|
876
|
-
*
|
|
877
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
878
|
-
* @template T Type of the input value
|
|
879
|
-
* @param generator Random data generator
|
|
880
|
-
* @returns A reusable `random` function
|
|
881
|
-
*/
|
|
882
|
-
export function createRandom<T>(
|
|
883
|
-
generator?: Partial<IRandomGenerator>,
|
|
884
|
-
): () => Resolved<T>;
|
|
885
|
-
|
|
886
|
-
/** @internal */
|
|
887
|
-
export function createRandom(): never {
|
|
888
|
-
NoTransformConfigurationError("createRandom");
|
|
889
|
-
}
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
|
|
3
|
+
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
4
|
+
|
|
5
|
+
import { AssertionGuard } from "./AssertionGuard";
|
|
6
|
+
import { IRandomGenerator } from "./IRandomGenerator";
|
|
7
|
+
import { IValidation } from "./IValidation";
|
|
8
|
+
import { Resolved } from "./Resolved";
|
|
9
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
10
|
+
|
|
11
|
+
export * as functional from "./functional";
|
|
12
|
+
export * as http from "./http";
|
|
13
|
+
export * as llm from "./llm";
|
|
14
|
+
export * as json from "./json";
|
|
15
|
+
export * as misc from "./misc";
|
|
16
|
+
export * as notations from "./notations";
|
|
17
|
+
export * as protobuf from "./protobuf";
|
|
18
|
+
export * as reflect from "./reflect";
|
|
19
|
+
export * as tags from "./tags";
|
|
20
|
+
|
|
21
|
+
export * from "./schemas/metadata/IJsDocTagInfo";
|
|
22
|
+
export * from "./schemas/json/IJsonApplication";
|
|
23
|
+
export * from "./schemas/json/IJsonSchemaCollection";
|
|
24
|
+
export * from "./schemas/json/IJsonSchemaUnit";
|
|
25
|
+
export * from "./AssertionGuard";
|
|
26
|
+
export * from "./IRandomGenerator";
|
|
27
|
+
export * from "./IValidation";
|
|
28
|
+
export * from "./TypeGuardError";
|
|
29
|
+
|
|
30
|
+
export * from "./Primitive";
|
|
31
|
+
export * from "./Resolved";
|
|
32
|
+
export * from "./CamelCase";
|
|
33
|
+
export * from "./PascalCase";
|
|
34
|
+
export * from "./SnakeCase";
|
|
35
|
+
export * from "./IReadableURLSearchParams";
|
|
36
|
+
|
|
37
|
+
/* -----------------------------------------------------------
|
|
38
|
+
BASIC VALIDATORS
|
|
39
|
+
----------------------------------------------------------- */
|
|
40
|
+
/**
|
|
41
|
+
* Asserts a value type.
|
|
42
|
+
*
|
|
43
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
44
|
+
* detailed reason, if the parametric value is not following the type `T`.
|
|
45
|
+
* Otherwise, if the value is following the type `T`, the input parameter will
|
|
46
|
+
* be returned.
|
|
47
|
+
*
|
|
48
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
49
|
+
* value is following the type `T` or not, you can choose the {@link is} function
|
|
50
|
+
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
51
|
+
* the way to go. Also, if you want to automatically cast the parametric value
|
|
52
|
+
* to the type `T` when there is no problem (perform the assertion guard of
|
|
53
|
+
* type).
|
|
54
|
+
*
|
|
55
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
56
|
+
* is not enrolled to the type `T`, you can use {@link assertEquals} function
|
|
57
|
+
* instead.
|
|
58
|
+
*
|
|
59
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
60
|
+
* @template T Type of the input value
|
|
61
|
+
* @param input A value to be asserted
|
|
62
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
63
|
+
* @returns Parametric input value
|
|
64
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
65
|
+
*/
|
|
66
|
+
export function assert<T>(
|
|
67
|
+
input: T,
|
|
68
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
69
|
+
): T;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Asserts a value type.
|
|
73
|
+
*
|
|
74
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
75
|
+
* detailed reason, if the parametric value is not following the type `T`.
|
|
76
|
+
* Otherwise, if the value is following the type `T`, the input parameter will
|
|
77
|
+
* be returned.
|
|
78
|
+
*
|
|
79
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
80
|
+
* value is following the type `T` or not, you can choose the {@link is} function
|
|
81
|
+
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
82
|
+
* the way to go.
|
|
83
|
+
*
|
|
84
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
85
|
+
* is not enrolled to the type `T`, you can use {@link assertEquals} function
|
|
86
|
+
* instead.
|
|
87
|
+
*
|
|
88
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
89
|
+
* @template T Type of the input value
|
|
90
|
+
* @param input A value to be asserted
|
|
91
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
92
|
+
* @returns Parametric input value casted as `T`
|
|
93
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
94
|
+
*/
|
|
95
|
+
export function assert<T>(
|
|
96
|
+
input: unknown,
|
|
97
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
98
|
+
): T;
|
|
99
|
+
|
|
100
|
+
/** @internal */
|
|
101
|
+
export function assert(): never {
|
|
102
|
+
NoTransformConfigurationError("assert");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Assertion guard of a value type.
|
|
107
|
+
*
|
|
108
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
109
|
+
* detailed reason, if the parametric value is not following the type `T`.
|
|
110
|
+
* Otherwise, if the value is following the type `T`, nothing will be returned,
|
|
111
|
+
* but the input value will be automatically casted to the type `T`. This is the
|
|
112
|
+
* concept of "Assertion Guard" of a value type.
|
|
113
|
+
*
|
|
114
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
115
|
+
* value is following the type `T` or not, you can choose the {@link is} function
|
|
116
|
+
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
117
|
+
* the way to go. Also, if you want to return the parametric value when there is
|
|
118
|
+
* no problem, you can use {@link assert} function instead.
|
|
119
|
+
*
|
|
120
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
121
|
+
* is not enrolled to the type `T`, you can use {@link assertGuardEquals}
|
|
122
|
+
* function instead.
|
|
123
|
+
*
|
|
124
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
125
|
+
* @template T Type of the input value
|
|
126
|
+
* @param input A value to be asserted
|
|
127
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
128
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
129
|
+
*/
|
|
130
|
+
export function assertGuard<T>(
|
|
131
|
+
input: T,
|
|
132
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
133
|
+
): asserts input is T;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Assertion guard of a value type.
|
|
137
|
+
*
|
|
138
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with a
|
|
139
|
+
* detailed reason, if the parametric value is not following the type `T`.
|
|
140
|
+
* Otherwise, if the value is following the type `T`, nothing will be returned,
|
|
141
|
+
* but the input value will be automatically casted to the type `T`. This is the
|
|
142
|
+
* concept of "Assertion Guard" of a value type.
|
|
143
|
+
*
|
|
144
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
145
|
+
* value is following the type `T` or not, you can choose the {@link is} function
|
|
146
|
+
* instead. Otherwise, if you want to know all the errors, {@link validate} is
|
|
147
|
+
* the way to go. Also, if you want to return the parametric value when there is
|
|
148
|
+
* no problem, you can use {@link assert} function instead.
|
|
149
|
+
*
|
|
150
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
151
|
+
* is not enrolled to the type `T`, you can use {@link assertGuardEquals}
|
|
152
|
+
* function instead.
|
|
153
|
+
*
|
|
154
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
155
|
+
* @template T Type of the input value
|
|
156
|
+
* @param input A value to be asserted
|
|
157
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
158
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
159
|
+
*/
|
|
160
|
+
export function assertGuard<T>(
|
|
161
|
+
input: unknown,
|
|
162
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
163
|
+
): asserts input is T;
|
|
164
|
+
|
|
165
|
+
/** @internal */
|
|
166
|
+
export function assertGuard(): never {
|
|
167
|
+
NoTransformConfigurationError("assertGuard");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Tests a value type.
|
|
172
|
+
*
|
|
173
|
+
* Tests a parametric value type and returns whether it's following the type `T`
|
|
174
|
+
* or not. If the parametric value is matched with the type `T`, `true` value
|
|
175
|
+
* will be returned. Otherwise, if the parametric value is not following the
|
|
176
|
+
* type `T`, `false` value will be returned.
|
|
177
|
+
*
|
|
178
|
+
* If what you want is not just knowing whether the parametric value is
|
|
179
|
+
* following the type `T` or not, but throwing an exception with a detailed
|
|
180
|
+
* reason, you can choose {@link assert} function instead. Also, if you want to
|
|
181
|
+
* know all the errors with detailed reasons, {@link validate} function will be
|
|
182
|
+
* useful.
|
|
183
|
+
*
|
|
184
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
185
|
+
* is not enrolled to the type `T`, you can use {@link equals} function instead.
|
|
186
|
+
*
|
|
187
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
188
|
+
* @template T Type of the input value
|
|
189
|
+
* @param input A value to be tested
|
|
190
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
191
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
192
|
+
*/
|
|
193
|
+
export function is<T>(input: T): input is T;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Tests a value type.
|
|
197
|
+
*
|
|
198
|
+
* Tests a parametric value type and returns whether it's following the type `T`
|
|
199
|
+
* or not. If the parametric value is matched with the type `T`, `true` value
|
|
200
|
+
* will be returned. Otherwise, if the parametric value is not following the
|
|
201
|
+
* type `T`, `false` value will be returned.
|
|
202
|
+
*
|
|
203
|
+
* If what you want is not just knowing whether the parametric value is
|
|
204
|
+
* following the type `T` or not, but throwing an exception with a detailed
|
|
205
|
+
* reason, you can choose {@link assert} function instead. Also, if you want to
|
|
206
|
+
* know all the errors with detailed reasons, {@link validate} function will be
|
|
207
|
+
* useful.
|
|
208
|
+
*
|
|
209
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
210
|
+
* is not enrolled to the type `T`, you can use {@link equals} function instead.
|
|
211
|
+
*
|
|
212
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
213
|
+
* @template T Type of the input value
|
|
214
|
+
* @param input A value to be tested
|
|
215
|
+
* @returns Whether the parametric value is following the type `T` or not
|
|
216
|
+
*/
|
|
217
|
+
export function is<T>(input: unknown): input is T;
|
|
218
|
+
|
|
219
|
+
/** @internal */
|
|
220
|
+
export function is(): never {
|
|
221
|
+
NoTransformConfigurationError("is");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Validates a value type.
|
|
226
|
+
*
|
|
227
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
228
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
229
|
+
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
230
|
+
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
|
|
231
|
+
* will have the `true` value.
|
|
232
|
+
*
|
|
233
|
+
* If what you want is not finding all the errors, but asserting the parametric
|
|
234
|
+
* value type with exception throwing, you can choose {@link assert} function
|
|
235
|
+
* instead. Otherwise, if you just want to know whether the parametric value is
|
|
236
|
+
* matched with the type `T`, {@link is} function is the way to go.
|
|
237
|
+
*
|
|
238
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
239
|
+
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
240
|
+
* instead.
|
|
241
|
+
*
|
|
242
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
243
|
+
* @template T Type of the input value
|
|
244
|
+
* @param input A value to be validated
|
|
245
|
+
* @returns Validation result
|
|
246
|
+
*/
|
|
247
|
+
export function validate<T>(input: T): IValidation<T>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Validates a value type.
|
|
251
|
+
*
|
|
252
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
253
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
254
|
+
* type `T`. Of course, if the parametric value is following the type `T`, the
|
|
255
|
+
* {@link IValidation.errors} array will be empty and {@link IValidation.success}
|
|
256
|
+
* will have the `true` value.
|
|
257
|
+
*
|
|
258
|
+
* If what you want is not finding all the errors, but asserting the parametric
|
|
259
|
+
* value type with exception throwing, you can choose {@link assert} function
|
|
260
|
+
* instead. Otherwise, if you just want to know whether the parametric value is
|
|
261
|
+
* matched with the type `T`, {@link is} function is the way to go.
|
|
262
|
+
*
|
|
263
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
264
|
+
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
265
|
+
* instead.
|
|
266
|
+
*
|
|
267
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
268
|
+
* @template T Type of the input value
|
|
269
|
+
* @param input A value to be validated
|
|
270
|
+
* @returns Validation result
|
|
271
|
+
*/
|
|
272
|
+
export function validate<T>(input: unknown): IValidation<T>;
|
|
273
|
+
|
|
274
|
+
/** @internal */
|
|
275
|
+
export function validate(): never {
|
|
276
|
+
NoTransformConfigurationError("validate");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* -----------------------------------------------------------
|
|
280
|
+
STRICT VALIDATORS
|
|
281
|
+
----------------------------------------------------------- */
|
|
282
|
+
/**
|
|
283
|
+
* Asserts equality between a value and its type.
|
|
284
|
+
*
|
|
285
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
286
|
+
* detailed reason, if the parametric value is not following the type `T` or
|
|
287
|
+
* some superfluous property that is not listed on the type `T` has been found.
|
|
288
|
+
* Otherwise, the value is following the type `T` without any superfluous
|
|
289
|
+
* property, just input parameter would be returned.
|
|
290
|
+
*
|
|
291
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
292
|
+
* value is following the type `T` or not, you can choose the {@link equals}
|
|
293
|
+
* function instead. Otherwise, if you want to know all the errors,
|
|
294
|
+
* {@link validateEquals} is the way to go.
|
|
295
|
+
*
|
|
296
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
297
|
+
* enrolled to the type `T`, you can use {@link assert} function instead.
|
|
298
|
+
*
|
|
299
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
300
|
+
* @template T Type of the input value
|
|
301
|
+
* @param input A value to be asserted
|
|
302
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
303
|
+
* @returns Parametric input value
|
|
304
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
305
|
+
*/
|
|
306
|
+
export function assertEquals<T>(
|
|
307
|
+
input: T,
|
|
308
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
309
|
+
): T;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Asserts equality between a value and its type.
|
|
313
|
+
*
|
|
314
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
315
|
+
* detailed reason, if the parametric value is not following the type `T` or
|
|
316
|
+
* some superfluous property that is not listed on the type `T` has been found.
|
|
317
|
+
* Otherwise, the value is following the type `T` without any superfluous
|
|
318
|
+
* property, just input parameter would be returned.
|
|
319
|
+
*
|
|
320
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
321
|
+
* value is following the type `T` or not, you can choose the {@link equals}
|
|
322
|
+
* function instead. Otherwise, if you want to know all the errors,
|
|
323
|
+
* {@link validateEquals} is the way to go.
|
|
324
|
+
*
|
|
325
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
326
|
+
* enrolled to the type `T`, you can use {@link assert} function instead.
|
|
327
|
+
*
|
|
328
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
329
|
+
* @template T Type of the input value
|
|
330
|
+
* @param input A value to be asserted
|
|
331
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
332
|
+
* @returns Parametric input value casted as `T`
|
|
333
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
334
|
+
*/
|
|
335
|
+
export function assertEquals<T>(
|
|
336
|
+
input: unknown,
|
|
337
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
338
|
+
): T;
|
|
339
|
+
|
|
340
|
+
/** @internal */
|
|
341
|
+
export function assertEquals(): never {
|
|
342
|
+
NoTransformConfigurationError("assertEquals");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Assertion guard of a type with equality.
|
|
347
|
+
*
|
|
348
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
349
|
+
* detailed reason, if the parametric value is not following the type `T` or
|
|
350
|
+
* some superfluous property that is not listed on the type `T` has been found.
|
|
351
|
+
*
|
|
352
|
+
* Otherwise, the value is following the type `T` without any superfluous
|
|
353
|
+
* property, nothing will be returned, but the input value would be
|
|
354
|
+
* automatically casted to the type `T`. This is the concept of "Assertion
|
|
355
|
+
* Guard" of a value type.
|
|
356
|
+
*
|
|
357
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
358
|
+
* value is following the type `T` or not, you can choose the {@link equals}
|
|
359
|
+
* function instead. Otherwise, if you want to know all the errors,
|
|
360
|
+
* {@link validateEquals} is the way to go. Also, if you want to returns the
|
|
361
|
+
* parametric value when no problem, you can use {@link assert} function
|
|
362
|
+
* instead.
|
|
363
|
+
*
|
|
364
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
365
|
+
* enrolled to the type `T`, you can use {@link assertEquals} function instead.
|
|
366
|
+
*
|
|
367
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
368
|
+
* @template T Type of the input value
|
|
369
|
+
* @param input A value to be asserted
|
|
370
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
371
|
+
* @returns Parametric input value casted as `T`
|
|
372
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
373
|
+
*/
|
|
374
|
+
export function assertGuardEquals<T>(
|
|
375
|
+
input: T,
|
|
376
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
377
|
+
): asserts input is T;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Assertion guard of a type with equality.
|
|
381
|
+
*
|
|
382
|
+
* Asserts a parametric value type and throws a {@link TypeGuardError} with
|
|
383
|
+
* detailed reason, if the parametric value is not following the type `T` or
|
|
384
|
+
* some superfluous property that is not listed on the type `T` has been found.
|
|
385
|
+
*
|
|
386
|
+
* Otherwise, the value is following the type `T` without any superfluous
|
|
387
|
+
* property, nothing will be returned, but the input value would be
|
|
388
|
+
* automatically casted to the type `T`. This is the concept of "Assertion
|
|
389
|
+
* Guard" of a value type.
|
|
390
|
+
*
|
|
391
|
+
* If what you want is not asserting but just knowing whether the parametric
|
|
392
|
+
* value is following the type `T` or not, you can choose the {@link equals}
|
|
393
|
+
* function instead. Otherwise, if you want to know all the errors,
|
|
394
|
+
* {@link validateEquals} is the way to go. Also, if you want to returns the
|
|
395
|
+
* parametric value when no problem, you can use {@link assertEquals} function
|
|
396
|
+
* instead.
|
|
397
|
+
*
|
|
398
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
399
|
+
* enrolled to the type `T`, you can use {@link assertGuard} function instead.
|
|
400
|
+
*
|
|
401
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
402
|
+
* @template T Type of the input value
|
|
403
|
+
* @param input A value to be asserted
|
|
404
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
405
|
+
* @returns Parametric input value casted as `T`
|
|
406
|
+
* @throws A {@link TypeGuardError} instance with a detailed reason
|
|
407
|
+
*/
|
|
408
|
+
export function assertGuardEquals<T>(
|
|
409
|
+
input: unknown,
|
|
410
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
411
|
+
): asserts input is T;
|
|
412
|
+
|
|
413
|
+
/** @internal */
|
|
414
|
+
export function assertGuardEquals(): never {
|
|
415
|
+
NoTransformConfigurationError("assertGuardEquals");
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Tests equality between a value and its type.
|
|
420
|
+
*
|
|
421
|
+
* Tests a parametric value type and returns whether it's equivalent to the type
|
|
422
|
+
* `T` or not. If the parametric value is matched with the type `T` and there's
|
|
423
|
+
* not any superfluous property that is not listed on the type `T`, `true` value
|
|
424
|
+
* will be returned. Otherwise, if the parametric value is not following the
|
|
425
|
+
* type `T` or some superfluous property exists, `false` value will be
|
|
426
|
+
* returned.
|
|
427
|
+
*
|
|
428
|
+
* If what you want is not just knowing whether the parametric value is
|
|
429
|
+
* following the type `T` or not, but throwing an exception with a detailed
|
|
430
|
+
* reason, you can choose {@link assertEquals} function instead. Also, if you
|
|
431
|
+
* want to know all the errors with detailed reasons, {@link validateEquals}
|
|
432
|
+
* function will be useful.
|
|
433
|
+
*
|
|
434
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
435
|
+
* enrolled to the type `T`, you can use {@link is} function instead.
|
|
436
|
+
*
|
|
437
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
438
|
+
* @template T Type of the input value
|
|
439
|
+
* @param input A value to be tested
|
|
440
|
+
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
441
|
+
*/
|
|
442
|
+
export function equals<T>(input: T): input is T;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Tests equality between a value and its type.
|
|
446
|
+
*
|
|
447
|
+
* Tests a parametric value type and returns whether it's equivalent to the type
|
|
448
|
+
* `T` or not. If the parametric value is matched with the type `T` and there's
|
|
449
|
+
* not any superfluous property that is not listed on the type `T`, `true` value
|
|
450
|
+
* will be returned. Otherwise, if the parametric value is not following the
|
|
451
|
+
* type `T` or some superfluous property exists, `false` value will be
|
|
452
|
+
* returned.
|
|
453
|
+
*
|
|
454
|
+
* If what you want is not just knowing whether the parametric value is
|
|
455
|
+
* following the type `T` or not, but throwing an exception with a detailed
|
|
456
|
+
* reason, you can choose {@link assertEquals} function instead. Also, if you
|
|
457
|
+
* want to know all the errors with detailed reasons, {@link validateEquals}
|
|
458
|
+
* function will be useful.
|
|
459
|
+
*
|
|
460
|
+
* On the other hand, if you want to allow superfluous property that is not
|
|
461
|
+
* enrolled to the type `T`, you can use {@link is} function instead.
|
|
462
|
+
*
|
|
463
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
464
|
+
* @template T Type of the input value
|
|
465
|
+
* @param input A value to be tested
|
|
466
|
+
* @returns Whether the parametric value is equivalent to the type `T` or not
|
|
467
|
+
*/
|
|
468
|
+
export function equals<T>(input: unknown): input is T;
|
|
469
|
+
|
|
470
|
+
/** @internal */
|
|
471
|
+
export function equals(): never {
|
|
472
|
+
NoTransformConfigurationError("equals");
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Validates equality between a value and its type.
|
|
477
|
+
*
|
|
478
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
479
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
480
|
+
* type `T` or some superfluous property that is not listed on the type `T` has
|
|
481
|
+
* been found. Of course, if the parametric value is following the type `T` and
|
|
482
|
+
* no superfluous property exists, the {@link IValidation.errors} array would be
|
|
483
|
+
* empty and {@link IValidation.success} would have the `true` value.
|
|
484
|
+
*
|
|
485
|
+
* If what you want is not finding all the error, but asserting the parametric
|
|
486
|
+
* value type with exception throwing, you can choose {@link assert} function
|
|
487
|
+
* instead. Otherwise, you just want to know whether the parametric value is
|
|
488
|
+
* matched with the type `T`, {@link is} function is the way to go.
|
|
489
|
+
*
|
|
490
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
491
|
+
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
492
|
+
* instead.
|
|
493
|
+
*
|
|
494
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
495
|
+
* @template Type Of the input value
|
|
496
|
+
* @param input A value to be validated
|
|
497
|
+
* @returns Validation result
|
|
498
|
+
*/
|
|
499
|
+
export function validateEquals<T>(input: T): IValidation<T>;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Validates equality between a value and its type.
|
|
503
|
+
*
|
|
504
|
+
* Validates a parametric value type and archives all the type errors into an
|
|
505
|
+
* {@link IValidation.errors} array, if the parametric value is not following the
|
|
506
|
+
* type `T` or some superfluous property that is not listed on the type `T` has
|
|
507
|
+
* been found. Of course, if the parametric value is following the type `T` and
|
|
508
|
+
* no superfluous property exists, the {@link IValidation.errors} array would be
|
|
509
|
+
* empty and {@link IValidation.success} would have the `true` value.
|
|
510
|
+
*
|
|
511
|
+
* If what you want is not finding all the error, but asserting the parametric
|
|
512
|
+
* value type with exception throwing, you can choose {@link assert} function
|
|
513
|
+
* instead. Otherwise, you just want to know whether the parametric value is
|
|
514
|
+
* matched with the type `T`, {@link is} function is the way to go.
|
|
515
|
+
*
|
|
516
|
+
* On the other hand, if you don't want to allow any superfluous property that
|
|
517
|
+
* is not enrolled to the type `T`, you can use {@link validateEquals} function
|
|
518
|
+
* instead.
|
|
519
|
+
*
|
|
520
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
521
|
+
* @template Type Of the input value
|
|
522
|
+
* @param input A value to be validated
|
|
523
|
+
* @returns Validation result
|
|
524
|
+
*/
|
|
525
|
+
export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
526
|
+
|
|
527
|
+
/** @internal */
|
|
528
|
+
export function validateEquals(): never {
|
|
529
|
+
NoTransformConfigurationError("validateEquals");
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/* -----------------------------------------------------------
|
|
533
|
+
RANDOM
|
|
534
|
+
----------------------------------------------------------- */
|
|
535
|
+
/**
|
|
536
|
+
* > You must configure the generic argument `T`.
|
|
537
|
+
*
|
|
538
|
+
* Generate random data.
|
|
539
|
+
*
|
|
540
|
+
* Generates a random data following type the `T`.
|
|
541
|
+
*
|
|
542
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
543
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
544
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
545
|
+
* will be generated instead.
|
|
546
|
+
*
|
|
547
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
548
|
+
* @template T Type of data to generate
|
|
549
|
+
* @param generator Random data generator
|
|
550
|
+
* @returns Randomly generated data
|
|
551
|
+
*/
|
|
552
|
+
export function random(generator?: Partial<IRandomGenerator>): never;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Generate random data.
|
|
556
|
+
*
|
|
557
|
+
* Generates a random data following type the `T`.
|
|
558
|
+
*
|
|
559
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
560
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
561
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
562
|
+
* will be generated instead.
|
|
563
|
+
*
|
|
564
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
565
|
+
* @template T Type of data to generate
|
|
566
|
+
* @param generator Random data generator
|
|
567
|
+
* @returns Randomly generated data
|
|
568
|
+
*/
|
|
569
|
+
export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
|
|
570
|
+
|
|
571
|
+
/** @internal */
|
|
572
|
+
export function random(): never {
|
|
573
|
+
NoTransformConfigurationError("random");
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/* -----------------------------------------------------------
|
|
577
|
+
FACTORY FUNCTIONS
|
|
578
|
+
----------------------------------------------------------- */
|
|
579
|
+
/**
|
|
580
|
+
* Creates a reusable {@link assert} function.
|
|
581
|
+
*
|
|
582
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
583
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
584
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
585
|
+
* @throws Compile error
|
|
586
|
+
* @danger You must configure the generic argument `T`
|
|
587
|
+
*/
|
|
588
|
+
export function createAssert(
|
|
589
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
590
|
+
): never;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Creates a reusable {@link assert} function.
|
|
594
|
+
*
|
|
595
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
596
|
+
* @template T Type of the input value
|
|
597
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
598
|
+
* @returns A reusable `assert` function
|
|
599
|
+
*/
|
|
600
|
+
export function createAssert<T>(
|
|
601
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
602
|
+
): (input: unknown) => T;
|
|
603
|
+
|
|
604
|
+
/** @internal */
|
|
605
|
+
export function createAssert<T>(): (input: unknown) => T {
|
|
606
|
+
NoTransformConfigurationError("createAssert");
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Creates a reusable {@link assertGuard} function.
|
|
611
|
+
*
|
|
612
|
+
* Note that, you've to declare the variable type of the factory function caller
|
|
613
|
+
* like below. If you don't declare the variable type, compilation error be
|
|
614
|
+
* thrown. This is the special rule of the TypeScript compiler.
|
|
615
|
+
*
|
|
616
|
+
* ```typescript
|
|
617
|
+
* // MUST DECLARE THE VARIABLE TYPE
|
|
618
|
+
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
|
|
619
|
+
*
|
|
620
|
+
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
621
|
+
* const func = typia.createAssertGuard<number>();
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* > _Assertions require every name in the call target to be declared with an_
|
|
625
|
+
* > _explicit type annotation._
|
|
626
|
+
*
|
|
627
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
628
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
629
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
630
|
+
* @throws Compile error
|
|
631
|
+
* @danger You must configure the generic argument `T`
|
|
632
|
+
*/
|
|
633
|
+
export function createAssertGuard(
|
|
634
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
635
|
+
): never;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Creates a reusable {@link assertGuard} function.
|
|
639
|
+
*
|
|
640
|
+
* Note that, you've to declare the variable type of the factory function caller
|
|
641
|
+
* like below. If you don't declare the variable type, compilation error be
|
|
642
|
+
* thrown. This is the special rule of the TypeScript compiler.
|
|
643
|
+
*
|
|
644
|
+
* ```typescript
|
|
645
|
+
* // MUST DECLARE THE VARIABLE TYPE
|
|
646
|
+
* const func: typia.AssertionGuard<number> = typia.createAssertGuard<number>();
|
|
647
|
+
*
|
|
648
|
+
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
649
|
+
* const func = typia.createAssertGuard<number>();
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* > _Assertions require every name in the call target to be declared with an_
|
|
653
|
+
* > _explicit type annotation._
|
|
654
|
+
*
|
|
655
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
656
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
657
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
658
|
+
* @throws Compile error
|
|
659
|
+
*/
|
|
660
|
+
export function createAssertGuard<T>(
|
|
661
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
662
|
+
): (input: unknown) => AssertionGuard<T>;
|
|
663
|
+
|
|
664
|
+
/** @internal */
|
|
665
|
+
export function createAssertGuard<T>(): (input: unknown) => AssertionGuard<T> {
|
|
666
|
+
NoTransformConfigurationError("createAssertGuard");
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Creates a reusable {@link is} function.
|
|
671
|
+
*
|
|
672
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
673
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
674
|
+
* @throws Compile error
|
|
675
|
+
* @danger You must configure the generic argument `T`
|
|
676
|
+
*/
|
|
677
|
+
export function createIs(): never;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Creates a reusable {@link is} function.
|
|
681
|
+
*
|
|
682
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
683
|
+
* @template T Type of the input value
|
|
684
|
+
* @returns A reusable `is` function
|
|
685
|
+
*/
|
|
686
|
+
export function createIs<T>(): (input: unknown) => input is T;
|
|
687
|
+
|
|
688
|
+
/** @internal */
|
|
689
|
+
export function createIs<T>(): (input: unknown) => input is T {
|
|
690
|
+
NoTransformConfigurationError("createIs");
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Creates a reusable {@link validate} function.
|
|
695
|
+
*
|
|
696
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
697
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
698
|
+
* @throws Compile error
|
|
699
|
+
* @danger You must configure the generic argument `T`
|
|
700
|
+
*/
|
|
701
|
+
export function createValidate(): never;
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Creates a reusable {@link validate} function.
|
|
705
|
+
*
|
|
706
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
707
|
+
* @template T Type of the input value
|
|
708
|
+
* @returns A reusable `validate` function
|
|
709
|
+
*/
|
|
710
|
+
export function createValidate<T>(): ((input: unknown) => IValidation<T>) &
|
|
711
|
+
StandardSchemaV1<unknown, T>;
|
|
712
|
+
|
|
713
|
+
/** @internal */
|
|
714
|
+
export function createValidate(): ((input: unknown) => IValidation) &
|
|
715
|
+
StandardSchemaV1<unknown, unknown> {
|
|
716
|
+
NoTransformConfigurationError("createValidate");
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Creates a reusable {@link assertEquals} function.
|
|
721
|
+
*
|
|
722
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
723
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
724
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
725
|
+
* @throws Compile error
|
|
726
|
+
* @danger You must configure the generic argument `T`
|
|
727
|
+
*/
|
|
728
|
+
export function createAssertEquals(
|
|
729
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
730
|
+
): never;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Creates a reusable {@link assertEquals} function.
|
|
734
|
+
*
|
|
735
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
736
|
+
* @template T Type of the input value
|
|
737
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
738
|
+
* @returns A reusable `assertEquals` function
|
|
739
|
+
*/
|
|
740
|
+
export function createAssertEquals<T>(
|
|
741
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
742
|
+
): (input: unknown) => T;
|
|
743
|
+
|
|
744
|
+
/** @internal */
|
|
745
|
+
export function createAssertEquals<T>(): (input: unknown) => T {
|
|
746
|
+
NoTransformConfigurationError("createAssertEquals");
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Creates a reusable {@link assertGuardEquals} function.
|
|
751
|
+
*
|
|
752
|
+
* Note that, you've to declare the variable type of the factory function caller
|
|
753
|
+
* like below. If you don't declare the variable type, compilation error be
|
|
754
|
+
* thrown. This is the special rule of the TypeScript compiler.
|
|
755
|
+
*
|
|
756
|
+
* ```typescript
|
|
757
|
+
* // MUST DECLARE THE VARIABLE TYPE
|
|
758
|
+
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
|
|
759
|
+
*
|
|
760
|
+
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
761
|
+
* const func = typia.createAssertGuardEquals<number>();
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* > _Assertions require every name in the call target to be declared with an_
|
|
765
|
+
* > _explicit type annotation._
|
|
766
|
+
*
|
|
767
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
768
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
769
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
770
|
+
* @throws Compile error
|
|
771
|
+
* @danger You must configure the generic argument `T`
|
|
772
|
+
*/
|
|
773
|
+
export function createAssertGuardEquals(
|
|
774
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
775
|
+
): never;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Creates a reusable {@link assertGuardEquals} function.
|
|
779
|
+
*
|
|
780
|
+
* Note that, you've to declare the variable type of the factory function caller
|
|
781
|
+
* like below. If you don't declare the variable type, compilation error be
|
|
782
|
+
* thrown. This is the special rule of the TypeScript compiler.
|
|
783
|
+
*
|
|
784
|
+
* ```typescript
|
|
785
|
+
* // MUST DECLARE THE VARIABLE TYPE
|
|
786
|
+
* const func: typia.AssertionGuard<number> = typia.createAssertGuardEquals<number>();
|
|
787
|
+
*
|
|
788
|
+
* // IF NOT, COMPILATION ERROR BE OCCURRED
|
|
789
|
+
* const func = typia.createAssertGuardEquals<number>();
|
|
790
|
+
* ```
|
|
791
|
+
*
|
|
792
|
+
* > _Assertions require every name in the call target to be declared with an_
|
|
793
|
+
* > _explicit type annotation._
|
|
794
|
+
*
|
|
795
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
796
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
797
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
798
|
+
* @throws Compile error
|
|
799
|
+
*/
|
|
800
|
+
export function createAssertGuardEquals<T>(
|
|
801
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
802
|
+
): (input: unknown) => AssertionGuard<T>;
|
|
803
|
+
|
|
804
|
+
/** @internal */
|
|
805
|
+
export function createAssertGuardEquals<T>(): (
|
|
806
|
+
input: unknown,
|
|
807
|
+
) => AssertionGuard<T> {
|
|
808
|
+
NoTransformConfigurationError("createAssertGuardEquals");
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Creates a reusable {@link equals} function.
|
|
813
|
+
*
|
|
814
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
815
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
816
|
+
* @throws Compile error
|
|
817
|
+
* @danger You must configure the generic argument `T`
|
|
818
|
+
*/
|
|
819
|
+
export function createEquals(): never;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Creates a reusable {@link equals} function.
|
|
823
|
+
*
|
|
824
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
825
|
+
* @template T Type of the input value
|
|
826
|
+
* @returns A reusable `equals` function
|
|
827
|
+
*/
|
|
828
|
+
export function createEquals<T>(): (input: unknown) => input is T;
|
|
829
|
+
|
|
830
|
+
/** @internal */
|
|
831
|
+
export function createEquals<T>(): (input: unknown) => input is T {
|
|
832
|
+
NoTransformConfigurationError("createEquals");
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Creates a reusable {@link validateEquals} function.
|
|
837
|
+
*
|
|
838
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
839
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
840
|
+
* @throws Compile error
|
|
841
|
+
* @danger You must configure the generic argument `T`
|
|
842
|
+
*/
|
|
843
|
+
export function createValidateEquals(): never;
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Creates a reusable {@link validateEquals} function.
|
|
847
|
+
*
|
|
848
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
849
|
+
* @template T Type of the input value
|
|
850
|
+
* @returns A reusable `validateEquals` function
|
|
851
|
+
*/
|
|
852
|
+
export function createValidateEquals<T>(): ((
|
|
853
|
+
input: unknown,
|
|
854
|
+
) => IValidation<T>) &
|
|
855
|
+
StandardSchemaV1<unknown, T>;
|
|
856
|
+
|
|
857
|
+
/** @internal */
|
|
858
|
+
export function createValidateEquals(): ((input: unknown) => IValidation) &
|
|
859
|
+
StandardSchemaV1<unknown, unknown> {
|
|
860
|
+
NoTransformConfigurationError("createValidateEquals");
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Creates a reusable {@link random} function.
|
|
865
|
+
*
|
|
866
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
867
|
+
* @param generator Random data generator
|
|
868
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
869
|
+
* @throws Compile error
|
|
870
|
+
* @danger You must configure the generic argument `T`
|
|
871
|
+
*/
|
|
872
|
+
export function createRandom(generator?: Partial<IRandomGenerator>): never;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Creates a reusable {@link random} function.
|
|
876
|
+
*
|
|
877
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
878
|
+
* @template T Type of the input value
|
|
879
|
+
* @param generator Random data generator
|
|
880
|
+
* @returns A reusable `random` function
|
|
881
|
+
*/
|
|
882
|
+
export function createRandom<T>(
|
|
883
|
+
generator?: Partial<IRandomGenerator>,
|
|
884
|
+
): () => Resolved<T>;
|
|
885
|
+
|
|
886
|
+
/** @internal */
|
|
887
|
+
export function createRandom(): never {
|
|
888
|
+
NoTransformConfigurationError("createRandom");
|
|
889
|
+
}
|