typia 5.0.4 → 5.0.5-dev.20230921

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/IRandomGenerator.ts +35 -35
  4. package/src/IValidation.ts +21 -21
  5. package/src/Primitive.ts +135 -135
  6. package/src/Resolved.ts +116 -116
  7. package/src/TypeGuardError.ts +36 -36
  8. package/src/executable/TypiaGenerateWizard.ts +85 -85
  9. package/src/executable/TypiaSetupWizard.ts +153 -153
  10. package/src/executable/setup/ArgumentParser.ts +45 -45
  11. package/src/executable/setup/CommandExecutor.ts +8 -8
  12. package/src/executable/setup/FileRetriever.ts +22 -22
  13. package/src/executable/setup/PackageManager.ts +71 -71
  14. package/src/executable/setup/PluginConfigurator.ts +70 -70
  15. package/src/executable/typia.ts +52 -52
  16. package/src/factories/CommentFactory.ts +84 -84
  17. package/src/factories/ExpressionFactory.ts +159 -159
  18. package/src/factories/IdentifierFactory.ts +74 -74
  19. package/src/factories/JsonMetadataFactory.ts +43 -43
  20. package/src/factories/LiteralFactory.ts +47 -47
  21. package/src/factories/MetadataCollection.ts +269 -269
  22. package/src/factories/MetadataCommentTagFactory.ts +629 -629
  23. package/src/factories/MetadataFactory.ts +214 -214
  24. package/src/factories/MetadataTypeTagFactory.ts +313 -313
  25. package/src/factories/NumericRangeFactory.ts +33 -33
  26. package/src/factories/ProtobufFactory.ts +272 -272
  27. package/src/factories/StatementFactory.ts +72 -72
  28. package/src/factories/TemplateFactory.ts +58 -58
  29. package/src/factories/TypeFactory.ts +119 -119
  30. package/src/factories/ValueFactory.ts +12 -12
  31. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  32. package/src/factories/internal/metadata/emend_metadata_atomics.ts +40 -40
  33. package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
  34. package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
  35. package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
  36. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
  37. package/src/factories/internal/metadata/explore_metadata.ts +32 -32
  38. package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
  39. package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
  40. package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
  41. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
  42. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  43. package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
  44. package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
  45. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  46. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
  47. package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
  48. package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
  49. package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
  50. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
  51. package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
  52. package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
  53. package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
  54. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
  55. package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
  56. package/src/functional/$ProtobufReader.ts +201 -201
  57. package/src/functional/$ProtobufSizer.ts +147 -147
  58. package/src/functional/$ProtobufWriter.ts +151 -151
  59. package/src/functional/$any.ts +4 -4
  60. package/src/functional/$clone.ts +4 -4
  61. package/src/functional/$dictionary.ts +25 -25
  62. package/src/functional/$every.ts +11 -11
  63. package/src/functional/$guard.ts +35 -35
  64. package/src/functional/$is_between.ts +2 -2
  65. package/src/functional/$join.ts +46 -46
  66. package/src/functional/$number.ts +13 -13
  67. package/src/functional/$report.ts +15 -15
  68. package/src/functional/$rest.ts +3 -3
  69. package/src/functional/$string.ts +50 -50
  70. package/src/functional/$strlen.ts +7 -7
  71. package/src/functional/$tail.ts +5 -5
  72. package/src/functional/$varint.ts +130 -130
  73. package/src/functional/$zigzag.ts +39 -39
  74. package/src/functional/IProtobufWriter.ts +18 -18
  75. package/src/functional/Namespace.ts +133 -133
  76. package/src/index.ts +4 -4
  77. package/src/json.ts +648 -648
  78. package/src/misc.ts +651 -651
  79. package/src/module.ts +656 -656
  80. package/src/programmers/AssertProgrammer.ts +317 -317
  81. package/src/programmers/CheckerProgrammer.ts +1137 -1137
  82. package/src/programmers/FeatureProgrammer.ts +478 -478
  83. package/src/programmers/IsProgrammer.ts +252 -252
  84. package/src/programmers/RandomProgrammer.ts +878 -878
  85. package/src/programmers/TypiaProgrammer.ts +163 -163
  86. package/src/programmers/ValidateProgrammer.ts +346 -346
  87. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  88. package/src/programmers/helpers/CloneJoiner.ts +144 -144
  89. package/src/programmers/helpers/FunctionImporeter.ts +91 -91
  90. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  91. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  92. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  93. package/src/programmers/helpers/ProtobufUtil.ts +125 -125
  94. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  95. package/src/programmers/helpers/PruneJoiner.ts +143 -143
  96. package/src/programmers/helpers/RandomJoiner.ts +151 -151
  97. package/src/programmers/helpers/RandomRanger.ts +173 -173
  98. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  99. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  100. package/src/programmers/helpers/UnionExplorer.ts +305 -305
  101. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  102. package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
  103. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  104. package/src/programmers/internal/application_alias.ts +65 -65
  105. package/src/programmers/internal/application_array.ts +53 -53
  106. package/src/programmers/internal/application_boolean.ts +15 -15
  107. package/src/programmers/internal/application_constant.ts +26 -26
  108. package/src/programmers/internal/application_default.ts +17 -17
  109. package/src/programmers/internal/application_default_string.ts +37 -37
  110. package/src/programmers/internal/application_escaped.ts +55 -55
  111. package/src/programmers/internal/application_native.ts +39 -39
  112. package/src/programmers/internal/application_number.ts +88 -88
  113. package/src/programmers/internal/application_object.ts +162 -162
  114. package/src/programmers/internal/application_schema.ts +175 -175
  115. package/src/programmers/internal/application_string.ts +51 -51
  116. package/src/programmers/internal/application_templates.ts +25 -25
  117. package/src/programmers/internal/application_tuple.ts +58 -58
  118. package/src/programmers/internal/check_array_length.ts +41 -41
  119. package/src/programmers/internal/check_bigint.ts +45 -45
  120. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  121. package/src/programmers/internal/check_everything.ts +28 -28
  122. package/src/programmers/internal/check_native.ts +21 -21
  123. package/src/programmers/internal/check_number.ts +105 -105
  124. package/src/programmers/internal/check_object.ts +55 -55
  125. package/src/programmers/internal/check_string.ts +45 -45
  126. package/src/programmers/internal/check_template.ts +61 -61
  127. package/src/programmers/internal/check_union_array_like.ts +323 -323
  128. package/src/programmers/internal/decode_union_object.ts +84 -84
  129. package/src/programmers/internal/feature_object_entries.ts +58 -58
  130. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  131. package/src/programmers/internal/prune_object_properties.ts +60 -60
  132. package/src/programmers/internal/random_custom.ts +37 -37
  133. package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
  134. package/src/programmers/internal/stringify_native.ts +7 -7
  135. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  136. package/src/programmers/internal/template_to_pattern.ts +15 -15
  137. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +20 -20
  138. package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
  139. package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
  140. package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
  141. package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
  142. package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
  143. package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
  144. package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
  145. package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
  146. package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
  147. package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
  148. package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
  149. package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
  150. package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
  151. package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
  152. package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
  153. package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
  154. package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
  155. package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
  156. package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
  157. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
  158. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
  159. package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
  160. package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
  161. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
  162. package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
  163. package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
  164. package/src/protobuf.ts +881 -881
  165. package/src/schemas/json/IJsonApplication.ts +8 -8
  166. package/src/schemas/json/IJsonComponents.ts +33 -33
  167. package/src/schemas/json/IJsonSchema.ts +110 -110
  168. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  169. package/src/schemas/metadata/IMetadata.ts +34 -34
  170. package/src/schemas/metadata/IMetadataAlias.ts +12 -12
  171. package/src/schemas/metadata/IMetadataApplication.ts +7 -7
  172. package/src/schemas/metadata/IMetadataArray.ts +7 -7
  173. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  174. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  175. package/src/schemas/metadata/IMetadataCollection.ts +11 -11
  176. package/src/schemas/metadata/IMetadataConstant.ts +16 -16
  177. package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
  178. package/src/schemas/metadata/IMetadataEntry.ts +6 -6
  179. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  180. package/src/schemas/metadata/IMetadataObject.ts +18 -18
  181. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  182. package/src/schemas/metadata/IMetadataTuple.ts +7 -7
  183. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  184. package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
  185. package/src/schemas/metadata/Metadata.ts +685 -685
  186. package/src/schemas/metadata/MetadataAlias.ts +61 -61
  187. package/src/schemas/metadata/MetadataArray.ts +49 -49
  188. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  189. package/src/schemas/metadata/MetadataAtomic.ts +42 -42
  190. package/src/schemas/metadata/MetadataConstant.ts +3 -3
  191. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  192. package/src/schemas/metadata/MetadataObject.ts +139 -139
  193. package/src/schemas/metadata/MetadataProperty.ts +59 -59
  194. package/src/schemas/metadata/MetadataTuple.ts +32 -32
  195. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  196. package/src/tags/ExclusiveMaximum.ts +13 -13
  197. package/src/tags/ExclusiveMinimum.ts +13 -13
  198. package/src/tags/Format.ts +30 -30
  199. package/src/tags/MaxItems.ts +9 -9
  200. package/src/tags/MaxLength.ts +9 -9
  201. package/src/tags/Maximum.ts +13 -13
  202. package/src/tags/MinItems.ts +9 -9
  203. package/src/tags/MinLength.ts +9 -9
  204. package/src/tags/Minimum.ts +13 -13
  205. package/src/tags/MultipleOf.ts +15 -15
  206. package/src/tags/Pattern.ts +8 -8
  207. package/src/tags/TagBase.ts +68 -68
  208. package/src/tags/Type.ts +27 -27
  209. package/src/tags/index.ts +13 -13
  210. package/src/transform.ts +35 -35
  211. package/src/transformers/CallExpressionTransformer.ts +243 -243
  212. package/src/transformers/FileTransformer.ts +57 -57
  213. package/src/transformers/IProject.ts +15 -15
  214. package/src/transformers/ITransformOptions.ts +62 -62
  215. package/src/transformers/ImportTransformer.ts +66 -66
  216. package/src/transformers/NodeTransformer.ts +13 -13
  217. package/src/transformers/TransformerError.ts +55 -55
  218. package/src/transformers/features/AssertTransformer.ts +11 -11
  219. package/src/transformers/features/CreateAssertTransformer.ts +13 -13
  220. package/src/transformers/features/CreateIsTransformer.ts +11 -11
  221. package/src/transformers/features/CreateRandomTransformer.ts +43 -43
  222. package/src/transformers/features/CreateValidateTransformer.ts +13 -13
  223. package/src/transformers/features/IsTransformer.ts +11 -11
  224. package/src/transformers/features/RandomTransformer.ts +46 -46
  225. package/src/transformers/features/ValidateTransformer.ts +11 -11
  226. package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
  227. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  228. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  229. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
  230. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  231. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  232. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
  233. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  234. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
  235. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  236. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  237. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  238. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  239. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  240. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  241. package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
  242. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  243. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  244. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  245. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
  246. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
  247. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  248. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  249. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  250. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  251. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
  252. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
  253. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  254. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  255. package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
  256. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  257. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  258. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  259. package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
  260. package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
  261. package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
  262. package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
  263. package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
  264. package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
  265. package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
  266. package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
  267. package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
  268. package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
  269. package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
  270. package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
  271. package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
  272. package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
  273. package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
  274. package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
  275. package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
  276. package/src/transformers/internal/GenericTransformer.ts +104 -104
  277. package/src/typings/Atomic.ts +18 -18
  278. package/src/typings/ClassProperties.ts +5 -5
  279. package/src/typings/Customizable.ts +5 -5
  280. package/src/typings/OmitNever.ts +3 -3
  281. package/src/typings/ProtobufAtomic.ts +19 -19
  282. package/src/typings/SpecialFields.ts +3 -3
  283. package/src/typings/ValidationPipe.ts +9 -9
  284. package/src/typings/Writable.ts +11 -11
  285. package/src/utils/ArrayUtil.ts +45 -45
  286. package/src/utils/Escaper.ts +46 -46
  287. package/src/utils/MapUtil.ts +12 -12
  288. package/src/utils/NameEncoder.ts +32 -32
  289. package/src/utils/PatternUtil.ts +33 -33
  290. package/src/utils/RandomGenerator.ts +83 -83
  291. package/src/utils/Singleton.ts +17 -17
package/src/module.ts CHANGED
@@ -1,656 +1,656 @@
1
- import { Namespace } from "./functional/Namespace";
2
-
3
- import { IMetadataApplication } from "./schemas/metadata/IMetadataApplication";
4
-
5
- import { IRandomGenerator } from "./IRandomGenerator";
6
- import { IValidation } from "./IValidation";
7
- import { Resolved } from "./Resolved";
8
-
9
- export * as json from "./json";
10
- export * as misc from "./misc";
11
- export * as protobuf from "./protobuf";
12
- export * as tags from "./tags";
13
-
14
- export * from "./schemas/json/IJsonApplication";
15
- export * from "./schemas/json/IJsonComponents";
16
- export * from "./schemas/json/IJsonSchema";
17
- export * from "./IRandomGenerator";
18
- export * from "./IValidation";
19
- export * from "./Primitive";
20
- export * from "./Resolved";
21
- export * from "./TypeGuardError";
22
-
23
- /* -----------------------------------------------------------
24
- BASIC VALIDATORS
25
- ----------------------------------------------------------- */
26
- /**
27
- * Asserts a value type.
28
- *
29
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
30
- * reason, if the parametric value is not following the type `T`. Otherwise, the
31
- * value is following the type `T`, just input parameter would be returned.
32
- *
33
- * If what you want is not asserting but just knowing whether the parametric value is
34
- * following the type `T` or not, you can choose the {@link is} function instead.
35
- * Otherwise you want to know all the errors, {@link validate} is the way to go.
36
- *
37
- * On the other and, if you don't want to allow any superfluous property that is not
38
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
39
- *
40
- * @template T Type of the input value
41
- * @param input A value to be asserted
42
- * @returns Parametric input value
43
- * @throws A {@link TypeGuardError} instance with detailed reason
44
- *
45
- * @author Jeongho Nam - https://github.com/samchon
46
- */
47
- export function assert<T>(input: T): T;
48
-
49
- /**
50
- * Asserts a value type.
51
- *
52
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
53
- * reason, if the parametric value is not following the type `T`. Otherwise, the
54
- * value is following the type `T`, just input parameter would be returned.
55
- *
56
- * If what you want is not asserting but just knowing whether the parametric value is
57
- * following the type `T` or not, you can choose the {@link is} function instead.
58
- * Otherwise, you want to know all the errors, {@link validate} is the way to go.
59
- *
60
- * On the other and, if you don't want to allow any superfluous property that is not
61
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
62
- *
63
- * @template T Type of the input value
64
- * @param input A value to be asserted
65
- * @returns Parametric input value casted as `T`
66
- * @throws A {@link TypeGuardError} instance with detailed reason
67
- *
68
- * @author Jeongho Nam - https://github.com/samchon
69
- */
70
- export function assert<T>(input: unknown): T;
71
-
72
- /**
73
- * @internal
74
- */
75
- export function assert(): never {
76
- halt("assert");
77
- }
78
- Object.assign(assert, Namespace.assert("assert"));
79
-
80
- /**
81
- * Tests a value type.
82
- *
83
- * Tests a parametric value type and returns whether it's following the type `T` or not.
84
- * If the parametric value is matched with the type `T`, `true` value would be returned.
85
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
86
- * returned.
87
- *
88
- * If what you want is not just knowing whether the parametric value is following the
89
- * type `T` or not, but throwing an exception with detailed reason, you can choose
90
- * {@link assert} function instead. Also, if you want to know all the errors with
91
- * detailed reasons, {@link validate} function would be useful.
92
- *
93
- * On the other and, if you don't want to allow any superfluous property that is not
94
- * enrolled to the type `T`, you can use {@link equals} function instead.
95
- *
96
- * @template T Type of the input value
97
- * @param input A value to be tested
98
- * @returns Whether the parametric value is following the type `T` or not
99
- *
100
- * @author Jeongho Nam - https://github.com/samchon
101
- */
102
- export function is<T>(input: T): input is T;
103
-
104
- /**
105
- * Tests a value type.
106
- *
107
- * Tests a parametric value type and returns whether it's following the type `T` or not.
108
- * If the parametric value is matched with the type `T`, `true` value would be returned.
109
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
110
- * returned.
111
- *
112
- * If what you want is not just knowing whether the parametric value is following the
113
- * type `T` or not, but throwing an exception with detailed reason, you can choose
114
- * {@link assert} function instead. Also, if you want to know all the errors with
115
- * detailed reasons, {@link validate} function would be useful.
116
- *
117
- * On the other and, if you don't want to allow any superfluous property that is not
118
- * enrolled to the type `T`, you can use {@link equals} function instead.
119
- *
120
- * @template T Type of the input value
121
- * @param input A value to be tested
122
- * @returns Whether the parametric value is following the type `T` or not
123
- *
124
- * @author Jeongho Nam - https://github.com/samchon
125
- */
126
- export function is<T>(input: unknown): input is T;
127
-
128
- /**
129
- * @internal
130
- */
131
- export function is(): never {
132
- halt("is");
133
- }
134
- Object.assign(is, Namespace.assert("is"));
135
-
136
- /**
137
- * Validates a value type.
138
- *
139
- * Validates a parametric value type and archives all the type errors into an
140
- * {@link IValidation.errors} array, if the parametric value is not following the
141
- * type `T`. Of course, if the parametric value is following the type `T`, the
142
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
143
- * would have the `true` value.
144
- *
145
- * If what you want is not finding all the error, but asserting the parametric value
146
- * type with exception throwing, you can choose {@link assert} function instead.
147
- * Otherwise, you just want to know whether the parametric value is matched with the
148
- * type `T`, {@link is} function is the way to go.
149
- *
150
- * On the other and, if you don't want to allow any superfluous property that is not
151
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
152
- *
153
- * @template Type of the input value
154
- * @param input A value to be validated
155
- * @returns Validation result
156
- *
157
- * @author Jeongho Nam - https://github.com/samchon
158
- */
159
- export function validate<T>(input: T): IValidation<T>;
160
-
161
- /**
162
- * Validates a value type.
163
- *
164
- * Validates a parametric value type and archives all the type errors into an
165
- * {@link IValidation.errors} array, if the parametric value is not following the
166
- * type `T`. Of course, if the parametric value is following the type `T`, the
167
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
168
- * would have the `true` value.
169
- *
170
- * If what you want is not finding all the error, but asserting the parametric value
171
- * type with exception throwing, you can choose {@link assert} function instead.
172
- * Otherwise, you just want to know whether the parametric value is matched with the
173
- * type `T`, {@link is} function is the way to go.
174
- *
175
- * On the other and, if you don't want to allow any superfluous property that is not
176
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
177
- *
178
- * @template Type of the input value
179
- * @param input A value to be validated
180
- * @returns Validation result
181
- *
182
- * @author Jeongho Nam - https://github.com/samchon
183
- */
184
- export function validate<T>(input: unknown): IValidation<T>;
185
-
186
- /**
187
- * @internal
188
- */
189
- export function validate(): never {
190
- halt("validate");
191
- }
192
- Object.assign(validate, Namespace.validate());
193
-
194
- /* -----------------------------------------------------------
195
- STRICT VALIDATORS
196
- ----------------------------------------------------------- */
197
- /**
198
- * Asserts equality between a value and its type.
199
- *
200
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
201
- * reason, if the parametric value is not following the type `T` or some superfluous
202
- * property that is not listed on the type `T` has been found. Otherwise, the value is
203
- * following the type `T` without any superfluous property, just input parameter would
204
- * be returned.
205
- *
206
- * If what you want is not asserting but just knowing whether the parametric value is
207
- * following the type `T` or not, you can choose the {@link equals} function instead.
208
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
209
- *
210
- * On the other hand, if you want to allow superfluous property that is not enrolled
211
- * to the type `T`, you can use {@link assert} function instead.
212
- *
213
- * @template T Type of the input value
214
- * @param input A value to be asserted
215
- * @returns Parametric input value
216
- * @throws A {@link TypeGuardError} instance with detailed reason
217
- *
218
- * @author Jeongho Nam - https://github.com/samchon
219
- */
220
- export function assertEquals<T>(input: T): T;
221
-
222
- /**
223
- * Asserts equality between a value and its type.
224
- *
225
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
226
- * reason, if the parametric value is not following the type `T` or some superfluous
227
- * property that is not listed on the type `T` has been found. Otherwise, the value is
228
- * following the type `T` without any superfluous property, just input parameter would
229
- * be returned.
230
- *
231
- * If what you want is not asserting but just knowing whether the parametric value is
232
- * following the type `T` or not, you can choose the {@link equals} function instead.
233
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
234
- *
235
- * On the other hand, if you want to allow superfluous property that is not enrolled
236
- * to the type `T`, you can use {@link assert} function instead.
237
- *
238
- * @template T Type of the input value
239
- * @param input A value to be asserted
240
- * @returns Parametric input value casted as `T`
241
- * @throws A {@link TypeGuardError} instance with detailed reason
242
- *
243
- * @author Jeongho Nam - https://github.com/samchon
244
- */
245
- export function assertEquals<T>(input: unknown): T;
246
-
247
- /**
248
- * @internal
249
- */
250
- export function assertEquals(): never {
251
- halt("assertEquals");
252
- }
253
- Object.assign(assertEquals, Namespace.assert("assertEquals"));
254
-
255
- /**
256
- * Tests equality between a value and its type.
257
- *
258
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
259
- * or not. If the parametric value is matched with the type `T` and there's not any
260
- * superfluous property that is not listed on the type `T`, `true` value would be
261
- * returned. Otherwise, the parametric value is not following the type `T` or some
262
- * superfluous property exists, `false` value would be returned.
263
- *
264
- * If what you want is not just knowing whether the parametric value is following the
265
- * type `T` or not, but throwing an exception with detailed reason, you can choose
266
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
267
- * detailed reasons, {@link validateEquals} function would be useful.
268
- *
269
- * On the other hand, if you want to allow superfluous property that is not enrolled
270
- * to the type `T`, you can use {@link is} function instead.
271
- *
272
- * @template T Type of the input value
273
- * @param input A value to be tested
274
- * @returns Whether the parametric value is equivalent to the type `T` or not
275
- *
276
- * @author Jeongho Nam - https://github.com/samchon
277
- */
278
- export function equals<T>(input: T): input is T;
279
-
280
- /**
281
- * Tests equality between a value and its type.
282
- *
283
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
284
- * or not. If the parametric value is matched with the type `T` and there's not any
285
- * superfluous property that is not listed on the type `T`, `true` value would be
286
- * returned. Otherwise, the parametric value is not following the type `T` or some
287
- * superfluous property exists, `false` value would be returned.
288
- *
289
- * If what you want is not just knowing whether the parametric value is following the
290
- * type `T` or not, but throwing an exception with detailed reason, you can choose
291
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
292
- * detailed reasons, {@link validateEquals} function would be useful.
293
- *
294
- * On the other hand, if you want to allow superfluous property that is not enrolled
295
- * to the type `T`, you can use {@link is} function instead.
296
- *
297
- * @template T Type of the input value
298
- * @param input A value to be tested
299
- * @returns Whether the parametric value is equivalent to the type `T` or not
300
- *
301
- * @author Jeongho Nam - https://github.com/samchon
302
- */
303
- export function equals<T>(input: unknown): input is T;
304
-
305
- /**
306
- * @internal
307
- */
308
- export function equals(): never {
309
- halt("equals");
310
- }
311
- Object.assign(equals, Namespace.is());
312
-
313
- /**
314
- * Validates equality between a value and its type.
315
- *
316
- * Validates a parametric value type and archives all the type errors into an
317
- * {@link IValidation.errors} array, if the parametric value is not following the
318
- * type `T` or some superfluous property that is not listed on the type `T` has been
319
- * found. Of course, if the parametric value is following the type `T` and no
320
- * superfluous property exists, the {@link IValidation.errors} array would be empty
321
- * and {@link IValidation.success} would have the `true` value.
322
- *
323
- * If what you want is not finding all the error, but asserting the parametric value
324
- * type with exception throwing, you can choose {@link assert} function instead.
325
- * Otherwise, you just want to know whether the parametric value is matched with the
326
- * type `T`, {@link is} function is the way to go.
327
- *
328
- * On the other and, if you don't want to allow any superfluous property that is not
329
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
330
- *
331
- * @template Type of the input value
332
- * @param input A value to be validated
333
- * @returns Validation result
334
- *
335
- * @author Jeongho Nam - https://github.com/samchon
336
- */
337
- export function validateEquals<T>(input: T): IValidation<T>;
338
-
339
- /**
340
- * Validates equality between a value and its type.
341
- *
342
- * Validates a parametric value type and archives all the type errors into an
343
- * {@link IValidation.errors} array, if the parametric value is not following the
344
- * type `T` or some superfluous property that is not listed on the type `T` has been
345
- * found. Of course, if the parametric value is following the type `T` and no
346
- * superfluous property exists, the {@link IValidation.errors} array would be empty
347
- * and {@link IValidation.success} would have the `true` value.
348
- *
349
- * If what you want is not finding all the error, but asserting the parametric value
350
- * type with exception throwing, you can choose {@link assert} function instead.
351
- * Otherwise, you just want to know whether the parametric value is matched with the
352
- * type `T`, {@link is} function is the way to go.
353
- *
354
- * On the other and, if you don't want to allow any superfluous property that is not
355
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
356
- *
357
- * @template Type of the input value
358
- * @param input A value to be validated
359
- * @returns Validation result
360
- *
361
- * @author Jeongho Nam - https://github.com/samchon
362
- */
363
- export function validateEquals<T>(input: unknown): IValidation<T>;
364
-
365
- /**
366
- * @internal
367
- */
368
- export function validateEquals(): never {
369
- halt("validateEquals");
370
- }
371
- Object.assign(validateEquals, Namespace.validate());
372
-
373
- /* -----------------------------------------------------------
374
- RANDOM
375
- ----------------------------------------------------------- */
376
- /**
377
- * > You must configure the generic argument `T`.
378
- *
379
- * Generate random data.
380
- *
381
- * Generates a random data following type the `T`.
382
- *
383
- * For reference, this `typia.random()` function generates only primitive type.
384
- * If there're some methods in the type `T` or its nested instances, those would
385
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
386
- * would be generated instead.
387
- *
388
- * @template T Type of data to generate
389
- * @param generator Random data generator
390
- * @return Randomly generated data
391
- *
392
- * @author Jeongho Nam - https://github.com/samchon
393
- */
394
- export function random(generator?: Partial<IRandomGenerator>): never;
395
-
396
- /**
397
- * Generate random data.
398
- *
399
- * Generates a random data following type the `T`.
400
- *
401
- * For reference, this `typia.random()` function generates only primitive type.
402
- * If there're some methods in the type `T` or its nested instances, those would
403
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
404
- * would be generated instead.
405
- *
406
- * @template T Type of data to generate
407
- * @param generator Random data generator
408
- * @return Randomly generated data
409
- *
410
- * @author Jeongho Nam - https://github.com/samchon
411
- */
412
- export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
413
-
414
- /**
415
- * @internal
416
- */
417
- export function random(): never {
418
- halt("random");
419
- }
420
- Object.assign(random, Namespace.random());
421
-
422
- /**
423
- * @internal
424
- */
425
- export function metadata(): never;
426
-
427
- /**
428
- * @internal
429
- */
430
- export function metadata<Types extends unknown[]>(): IMetadataApplication;
431
-
432
- /**
433
- * @internal
434
- */
435
- export function metadata(): never {
436
- halt("metadata");
437
- }
438
-
439
- /* -----------------------------------------------------------
440
- FACTORY FUNCTIONS
441
- ----------------------------------------------------------- */
442
- /**
443
- * Creates a reusable {@link assert} function.
444
- *
445
- * @danger You must configure the generic argument `T`
446
- * @returns Nothing until you configure the generic argument `T`
447
- * @throws compile error
448
- *
449
- * @author Jeongho Nam - https://github.com/samchon
450
- */
451
- export function createAssert(): never;
452
-
453
- /**
454
- * Creates a reusable {@link assert} function.
455
- *
456
- * @template T Type of the input value
457
- * @returns A reusable `assert` function
458
- *
459
- * @author Jeongho Nam - https://github.com/samchon
460
- */
461
- export function createAssert<T>(): (input: unknown) => T;
462
-
463
- /**
464
- * @internal
465
- */
466
- export function createAssert<T>(): (input: unknown) => T {
467
- halt("createAssert");
468
- }
469
- Object.assign(createAssert, assert);
470
-
471
- /**
472
- * Creates a reusable {@link is} function.
473
- *
474
- * @danger You must configure the generic argument `T`
475
- * @returns Nothing until you configure the generic argument `T`
476
- * @throws compile error
477
- *
478
- * @author Jeongho Nam - https://github.com/samchon
479
- */
480
- export function createIs(): never;
481
-
482
- /**
483
- * Creates a reusable {@link is} function.
484
- *
485
- * @template T Type of the input value
486
- * @returns A reusable `is` function
487
- *
488
- * @author Jeongho Nam - https://github.com/samchon
489
- */
490
- export function createIs<T>(): (input: unknown) => input is T;
491
-
492
- /**
493
- * @internal
494
- */
495
- export function createIs<T>(): (input: unknown) => input is T {
496
- halt("createIs");
497
- }
498
- Object.assign(createIs, is);
499
-
500
- /**
501
- * Creates a reusable {@link validate} function.
502
- *
503
- * @danger You must configure the generic argument `T`
504
- * @returns Nothing until you configure the generic argument `T`
505
- * @throws compile error
506
- *
507
- * @author Jeongho Nam - https://github.com/samchon
508
- */
509
- export function createValidate(): never;
510
-
511
- /**
512
- * Creates a reusable {@link validate} function.
513
- *
514
- * @template T Type of the input value
515
- * @returns A reusable `validate` function
516
- *
517
- * @author Jeongho Nam - https://github.com/samchon
518
- */
519
- export function createValidate<T>(): (input: unknown) => IValidation<T>;
520
-
521
- /**
522
- * @internal
523
- */
524
- export function createValidate(): (input: unknown) => IValidation {
525
- halt("createValidate");
526
- }
527
- Object.assign(createValidate, validate);
528
-
529
- /**
530
- * Creates a reusable {@link assertEquals} function.
531
- *
532
- * @danger You must configure the generic argument `T`
533
- * @returns Nothing until you configure the generic argument `T`
534
- * @throws compile error
535
- *
536
- * @author Jeongho Nam - https://github.com/samchon
537
- */
538
- export function createAssertEquals(): never;
539
-
540
- /**
541
- * Creates a reusable {@link assertEquals} function.
542
- *
543
- * @template T Type of the input value
544
- * @returns A reusable `assertEquals` function
545
- *
546
- * @author Jeongho Nam - https://github.com/samchon
547
- */
548
- export function createAssertEquals<T>(): (input: unknown) => T;
549
-
550
- /**
551
- * @internal
552
- */
553
- export function createAssertEquals<T>(): (input: unknown) => T {
554
- halt("createAssertEquals");
555
- }
556
- Object.assign(createAssertEquals, assertEquals);
557
-
558
- /**
559
- * Creates a reusable {@link equals} function.
560
- *
561
- * @danger You must configure the generic argument `T`
562
- * @returns Nothing until you configure the generic argument `T`
563
- * @throws compile error
564
- *
565
- * @author Jeongho Nam - https://github.com/samchon
566
- */
567
- export function createEquals(): never;
568
-
569
- /**
570
- * Creates a reusable {@link equals} function.
571
- *
572
- * @template T Type of the input value
573
- * @returns A reusable `equals` function
574
- *
575
- * @author Jeongho Nam - https://github.com/samchon
576
- */
577
- export function createEquals<T>(): (input: unknown) => input is T;
578
-
579
- /**
580
- * @internal
581
- */
582
- export function createEquals<T>(): (input: unknown) => input is T {
583
- halt("createEquals");
584
- }
585
- Object.assign(createEquals, equals);
586
-
587
- /**
588
- * Creates a reusable {@link validateEquals} function.
589
- *
590
- * @danger You must configure the generic argument `T`
591
- * @returns Nothing until you configure the generic argument `T`
592
- * @throws compile error
593
- *
594
- * @author Jeongho Nam - https://github.com/samchon
595
- */
596
- export function createValidateEquals(): never;
597
-
598
- /**
599
- * Creates a reusable {@link validateEquals} function.
600
- *
601
- * @template T Type of the input value
602
- * @returns A reusable `validateEquals` function
603
- *
604
- * @author Jeongho Nam - https://github.com/samchon
605
- */
606
- export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
607
-
608
- /**
609
- * @internal
610
- */
611
- export function createValidateEquals(): (input: unknown) => IValidation {
612
- halt("createValidateEquals");
613
- }
614
- Object.assign(createValidateEquals, validateEquals);
615
-
616
- /**
617
- * Creates a reusable {@link random} function.
618
- *
619
- * @danger You must configure the generic argument `T`
620
- * @param generator Random data generator
621
- * @returns Nothing until you configure the generic argument `T`
622
- * @throws compile error
623
- *
624
- * @author Jeongho Nam - https://github.com/samchon
625
- */
626
- export function createRandom(generator?: Partial<IRandomGenerator>): never;
627
-
628
- /**
629
- * Creates a resuable {@link random} function.
630
- *
631
- * @template T Type of the input value
632
- * @param generator Random data generator
633
- * @returns A reusable `random` function
634
- *
635
- * @author Jeongho Nam - https://github.com/samchon
636
- */
637
- export function createRandom<T>(
638
- generator?: Partial<IRandomGenerator>,
639
- ): () => Resolved<T>;
640
-
641
- /**
642
- * @internal
643
- */
644
- export function createRandom(): never {
645
- halt("createRandom");
646
- }
647
- Object.assign(createRandom, random);
648
-
649
- /**
650
- * @internal
651
- */
652
- function halt(name: string): never {
653
- throw new Error(
654
- `Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
655
- );
656
- }
1
+ import { Namespace } from "./functional/Namespace";
2
+
3
+ import { IMetadataApplication } from "./schemas/metadata/IMetadataApplication";
4
+
5
+ import { IRandomGenerator } from "./IRandomGenerator";
6
+ import { IValidation } from "./IValidation";
7
+ import { Resolved } from "./Resolved";
8
+
9
+ export * as json from "./json";
10
+ export * as misc from "./misc";
11
+ export * as protobuf from "./protobuf";
12
+ export * as tags from "./tags";
13
+
14
+ export * from "./schemas/json/IJsonApplication";
15
+ export * from "./schemas/json/IJsonComponents";
16
+ export * from "./schemas/json/IJsonSchema";
17
+ export * from "./IRandomGenerator";
18
+ export * from "./IValidation";
19
+ export * from "./Primitive";
20
+ export * from "./Resolved";
21
+ export * from "./TypeGuardError";
22
+
23
+ /* -----------------------------------------------------------
24
+ BASIC VALIDATORS
25
+ ----------------------------------------------------------- */
26
+ /**
27
+ * Asserts a value type.
28
+ *
29
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
30
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
31
+ * value is following the type `T`, just input parameter would be returned.
32
+ *
33
+ * If what you want is not asserting but just knowing whether the parametric value is
34
+ * following the type `T` or not, you can choose the {@link is} function instead.
35
+ * Otherwise you want to know all the errors, {@link validate} is the way to go.
36
+ *
37
+ * On the other and, if you don't want to allow any superfluous property that is not
38
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
39
+ *
40
+ * @template T Type of the input value
41
+ * @param input A value to be asserted
42
+ * @returns Parametric input value
43
+ * @throws A {@link TypeGuardError} instance with detailed reason
44
+ *
45
+ * @author Jeongho Nam - https://github.com/samchon
46
+ */
47
+ export function assert<T>(input: T): T;
48
+
49
+ /**
50
+ * Asserts a value type.
51
+ *
52
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
53
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
54
+ * value is following the type `T`, just input parameter would be returned.
55
+ *
56
+ * If what you want is not asserting but just knowing whether the parametric value is
57
+ * following the type `T` or not, you can choose the {@link is} function instead.
58
+ * Otherwise, you want to know all the errors, {@link validate} is the way to go.
59
+ *
60
+ * On the other and, if you don't want to allow any superfluous property that is not
61
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
62
+ *
63
+ * @template T Type of the input value
64
+ * @param input A value to be asserted
65
+ * @returns Parametric input value casted as `T`
66
+ * @throws A {@link TypeGuardError} instance with detailed reason
67
+ *
68
+ * @author Jeongho Nam - https://github.com/samchon
69
+ */
70
+ export function assert<T>(input: unknown): T;
71
+
72
+ /**
73
+ * @internal
74
+ */
75
+ export function assert(): never {
76
+ halt("assert");
77
+ }
78
+ Object.assign(assert, Namespace.assert("assert"));
79
+
80
+ /**
81
+ * Tests a value type.
82
+ *
83
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
84
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
85
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
86
+ * returned.
87
+ *
88
+ * If what you want is not just knowing whether the parametric value is following the
89
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
90
+ * {@link assert} function instead. Also, if you want to know all the errors with
91
+ * detailed reasons, {@link validate} function would be useful.
92
+ *
93
+ * On the other and, if you don't want to allow any superfluous property that is not
94
+ * enrolled to the type `T`, you can use {@link equals} function instead.
95
+ *
96
+ * @template T Type of the input value
97
+ * @param input A value to be tested
98
+ * @returns Whether the parametric value is following the type `T` or not
99
+ *
100
+ * @author Jeongho Nam - https://github.com/samchon
101
+ */
102
+ export function is<T>(input: T): input is T;
103
+
104
+ /**
105
+ * Tests a value type.
106
+ *
107
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
108
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
109
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
110
+ * returned.
111
+ *
112
+ * If what you want is not just knowing whether the parametric value is following the
113
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
114
+ * {@link assert} function instead. Also, if you want to know all the errors with
115
+ * detailed reasons, {@link validate} function would be useful.
116
+ *
117
+ * On the other and, if you don't want to allow any superfluous property that is not
118
+ * enrolled to the type `T`, you can use {@link equals} function instead.
119
+ *
120
+ * @template T Type of the input value
121
+ * @param input A value to be tested
122
+ * @returns Whether the parametric value is following the type `T` or not
123
+ *
124
+ * @author Jeongho Nam - https://github.com/samchon
125
+ */
126
+ export function is<T>(input: unknown): input is T;
127
+
128
+ /**
129
+ * @internal
130
+ */
131
+ export function is(): never {
132
+ halt("is");
133
+ }
134
+ Object.assign(is, Namespace.assert("is"));
135
+
136
+ /**
137
+ * Validates a value type.
138
+ *
139
+ * Validates a parametric value type and archives all the type errors into an
140
+ * {@link IValidation.errors} array, if the parametric value is not following the
141
+ * type `T`. Of course, if the parametric value is following the type `T`, the
142
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
143
+ * would have the `true` value.
144
+ *
145
+ * If what you want is not finding all the error, but asserting the parametric value
146
+ * type with exception throwing, you can choose {@link assert} function instead.
147
+ * Otherwise, you just want to know whether the parametric value is matched with the
148
+ * type `T`, {@link is} function is the way to go.
149
+ *
150
+ * On the other and, if you don't want to allow any superfluous property that is not
151
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
152
+ *
153
+ * @template Type of the input value
154
+ * @param input A value to be validated
155
+ * @returns Validation result
156
+ *
157
+ * @author Jeongho Nam - https://github.com/samchon
158
+ */
159
+ export function validate<T>(input: T): IValidation<T>;
160
+
161
+ /**
162
+ * Validates a value type.
163
+ *
164
+ * Validates a parametric value type and archives all the type errors into an
165
+ * {@link IValidation.errors} array, if the parametric value is not following the
166
+ * type `T`. Of course, if the parametric value is following the type `T`, the
167
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
168
+ * would have the `true` value.
169
+ *
170
+ * If what you want is not finding all the error, but asserting the parametric value
171
+ * type with exception throwing, you can choose {@link assert} function instead.
172
+ * Otherwise, you just want to know whether the parametric value is matched with the
173
+ * type `T`, {@link is} function is the way to go.
174
+ *
175
+ * On the other and, if you don't want to allow any superfluous property that is not
176
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
177
+ *
178
+ * @template Type of the input value
179
+ * @param input A value to be validated
180
+ * @returns Validation result
181
+ *
182
+ * @author Jeongho Nam - https://github.com/samchon
183
+ */
184
+ export function validate<T>(input: unknown): IValidation<T>;
185
+
186
+ /**
187
+ * @internal
188
+ */
189
+ export function validate(): never {
190
+ halt("validate");
191
+ }
192
+ Object.assign(validate, Namespace.validate());
193
+
194
+ /* -----------------------------------------------------------
195
+ STRICT VALIDATORS
196
+ ----------------------------------------------------------- */
197
+ /**
198
+ * Asserts equality between a value and its type.
199
+ *
200
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
201
+ * reason, if the parametric value is not following the type `T` or some superfluous
202
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
203
+ * following the type `T` without any superfluous property, just input parameter would
204
+ * be returned.
205
+ *
206
+ * If what you want is not asserting but just knowing whether the parametric value is
207
+ * following the type `T` or not, you can choose the {@link equals} function instead.
208
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
209
+ *
210
+ * On the other hand, if you want to allow superfluous property that is not enrolled
211
+ * to the type `T`, you can use {@link assert} function instead.
212
+ *
213
+ * @template T Type of the input value
214
+ * @param input A value to be asserted
215
+ * @returns Parametric input value
216
+ * @throws A {@link TypeGuardError} instance with detailed reason
217
+ *
218
+ * @author Jeongho Nam - https://github.com/samchon
219
+ */
220
+ export function assertEquals<T>(input: T): T;
221
+
222
+ /**
223
+ * Asserts equality between a value and its type.
224
+ *
225
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
226
+ * reason, if the parametric value is not following the type `T` or some superfluous
227
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
228
+ * following the type `T` without any superfluous property, just input parameter would
229
+ * be returned.
230
+ *
231
+ * If what you want is not asserting but just knowing whether the parametric value is
232
+ * following the type `T` or not, you can choose the {@link equals} function instead.
233
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
234
+ *
235
+ * On the other hand, if you want to allow superfluous property that is not enrolled
236
+ * to the type `T`, you can use {@link assert} function instead.
237
+ *
238
+ * @template T Type of the input value
239
+ * @param input A value to be asserted
240
+ * @returns Parametric input value casted as `T`
241
+ * @throws A {@link TypeGuardError} instance with detailed reason
242
+ *
243
+ * @author Jeongho Nam - https://github.com/samchon
244
+ */
245
+ export function assertEquals<T>(input: unknown): T;
246
+
247
+ /**
248
+ * @internal
249
+ */
250
+ export function assertEquals(): never {
251
+ halt("assertEquals");
252
+ }
253
+ Object.assign(assertEquals, Namespace.assert("assertEquals"));
254
+
255
+ /**
256
+ * Tests equality between a value and its type.
257
+ *
258
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
259
+ * or not. If the parametric value is matched with the type `T` and there's not any
260
+ * superfluous property that is not listed on the type `T`, `true` value would be
261
+ * returned. Otherwise, the parametric value is not following the type `T` or some
262
+ * superfluous property exists, `false` value would be returned.
263
+ *
264
+ * If what you want is not just knowing whether the parametric value is following the
265
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
266
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
267
+ * detailed reasons, {@link validateEquals} function would be useful.
268
+ *
269
+ * On the other hand, if you want to allow superfluous property that is not enrolled
270
+ * to the type `T`, you can use {@link is} function instead.
271
+ *
272
+ * @template T Type of the input value
273
+ * @param input A value to be tested
274
+ * @returns Whether the parametric value is equivalent to the type `T` or not
275
+ *
276
+ * @author Jeongho Nam - https://github.com/samchon
277
+ */
278
+ export function equals<T>(input: T): input is T;
279
+
280
+ /**
281
+ * Tests equality between a value and its type.
282
+ *
283
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
284
+ * or not. If the parametric value is matched with the type `T` and there's not any
285
+ * superfluous property that is not listed on the type `T`, `true` value would be
286
+ * returned. Otherwise, the parametric value is not following the type `T` or some
287
+ * superfluous property exists, `false` value would be returned.
288
+ *
289
+ * If what you want is not just knowing whether the parametric value is following the
290
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
291
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
292
+ * detailed reasons, {@link validateEquals} function would be useful.
293
+ *
294
+ * On the other hand, if you want to allow superfluous property that is not enrolled
295
+ * to the type `T`, you can use {@link is} function instead.
296
+ *
297
+ * @template T Type of the input value
298
+ * @param input A value to be tested
299
+ * @returns Whether the parametric value is equivalent to the type `T` or not
300
+ *
301
+ * @author Jeongho Nam - https://github.com/samchon
302
+ */
303
+ export function equals<T>(input: unknown): input is T;
304
+
305
+ /**
306
+ * @internal
307
+ */
308
+ export function equals(): never {
309
+ halt("equals");
310
+ }
311
+ Object.assign(equals, Namespace.is());
312
+
313
+ /**
314
+ * Validates equality between a value and its type.
315
+ *
316
+ * Validates a parametric value type and archives all the type errors into an
317
+ * {@link IValidation.errors} array, if the parametric value is not following the
318
+ * type `T` or some superfluous property that is not listed on the type `T` has been
319
+ * found. Of course, if the parametric value is following the type `T` and no
320
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
321
+ * and {@link IValidation.success} would have the `true` value.
322
+ *
323
+ * If what you want is not finding all the error, but asserting the parametric value
324
+ * type with exception throwing, you can choose {@link assert} function instead.
325
+ * Otherwise, you just want to know whether the parametric value is matched with the
326
+ * type `T`, {@link is} function is the way to go.
327
+ *
328
+ * On the other and, if you don't want to allow any superfluous property that is not
329
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
330
+ *
331
+ * @template Type of the input value
332
+ * @param input A value to be validated
333
+ * @returns Validation result
334
+ *
335
+ * @author Jeongho Nam - https://github.com/samchon
336
+ */
337
+ export function validateEquals<T>(input: T): IValidation<T>;
338
+
339
+ /**
340
+ * Validates equality between a value and its type.
341
+ *
342
+ * Validates a parametric value type and archives all the type errors into an
343
+ * {@link IValidation.errors} array, if the parametric value is not following the
344
+ * type `T` or some superfluous property that is not listed on the type `T` has been
345
+ * found. Of course, if the parametric value is following the type `T` and no
346
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
347
+ * and {@link IValidation.success} would have the `true` value.
348
+ *
349
+ * If what you want is not finding all the error, but asserting the parametric value
350
+ * type with exception throwing, you can choose {@link assert} function instead.
351
+ * Otherwise, you just want to know whether the parametric value is matched with the
352
+ * type `T`, {@link is} function is the way to go.
353
+ *
354
+ * On the other and, if you don't want to allow any superfluous property that is not
355
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
356
+ *
357
+ * @template Type of the input value
358
+ * @param input A value to be validated
359
+ * @returns Validation result
360
+ *
361
+ * @author Jeongho Nam - https://github.com/samchon
362
+ */
363
+ export function validateEquals<T>(input: unknown): IValidation<T>;
364
+
365
+ /**
366
+ * @internal
367
+ */
368
+ export function validateEquals(): never {
369
+ halt("validateEquals");
370
+ }
371
+ Object.assign(validateEquals, Namespace.validate());
372
+
373
+ /* -----------------------------------------------------------
374
+ RANDOM
375
+ ----------------------------------------------------------- */
376
+ /**
377
+ * > You must configure the generic argument `T`.
378
+ *
379
+ * Generate random data.
380
+ *
381
+ * Generates a random data following type the `T`.
382
+ *
383
+ * For reference, this `typia.random()` function generates only primitive type.
384
+ * If there're some methods in the type `T` or its nested instances, those would
385
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
386
+ * would be generated instead.
387
+ *
388
+ * @template T Type of data to generate
389
+ * @param generator Random data generator
390
+ * @return Randomly generated data
391
+ *
392
+ * @author Jeongho Nam - https://github.com/samchon
393
+ */
394
+ export function random(generator?: Partial<IRandomGenerator>): never;
395
+
396
+ /**
397
+ * Generate random data.
398
+ *
399
+ * Generates a random data following type the `T`.
400
+ *
401
+ * For reference, this `typia.random()` function generates only primitive type.
402
+ * If there're some methods in the type `T` or its nested instances, those would
403
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
404
+ * would be generated instead.
405
+ *
406
+ * @template T Type of data to generate
407
+ * @param generator Random data generator
408
+ * @return Randomly generated data
409
+ *
410
+ * @author Jeongho Nam - https://github.com/samchon
411
+ */
412
+ export function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;
413
+
414
+ /**
415
+ * @internal
416
+ */
417
+ export function random(): never {
418
+ halt("random");
419
+ }
420
+ Object.assign(random, Namespace.random());
421
+
422
+ /**
423
+ * @internal
424
+ */
425
+ export function metadata(): never;
426
+
427
+ /**
428
+ * @internal
429
+ */
430
+ export function metadata<Types extends unknown[]>(): IMetadataApplication;
431
+
432
+ /**
433
+ * @internal
434
+ */
435
+ export function metadata(): never {
436
+ halt("metadata");
437
+ }
438
+
439
+ /* -----------------------------------------------------------
440
+ FACTORY FUNCTIONS
441
+ ----------------------------------------------------------- */
442
+ /**
443
+ * Creates a reusable {@link assert} function.
444
+ *
445
+ * @danger You must configure the generic argument `T`
446
+ * @returns Nothing until you configure the generic argument `T`
447
+ * @throws compile error
448
+ *
449
+ * @author Jeongho Nam - https://github.com/samchon
450
+ */
451
+ export function createAssert(): never;
452
+
453
+ /**
454
+ * Creates a reusable {@link assert} function.
455
+ *
456
+ * @template T Type of the input value
457
+ * @returns A reusable `assert` function
458
+ *
459
+ * @author Jeongho Nam - https://github.com/samchon
460
+ */
461
+ export function createAssert<T>(): (input: unknown) => T;
462
+
463
+ /**
464
+ * @internal
465
+ */
466
+ export function createAssert<T>(): (input: unknown) => T {
467
+ halt("createAssert");
468
+ }
469
+ Object.assign(createAssert, assert);
470
+
471
+ /**
472
+ * Creates a reusable {@link is} function.
473
+ *
474
+ * @danger You must configure the generic argument `T`
475
+ * @returns Nothing until you configure the generic argument `T`
476
+ * @throws compile error
477
+ *
478
+ * @author Jeongho Nam - https://github.com/samchon
479
+ */
480
+ export function createIs(): never;
481
+
482
+ /**
483
+ * Creates a reusable {@link is} function.
484
+ *
485
+ * @template T Type of the input value
486
+ * @returns A reusable `is` function
487
+ *
488
+ * @author Jeongho Nam - https://github.com/samchon
489
+ */
490
+ export function createIs<T>(): (input: unknown) => input is T;
491
+
492
+ /**
493
+ * @internal
494
+ */
495
+ export function createIs<T>(): (input: unknown) => input is T {
496
+ halt("createIs");
497
+ }
498
+ Object.assign(createIs, is);
499
+
500
+ /**
501
+ * Creates a reusable {@link validate} function.
502
+ *
503
+ * @danger You must configure the generic argument `T`
504
+ * @returns Nothing until you configure the generic argument `T`
505
+ * @throws compile error
506
+ *
507
+ * @author Jeongho Nam - https://github.com/samchon
508
+ */
509
+ export function createValidate(): never;
510
+
511
+ /**
512
+ * Creates a reusable {@link validate} function.
513
+ *
514
+ * @template T Type of the input value
515
+ * @returns A reusable `validate` function
516
+ *
517
+ * @author Jeongho Nam - https://github.com/samchon
518
+ */
519
+ export function createValidate<T>(): (input: unknown) => IValidation<T>;
520
+
521
+ /**
522
+ * @internal
523
+ */
524
+ export function createValidate(): (input: unknown) => IValidation {
525
+ halt("createValidate");
526
+ }
527
+ Object.assign(createValidate, validate);
528
+
529
+ /**
530
+ * Creates a reusable {@link assertEquals} function.
531
+ *
532
+ * @danger You must configure the generic argument `T`
533
+ * @returns Nothing until you configure the generic argument `T`
534
+ * @throws compile error
535
+ *
536
+ * @author Jeongho Nam - https://github.com/samchon
537
+ */
538
+ export function createAssertEquals(): never;
539
+
540
+ /**
541
+ * Creates a reusable {@link assertEquals} function.
542
+ *
543
+ * @template T Type of the input value
544
+ * @returns A reusable `assertEquals` function
545
+ *
546
+ * @author Jeongho Nam - https://github.com/samchon
547
+ */
548
+ export function createAssertEquals<T>(): (input: unknown) => T;
549
+
550
+ /**
551
+ * @internal
552
+ */
553
+ export function createAssertEquals<T>(): (input: unknown) => T {
554
+ halt("createAssertEquals");
555
+ }
556
+ Object.assign(createAssertEquals, assertEquals);
557
+
558
+ /**
559
+ * Creates a reusable {@link equals} function.
560
+ *
561
+ * @danger You must configure the generic argument `T`
562
+ * @returns Nothing until you configure the generic argument `T`
563
+ * @throws compile error
564
+ *
565
+ * @author Jeongho Nam - https://github.com/samchon
566
+ */
567
+ export function createEquals(): never;
568
+
569
+ /**
570
+ * Creates a reusable {@link equals} function.
571
+ *
572
+ * @template T Type of the input value
573
+ * @returns A reusable `equals` function
574
+ *
575
+ * @author Jeongho Nam - https://github.com/samchon
576
+ */
577
+ export function createEquals<T>(): (input: unknown) => input is T;
578
+
579
+ /**
580
+ * @internal
581
+ */
582
+ export function createEquals<T>(): (input: unknown) => input is T {
583
+ halt("createEquals");
584
+ }
585
+ Object.assign(createEquals, equals);
586
+
587
+ /**
588
+ * Creates a reusable {@link validateEquals} function.
589
+ *
590
+ * @danger You must configure the generic argument `T`
591
+ * @returns Nothing until you configure the generic argument `T`
592
+ * @throws compile error
593
+ *
594
+ * @author Jeongho Nam - https://github.com/samchon
595
+ */
596
+ export function createValidateEquals(): never;
597
+
598
+ /**
599
+ * Creates a reusable {@link validateEquals} function.
600
+ *
601
+ * @template T Type of the input value
602
+ * @returns A reusable `validateEquals` function
603
+ *
604
+ * @author Jeongho Nam - https://github.com/samchon
605
+ */
606
+ export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
607
+
608
+ /**
609
+ * @internal
610
+ */
611
+ export function createValidateEquals(): (input: unknown) => IValidation {
612
+ halt("createValidateEquals");
613
+ }
614
+ Object.assign(createValidateEquals, validateEquals);
615
+
616
+ /**
617
+ * Creates a reusable {@link random} function.
618
+ *
619
+ * @danger You must configure the generic argument `T`
620
+ * @param generator Random data generator
621
+ * @returns Nothing until you configure the generic argument `T`
622
+ * @throws compile error
623
+ *
624
+ * @author Jeongho Nam - https://github.com/samchon
625
+ */
626
+ export function createRandom(generator?: Partial<IRandomGenerator>): never;
627
+
628
+ /**
629
+ * Creates a resuable {@link random} function.
630
+ *
631
+ * @template T Type of the input value
632
+ * @param generator Random data generator
633
+ * @returns A reusable `random` function
634
+ *
635
+ * @author Jeongho Nam - https://github.com/samchon
636
+ */
637
+ export function createRandom<T>(
638
+ generator?: Partial<IRandomGenerator>,
639
+ ): () => Resolved<T>;
640
+
641
+ /**
642
+ * @internal
643
+ */
644
+ export function createRandom(): never {
645
+ halt("createRandom");
646
+ }
647
+ Object.assign(createRandom, random);
648
+
649
+ /**
650
+ * @internal
651
+ */
652
+ function halt(name: string): never {
653
+ throw new Error(
654
+ `Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
655
+ );
656
+ }