typia 5.0.0-dev.20230711 → 5.0.0-dev.20230713

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 (381) hide show
  1. package/lib/functional/$number.js +2 -2
  2. package/lib/functional/$number.js.map +1 -1
  3. package/lib/json.d.ts +455 -0
  4. package/lib/json.js +85 -0
  5. package/lib/json.js.map +1 -0
  6. package/lib/misc.d.ts +442 -0
  7. package/lib/misc.js +98 -0
  8. package/lib/misc.js.map +1 -0
  9. package/lib/module.d.ts +132 -1024
  10. package/lib/module.js +32 -189
  11. package/lib/module.js.map +1 -1
  12. package/lib/programmers/IsPruneProgrammer.js +2 -2
  13. package/lib/programmers/IsPruneProgrammer.js.map +1 -1
  14. package/lib/programmers/internal/application_alias.d.ts +2 -2
  15. package/lib/programmers/internal/application_alias.js.map +1 -1
  16. package/lib/programmers/internal/application_array.js.map +1 -1
  17. package/lib/programmers/internal/application_native.js.map +1 -1
  18. package/lib/programmers/internal/application_object.js.map +1 -1
  19. package/lib/programmers/internal/application_resolved.d.ts +2 -2
  20. package/lib/programmers/internal/application_resolved.js.map +1 -1
  21. package/lib/programmers/internal/application_schema.js.map +1 -1
  22. package/lib/programmers/internal/application_tuple.js.map +1 -1
  23. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +8 -0
  24. package/lib/programmers/{ApplicationProgrammer.js → json/JsonApplicationProgrammer.js} +8 -8
  25. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -0
  26. package/lib/programmers/{AssertStringifyProgrammer.d.ts → json/JsonAssertParseProgrammer.d.ts} +2 -2
  27. package/lib/programmers/{AssertParseProgrammer.js → json/JsonAssertParseProgrammer.js} +10 -10
  28. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -0
  29. package/lib/programmers/json/JsonAssertStringifyProgrammer.d.ts +5 -0
  30. package/lib/programmers/{AssertStringifyProgrammer.js → json/JsonAssertStringifyProgrammer.js} +12 -12
  31. package/lib/programmers/json/JsonAssertStringifyProgrammer.js.map +1 -0
  32. package/lib/programmers/{IsCloneProgrammer.d.ts → json/JsonIsParseProgrammer.d.ts} +2 -2
  33. package/lib/programmers/{IsParseProgrammer.js → json/JsonIsParseProgrammer.js} +10 -10
  34. package/lib/programmers/json/JsonIsParseProgrammer.js.map +1 -0
  35. package/lib/programmers/{IsStringifyProgrammer.d.ts → json/JsonIsStringifyProgrammer.d.ts} +1 -1
  36. package/lib/programmers/{IsStringifyProgrammer.js → json/JsonIsStringifyProgrammer.js} +7 -7
  37. package/lib/programmers/json/JsonIsStringifyProgrammer.js.map +1 -0
  38. package/lib/programmers/{StringifyProgrammer.d.ts → json/JsonStringifyProgrammer.d.ts} +2 -2
  39. package/lib/programmers/{StringifyProgrammer.js → json/JsonStringifyProgrammer.js} +30 -30
  40. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -0
  41. package/lib/programmers/json/JsonValidateParseProgrammer.d.ts +5 -0
  42. package/lib/programmers/{ValidateParseProgrammer.js → json/JsonValidateParseProgrammer.js} +10 -10
  43. package/lib/programmers/json/JsonValidateParseProgrammer.js.map +1 -0
  44. package/lib/programmers/json/JsonValidateStringifyProgrammer.d.ts +5 -0
  45. package/lib/programmers/{ValidateStringifyProgrammer.js → json/JsonValidateStringifyProgrammer.js} +12 -12
  46. package/lib/programmers/json/JsonValidateStringifyProgrammer.js.map +1 -0
  47. package/lib/programmers/{AssertPruneProgrammer.d.ts → misc/MiscAssertCloneProgrammer.d.ts} +2 -2
  48. package/lib/programmers/{AssertCloneProgrammer.js → misc/MiscAssertCloneProgrammer.js} +12 -12
  49. package/lib/programmers/misc/MiscAssertCloneProgrammer.js.map +1 -0
  50. package/lib/programmers/{AssertCloneProgrammer.d.ts → misc/MiscAssertPruneProgrammer.d.ts} +2 -2
  51. package/lib/programmers/{AssertPruneProgrammer.js → misc/MiscAssertPruneProgrammer.js} +12 -12
  52. package/lib/programmers/misc/MiscAssertPruneProgrammer.js.map +1 -0
  53. package/lib/programmers/{CloneProgrammer.d.ts → misc/MiscCloneProgrammer.d.ts} +2 -2
  54. package/lib/programmers/{CloneProgrammer.js → misc/MiscCloneProgrammer.js} +20 -20
  55. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -0
  56. package/lib/programmers/{AssertParseProgrammer.d.ts → misc/MiscIsCloneProgrammer.d.ts} +2 -2
  57. package/lib/programmers/{IsCloneProgrammer.js → misc/MiscIsCloneProgrammer.js} +12 -12
  58. package/lib/programmers/misc/MiscIsCloneProgrammer.js.map +1 -0
  59. package/lib/programmers/{LiteralsProgrammer.d.ts → misc/MiscLiteralsProgrammer.d.ts} +2 -2
  60. package/lib/programmers/{LiteralsProgrammer.js → misc/MiscLiteralsProgrammer.js} +12 -11
  61. package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -0
  62. package/lib/programmers/{PruneProgrammer.d.ts → misc/MiscPruneProgrammer.d.ts} +2 -2
  63. package/lib/programmers/{PruneProgrammer.js → misc/MiscPruneProgrammer.js} +20 -20
  64. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -0
  65. package/lib/programmers/misc/MiscValidateCloneProgrammer.d.ts +5 -0
  66. package/lib/programmers/{ValidateCloneProgrammer.js → misc/MiscValidateCloneProgrammer.js} +12 -12
  67. package/lib/programmers/misc/MiscValidateCloneProgrammer.js.map +1 -0
  68. package/lib/programmers/misc/MiscValidatePruneProgrammer.d.ts +5 -0
  69. package/lib/programmers/{ValidatePruneProgrammer.js → misc/MiscValidatePruneProgrammer.js} +12 -12
  70. package/lib/programmers/misc/MiscValidatePruneProgrammer.js.map +1 -0
  71. package/lib/programmers/{MessageProgrammer.d.ts → protobuf/ProtobufMessageProgrammer.d.ts} +2 -2
  72. package/lib/programmers/{MessageProgrammer.js → protobuf/ProtobufMessageProgrammer.js} +11 -11
  73. package/lib/programmers/protobuf/ProtobufMessageProgrammer.js.map +1 -0
  74. package/lib/protobuf.d.ts +2 -0
  75. package/lib/protobuf.js +11 -0
  76. package/lib/protobuf.js.map +1 -0
  77. package/lib/transformers/CallExpressionTransformer.js +122 -103
  78. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  79. package/lib/transformers/features/AssertTransformer.d.ts +3 -0
  80. package/lib/transformers/features/{validators/AssertTransformer.js → AssertTransformer.js} +2 -2
  81. package/lib/transformers/features/AssertTransformer.js.map +1 -0
  82. package/lib/transformers/features/CreateAssertTransformer.d.ts +3 -0
  83. package/lib/transformers/features/{validators/CreateAssertTransformer.js → CreateAssertTransformer.js} +2 -2
  84. package/lib/transformers/features/CreateAssertTransformer.js.map +1 -0
  85. package/lib/transformers/features/CreateIsTransformer.d.ts +3 -0
  86. package/lib/transformers/features/{validators/CreateIsTransformer.js → CreateIsTransformer.js} +2 -2
  87. package/lib/transformers/features/CreateIsTransformer.js.map +1 -0
  88. package/lib/transformers/features/{miscellaneous/CreateRandomTransformer.d.ts → CreateRandomTransformer.d.ts} +1 -1
  89. package/lib/transformers/features/{miscellaneous/CreateRandomTransformer.js → CreateRandomTransformer.js} +1 -1
  90. package/lib/transformers/features/CreateRandomTransformer.js.map +1 -0
  91. package/lib/transformers/features/CreateValidateTransformer.d.ts +3 -0
  92. package/lib/transformers/features/{validators/CreateValidateTransformer.js → CreateValidateTransformer.js} +2 -2
  93. package/lib/transformers/features/CreateValidateTransformer.js.map +1 -0
  94. package/lib/transformers/features/IsTransformer.d.ts +3 -0
  95. package/lib/transformers/features/{validators/IsTransformer.js → IsTransformer.js} +2 -2
  96. package/lib/transformers/features/IsTransformer.js.map +1 -0
  97. package/lib/transformers/features/{miscellaneous/RandomTransformer.d.ts → RandomTransformer.d.ts} +1 -1
  98. package/lib/transformers/features/{miscellaneous/RandomTransformer.js → RandomTransformer.js} +1 -1
  99. package/lib/transformers/features/RandomTransformer.js.map +1 -0
  100. package/lib/transformers/features/ValidateTransformer.d.ts +3 -0
  101. package/lib/transformers/features/{validators/ValidateTransformer.js → ValidateTransformer.js} +2 -2
  102. package/lib/transformers/features/ValidateTransformer.js.map +1 -0
  103. package/lib/transformers/features/{parsers → json}/AssertParseTransformer.js +4 -2
  104. package/lib/transformers/features/json/AssertParseTransformer.js.map +1 -0
  105. package/lib/transformers/features/{stringifiers → json}/AssertStringifyTransformer.js +2 -2
  106. package/lib/transformers/features/json/AssertStringifyTransformer.js.map +1 -0
  107. package/lib/transformers/features/{parsers → json}/CreateAssertParseTransformer.js +4 -2
  108. package/lib/transformers/features/json/CreateAssertParseTransformer.js.map +1 -0
  109. package/lib/transformers/features/{stringifiers → json}/CreateAssertStringifyTransformer.js +2 -2
  110. package/lib/transformers/features/json/CreateAssertStringifyTransformer.js.map +1 -0
  111. package/lib/transformers/features/{parsers → json}/CreateIsParseTransformer.js +2 -2
  112. package/lib/transformers/features/json/CreateIsParseTransformer.js.map +1 -0
  113. package/lib/transformers/features/{stringifiers → json}/CreateIsStringifyTransformer.js +2 -2
  114. package/lib/transformers/features/json/CreateIsStringifyTransformer.js.map +1 -0
  115. package/lib/transformers/features/{stringifiers → json}/CreateStringifyTransformer.js +2 -2
  116. package/lib/transformers/features/json/CreateStringifyTransformer.js.map +1 -0
  117. package/lib/transformers/features/{parsers → json}/CreateValidateParseTransformer.js +4 -2
  118. package/lib/transformers/features/json/CreateValidateParseTransformer.js.map +1 -0
  119. package/lib/transformers/features/{stringifiers → json}/CreateValidateStringifyProgrammer.js +2 -2
  120. package/lib/transformers/features/json/CreateValidateStringifyProgrammer.js.map +1 -0
  121. package/lib/transformers/features/{parsers → json}/IsParseTransformer.js +2 -2
  122. package/lib/transformers/features/json/IsParseTransformer.js.map +1 -0
  123. package/lib/transformers/features/{stringifiers → json}/IsStringifyTransformer.js +2 -2
  124. package/lib/transformers/features/json/IsStringifyTransformer.js.map +1 -0
  125. package/lib/transformers/features/{stringifiers → json}/StringifyTransformer.js +2 -2
  126. package/lib/transformers/features/json/StringifyTransformer.js.map +1 -0
  127. package/lib/transformers/features/{parsers → json}/ValidateParseTransformer.js +4 -2
  128. package/lib/transformers/features/json/ValidateParseTransformer.js.map +1 -0
  129. package/lib/transformers/features/{stringifiers → json}/ValidateStringifyTransformer.js +2 -2
  130. package/lib/transformers/features/json/ValidateStringifyTransformer.js.map +1 -0
  131. package/lib/transformers/features/{miscellaneous → misc}/ApplicationTransformer.js +2 -2
  132. package/lib/transformers/features/misc/ApplicationTransformer.js.map +1 -0
  133. package/lib/transformers/features/{miscellaneous → misc}/AssertCloneTransformer.js +4 -2
  134. package/lib/transformers/features/misc/AssertCloneTransformer.js.map +1 -0
  135. package/lib/transformers/features/{miscellaneous → misc}/AssertPruneTransformer.js +4 -2
  136. package/lib/transformers/features/misc/AssertPruneTransformer.js.map +1 -0
  137. package/lib/transformers/features/{miscellaneous → misc}/CloneTransformer.js +2 -2
  138. package/lib/transformers/features/misc/CloneTransformer.js.map +1 -0
  139. package/lib/transformers/features/{miscellaneous → misc}/CreateAssertCloneTransformer.js +4 -2
  140. package/lib/transformers/features/misc/CreateAssertCloneTransformer.js.map +1 -0
  141. package/lib/transformers/features/{miscellaneous → misc}/CreateAssertPruneTransformer.js +4 -2
  142. package/lib/transformers/features/misc/CreateAssertPruneTransformer.js.map +1 -0
  143. package/lib/transformers/features/{miscellaneous → misc}/CreateCloneTransformer.js +2 -2
  144. package/lib/transformers/features/misc/CreateCloneTransformer.js.map +1 -0
  145. package/lib/transformers/features/{miscellaneous → misc}/CreateIsCloneTransformer.js +2 -2
  146. package/lib/transformers/features/misc/CreateIsCloneTransformer.js.map +1 -0
  147. package/lib/transformers/features/misc/CreateIsPruneTransformer.js.map +1 -0
  148. package/lib/transformers/features/{miscellaneous → misc}/CreatePruneTransformer.js +2 -2
  149. package/lib/transformers/features/misc/CreatePruneTransformer.js.map +1 -0
  150. package/lib/transformers/features/{miscellaneous → misc}/CreateValidateCloneTransformer.js +4 -2
  151. package/lib/transformers/features/misc/CreateValidateCloneTransformer.js.map +1 -0
  152. package/lib/transformers/features/{miscellaneous → misc}/CreateValidatePruneTransformer.js +4 -2
  153. package/lib/transformers/features/misc/CreateValidatePruneTransformer.js.map +1 -0
  154. package/lib/transformers/features/{miscellaneous → misc}/IsCloneTransformer.js +2 -2
  155. package/lib/transformers/features/misc/IsCloneTransformer.js.map +1 -0
  156. package/lib/transformers/features/misc/IsPruneTransformer.js.map +1 -0
  157. package/lib/transformers/features/{miscellaneous → misc}/LiteralsTransformer.js +2 -2
  158. package/lib/transformers/features/misc/LiteralsTransformer.js.map +1 -0
  159. package/lib/transformers/features/misc/MetadataTransformer.js.map +1 -0
  160. package/lib/transformers/features/{miscellaneous → misc}/PruneTransformer.js +2 -2
  161. package/lib/transformers/features/misc/PruneTransformer.js.map +1 -0
  162. package/lib/transformers/features/{miscellaneous → misc}/ValidateCloneTransformer.js +4 -2
  163. package/lib/transformers/features/misc/ValidateCloneTransformer.js.map +1 -0
  164. package/lib/transformers/features/{miscellaneous → misc}/ValidatePruneTransformer.js +4 -2
  165. package/lib/transformers/features/misc/ValidatePruneTransformer.js.map +1 -0
  166. package/lib/transformers/features/{protocols → protobuf}/MessageTransformer.js +2 -2
  167. package/lib/transformers/features/protobuf/MessageTransformer.js.map +1 -0
  168. package/package.json +1 -1
  169. package/src/factories/MetadataTagFactory.ts +362 -362
  170. package/src/factories/ProtocolFactory.ts +80 -80
  171. package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +180 -180
  172. package/src/factories/internal/protocols/emplace_protocol_object.ts +25 -25
  173. package/src/factories/internal/protocols/emplace_protocol_property.ts +12 -12
  174. package/src/factories/internal/protocols/iterate_protocol_atomic.ts +34 -34
  175. package/src/factories/internal/protocols/iterate_protocol_constant.ts +27 -27
  176. package/src/factories/internal/protocols/iterate_protocol_main.ts +19 -19
  177. package/src/factories/internal/protocols/iterate_protocol_map.ts +58 -58
  178. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +96 -96
  179. package/src/factories/internal/protocols/iterate_protocol_native.ts +34 -34
  180. package/src/factories/internal/protocols/iterate_protocol_never.ts +1 -1
  181. package/src/factories/internal/protocols/iterate_protocol_object.ts +110 -110
  182. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +34 -34
  183. package/src/factories/internal/protocols/iterate_protocol_tuple.ts +29 -29
  184. package/src/functional/$number.ts +3 -2
  185. package/src/functional/$proto_bytes.ts +25 -25
  186. package/src/functional/$proto_field.ts +30 -30
  187. package/src/functional/$proto_float.ts +37 -37
  188. package/src/functional/$proto_i32.ts +29 -29
  189. package/src/functional/$proto_i64.ts +37 -37
  190. package/src/functional/$proto_size.ts +82 -82
  191. package/src/functional/$proto_string.ts +24 -24
  192. package/src/functional/$varint.ts +130 -130
  193. package/src/functional/$zigzag.ts +39 -39
  194. package/src/json.ts +648 -0
  195. package/src/messages/IProtocolMap.ts +5 -5
  196. package/src/messages/IProtocolMessage.ts +6 -6
  197. package/src/messages/IProtocolProperty.ts +13 -13
  198. package/src/metadata/IMetadataTag.ts +113 -113
  199. package/src/metadata/Metadata.ts +606 -606
  200. package/src/misc.ts +651 -0
  201. package/src/module.ts +781 -2049
  202. package/src/programmers/IsPruneProgrammer.ts +2 -2
  203. package/src/programmers/internal/application_alias.ts +2 -2
  204. package/src/programmers/internal/application_array.ts +2 -2
  205. package/src/programmers/internal/application_native.ts +2 -2
  206. package/src/programmers/internal/application_number.ts +77 -77
  207. package/src/programmers/internal/application_object.ts +3 -3
  208. package/src/programmers/internal/application_resolved.ts +2 -2
  209. package/src/programmers/internal/application_schema.ts +2 -2
  210. package/src/programmers/internal/application_tuple.ts +2 -2
  211. package/src/programmers/{ApplicationProgrammer.ts → json/JsonApplicationProgrammer.ts} +6 -6
  212. package/src/programmers/{AssertParseProgrammer.ts → json/JsonAssertParseProgrammer.ts} +6 -6
  213. package/src/programmers/{AssertStringifyProgrammer.ts → json/JsonAssertStringifyProgrammer.ts} +8 -8
  214. package/src/programmers/{IsParseProgrammer.ts → json/JsonIsParseProgrammer.ts} +6 -6
  215. package/src/programmers/{IsStringifyProgrammer.ts → json/JsonIsStringifyProgrammer.ts} +7 -7
  216. package/src/programmers/{StringifyProgrammer.ts → json/JsonStringifyProgrammer.ts} +40 -39
  217. package/src/programmers/{ValidateParseProgrammer.ts → json/JsonValidateParseProgrammer.ts} +6 -6
  218. package/src/programmers/{ValidateStringifyProgrammer.ts → json/JsonValidateStringifyProgrammer.ts} +8 -8
  219. package/src/programmers/{AssertCloneProgrammer.ts → misc/MiscAssertCloneProgrammer.ts} +8 -8
  220. package/src/programmers/{AssertPruneProgrammer.ts → misc/MiscAssertPruneProgrammer.ts} +8 -8
  221. package/src/programmers/{CloneProgrammer.ts → misc/MiscCloneProgrammer.ts} +24 -24
  222. package/src/programmers/{IsCloneProgrammer.ts → misc/MiscIsCloneProgrammer.ts} +8 -8
  223. package/src/programmers/{LiteralsProgrammer.ts → misc/MiscLiteralsProgrammer.ts} +63 -62
  224. package/src/programmers/{PruneProgrammer.ts → misc/MiscPruneProgrammer.ts} +24 -24
  225. package/src/programmers/{ValidateCloneProgrammer.ts → misc/MiscValidateCloneProgrammer.ts} +8 -8
  226. package/src/programmers/{ValidatePruneProgrammer.ts → misc/MiscValidatePruneProgrammer.ts} +8 -8
  227. package/src/programmers/{MessageProgrammer.ts → protobuf/ProtobufMessageProgrammer.ts} +126 -126
  228. package/src/protobuf.ts +18 -0
  229. package/src/transformers/CallExpressionTransformer.ts +196 -186
  230. package/src/transformers/features/{validators/AssertTransformer.ts → AssertTransformer.ts} +2 -2
  231. package/src/transformers/features/{validators/CreateAssertTransformer.ts → CreateAssertTransformer.ts} +2 -2
  232. package/src/transformers/features/{validators/CreateIsTransformer.ts → CreateIsTransformer.ts} +2 -2
  233. package/src/transformers/features/{miscellaneous/CreateRandomTransformer.ts → CreateRandomTransformer.ts} +2 -2
  234. package/src/transformers/features/{validators/CreateValidateTransformer.ts → CreateValidateTransformer.ts} +2 -2
  235. package/src/transformers/features/{validators/IsTransformer.ts → IsTransformer.ts} +2 -2
  236. package/src/transformers/features/{miscellaneous/RandomTransformer.ts → RandomTransformer.ts} +2 -2
  237. package/src/transformers/features/{validators/ValidateTransformer.ts → ValidateTransformer.ts} +2 -2
  238. package/src/transformers/features/{parsers → json}/AssertParseTransformer.ts +3 -2
  239. package/src/transformers/features/{stringifiers → json}/AssertStringifyTransformer.ts +2 -2
  240. package/src/transformers/features/{parsers → json}/CreateAssertParseTransformer.ts +3 -2
  241. package/src/transformers/features/{stringifiers → json}/CreateAssertStringifyTransformer.ts +2 -2
  242. package/src/transformers/features/{parsers → json}/CreateIsParseTransformer.ts +2 -2
  243. package/src/transformers/features/{stringifiers → json}/CreateIsStringifyTransformer.ts +1 -1
  244. package/src/transformers/features/{stringifiers → json}/CreateStringifyTransformer.ts +2 -2
  245. package/src/transformers/features/{parsers → json}/CreateValidateParseTransformer.ts +3 -2
  246. package/src/transformers/features/{stringifiers → json}/CreateValidateStringifyProgrammer.ts +2 -2
  247. package/src/transformers/features/{parsers → json}/IsParseTransformer.ts +2 -2
  248. package/src/transformers/features/{stringifiers → json}/IsStringifyTransformer.ts +1 -1
  249. package/src/transformers/features/{stringifiers → json}/StringifyTransformer.ts +2 -2
  250. package/src/transformers/features/{parsers → json}/ValidateParseTransformer.ts +3 -2
  251. package/src/transformers/features/{stringifiers → json}/ValidateStringifyTransformer.ts +2 -2
  252. package/src/transformers/features/{miscellaneous → misc}/ApplicationTransformer.ts +102 -102
  253. package/src/transformers/features/{miscellaneous → misc}/AssertCloneTransformer.ts +3 -2
  254. package/src/transformers/features/{miscellaneous → misc}/AssertPruneTransformer.ts +3 -2
  255. package/src/transformers/features/{miscellaneous → misc}/CloneTransformer.ts +2 -2
  256. package/src/transformers/features/{miscellaneous → misc}/CreateAssertCloneTransformer.ts +3 -2
  257. package/src/transformers/features/{miscellaneous → misc}/CreateAssertPruneTransformer.ts +3 -2
  258. package/src/transformers/features/{miscellaneous → misc}/CreateCloneTransformer.ts +2 -2
  259. package/src/transformers/features/{miscellaneous → misc}/CreateIsCloneTransformer.ts +2 -2
  260. package/src/transformers/features/{miscellaneous → misc}/CreatePruneTransformer.ts +2 -2
  261. package/src/transformers/features/{miscellaneous → misc}/CreateValidateCloneTransformer.ts +3 -2
  262. package/src/transformers/features/{miscellaneous → misc}/CreateValidatePruneTransformer.ts +3 -2
  263. package/src/transformers/features/{miscellaneous → misc}/IsCloneTransformer.ts +2 -2
  264. package/src/transformers/features/{miscellaneous → misc}/LiteralsTransformer.ts +2 -2
  265. package/src/transformers/features/{miscellaneous → misc}/PruneTransformer.ts +2 -2
  266. package/src/transformers/features/{miscellaneous → misc}/ValidateCloneTransformer.ts +3 -2
  267. package/src/transformers/features/{miscellaneous → misc}/ValidatePruneTransformer.ts +3 -2
  268. package/src/transformers/features/{protocols → protobuf}/MessageTransformer.ts +31 -31
  269. package/src/utils/Escaper.ts +46 -46
  270. package/src/utils/NameEncoder.ts +32 -32
  271. package/lib/programmers/ApplicationProgrammer.d.ts +0 -8
  272. package/lib/programmers/ApplicationProgrammer.js.map +0 -1
  273. package/lib/programmers/AssertCloneProgrammer.js.map +0 -1
  274. package/lib/programmers/AssertParseProgrammer.js.map +0 -1
  275. package/lib/programmers/AssertPruneProgrammer.js.map +0 -1
  276. package/lib/programmers/AssertStringifyProgrammer.js.map +0 -1
  277. package/lib/programmers/CloneProgrammer.js.map +0 -1
  278. package/lib/programmers/IsCloneProgrammer.js.map +0 -1
  279. package/lib/programmers/IsParseProgrammer.d.ts +0 -5
  280. package/lib/programmers/IsParseProgrammer.js.map +0 -1
  281. package/lib/programmers/IsStringifyProgrammer.js.map +0 -1
  282. package/lib/programmers/LiteralsProgrammer.js.map +0 -1
  283. package/lib/programmers/MessageProgrammer.js.map +0 -1
  284. package/lib/programmers/PruneProgrammer.js.map +0 -1
  285. package/lib/programmers/StringifyProgrammer.js.map +0 -1
  286. package/lib/programmers/ValidateCloneProgrammer.d.ts +0 -5
  287. package/lib/programmers/ValidateCloneProgrammer.js.map +0 -1
  288. package/lib/programmers/ValidateParseProgrammer.d.ts +0 -5
  289. package/lib/programmers/ValidateParseProgrammer.js.map +0 -1
  290. package/lib/programmers/ValidatePruneProgrammer.d.ts +0 -5
  291. package/lib/programmers/ValidatePruneProgrammer.js.map +0 -1
  292. package/lib/programmers/ValidateStringifyProgrammer.d.ts +0 -5
  293. package/lib/programmers/ValidateStringifyProgrammer.js.map +0 -1
  294. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +0 -1
  295. package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js.map +0 -1
  296. package/lib/transformers/features/miscellaneous/AssertPruneTransformer.js.map +0 -1
  297. package/lib/transformers/features/miscellaneous/CloneTransformer.js.map +0 -1
  298. package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js.map +0 -1
  299. package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js.map +0 -1
  300. package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js.map +0 -1
  301. package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js.map +0 -1
  302. package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js.map +0 -1
  303. package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +0 -1
  304. package/lib/transformers/features/miscellaneous/CreateRandomTransformer.js.map +0 -1
  305. package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js.map +0 -1
  306. package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js.map +0 -1
  307. package/lib/transformers/features/miscellaneous/IsCloneTransformer.js.map +0 -1
  308. package/lib/transformers/features/miscellaneous/IsPruneTransformer.js.map +0 -1
  309. package/lib/transformers/features/miscellaneous/LiteralsTransformer.js.map +0 -1
  310. package/lib/transformers/features/miscellaneous/MetadataTransformer.js.map +0 -1
  311. package/lib/transformers/features/miscellaneous/PruneTransformer.js.map +0 -1
  312. package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +0 -1
  313. package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js.map +0 -1
  314. package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.js.map +0 -1
  315. package/lib/transformers/features/parsers/AssertParseTransformer.js.map +0 -1
  316. package/lib/transformers/features/parsers/CreateAssertParseTransformer.js.map +0 -1
  317. package/lib/transformers/features/parsers/CreateIsParseTransformer.js.map +0 -1
  318. package/lib/transformers/features/parsers/CreateValidateParseTransformer.js.map +0 -1
  319. package/lib/transformers/features/parsers/IsParseTransformer.js.map +0 -1
  320. package/lib/transformers/features/parsers/ValidateParseTransformer.js.map +0 -1
  321. package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
  322. package/lib/transformers/features/stringifiers/AssertStringifyTransformer.js.map +0 -1
  323. package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js.map +0 -1
  324. package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js.map +0 -1
  325. package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js.map +0 -1
  326. package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js.map +0 -1
  327. package/lib/transformers/features/stringifiers/IsStringifyTransformer.js.map +0 -1
  328. package/lib/transformers/features/stringifiers/StringifyTransformer.js.map +0 -1
  329. package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.js.map +0 -1
  330. package/lib/transformers/features/validators/AssertTransformer.d.ts +0 -3
  331. package/lib/transformers/features/validators/AssertTransformer.js.map +0 -1
  332. package/lib/transformers/features/validators/CreateAssertTransformer.d.ts +0 -3
  333. package/lib/transformers/features/validators/CreateAssertTransformer.js.map +0 -1
  334. package/lib/transformers/features/validators/CreateIsTransformer.d.ts +0 -3
  335. package/lib/transformers/features/validators/CreateIsTransformer.js.map +0 -1
  336. package/lib/transformers/features/validators/CreateValidateTransformer.d.ts +0 -3
  337. package/lib/transformers/features/validators/CreateValidateTransformer.js.map +0 -1
  338. package/lib/transformers/features/validators/IsTransformer.d.ts +0 -3
  339. package/lib/transformers/features/validators/IsTransformer.js.map +0 -1
  340. package/lib/transformers/features/validators/ValidateTransformer.d.ts +0 -3
  341. package/lib/transformers/features/validators/ValidateTransformer.js.map +0 -1
  342. /package/lib/transformers/features/{parsers → json}/AssertParseTransformer.d.ts +0 -0
  343. /package/lib/transformers/features/{stringifiers → json}/AssertStringifyTransformer.d.ts +0 -0
  344. /package/lib/transformers/features/{parsers → json}/CreateAssertParseTransformer.d.ts +0 -0
  345. /package/lib/transformers/features/{stringifiers → json}/CreateAssertStringifyTransformer.d.ts +0 -0
  346. /package/lib/transformers/features/{parsers → json}/CreateIsParseTransformer.d.ts +0 -0
  347. /package/lib/transformers/features/{stringifiers → json}/CreateIsStringifyTransformer.d.ts +0 -0
  348. /package/lib/transformers/features/{stringifiers → json}/CreateStringifyTransformer.d.ts +0 -0
  349. /package/lib/transformers/features/{parsers → json}/CreateValidateParseTransformer.d.ts +0 -0
  350. /package/lib/transformers/features/{stringifiers → json}/CreateValidateStringifyProgrammer.d.ts +0 -0
  351. /package/lib/transformers/features/{parsers → json}/IsParseTransformer.d.ts +0 -0
  352. /package/lib/transformers/features/{stringifiers → json}/IsStringifyTransformer.d.ts +0 -0
  353. /package/lib/transformers/features/{stringifiers → json}/StringifyTransformer.d.ts +0 -0
  354. /package/lib/transformers/features/{parsers → json}/ValidateParseTransformer.d.ts +0 -0
  355. /package/lib/transformers/features/{stringifiers → json}/ValidateStringifyTransformer.d.ts +0 -0
  356. /package/lib/transformers/features/{miscellaneous → misc}/ApplicationTransformer.d.ts +0 -0
  357. /package/lib/transformers/features/{miscellaneous → misc}/AssertCloneTransformer.d.ts +0 -0
  358. /package/lib/transformers/features/{miscellaneous → misc}/AssertPruneTransformer.d.ts +0 -0
  359. /package/lib/transformers/features/{miscellaneous → misc}/CloneTransformer.d.ts +0 -0
  360. /package/lib/transformers/features/{miscellaneous → misc}/CreateAssertCloneTransformer.d.ts +0 -0
  361. /package/lib/transformers/features/{miscellaneous → misc}/CreateAssertPruneTransformer.d.ts +0 -0
  362. /package/lib/transformers/features/{miscellaneous → misc}/CreateCloneTransformer.d.ts +0 -0
  363. /package/lib/transformers/features/{miscellaneous → misc}/CreateIsCloneTransformer.d.ts +0 -0
  364. /package/lib/transformers/features/{miscellaneous → misc}/CreateIsPruneTransformer.d.ts +0 -0
  365. /package/lib/transformers/features/{miscellaneous → misc}/CreateIsPruneTransformer.js +0 -0
  366. /package/lib/transformers/features/{miscellaneous → misc}/CreatePruneTransformer.d.ts +0 -0
  367. /package/lib/transformers/features/{miscellaneous → misc}/CreateValidateCloneTransformer.d.ts +0 -0
  368. /package/lib/transformers/features/{miscellaneous → misc}/CreateValidatePruneTransformer.d.ts +0 -0
  369. /package/lib/transformers/features/{miscellaneous → misc}/IsCloneTransformer.d.ts +0 -0
  370. /package/lib/transformers/features/{miscellaneous → misc}/IsPruneTransformer.d.ts +0 -0
  371. /package/lib/transformers/features/{miscellaneous → misc}/IsPruneTransformer.js +0 -0
  372. /package/lib/transformers/features/{miscellaneous → misc}/LiteralsTransformer.d.ts +0 -0
  373. /package/lib/transformers/features/{miscellaneous → misc}/MetadataTransformer.d.ts +0 -0
  374. /package/lib/transformers/features/{miscellaneous → misc}/MetadataTransformer.js +0 -0
  375. /package/lib/transformers/features/{miscellaneous → misc}/PruneTransformer.d.ts +0 -0
  376. /package/lib/transformers/features/{miscellaneous → misc}/ValidateCloneTransformer.d.ts +0 -0
  377. /package/lib/transformers/features/{miscellaneous → misc}/ValidatePruneTransformer.d.ts +0 -0
  378. /package/lib/transformers/features/{protocols → protobuf}/MessageTransformer.d.ts +0 -0
  379. /package/src/transformers/features/{miscellaneous → misc}/CreateIsPruneTransformer.ts +0 -0
  380. /package/src/transformers/features/{miscellaneous → misc}/IsPruneTransformer.ts +0 -0
  381. /package/src/transformers/features/{miscellaneous → misc}/MetadataTransformer.ts +0 -0
package/src/module.ts CHANGED
@@ -1,2049 +1,781 @@
1
- import { $dictionary } from "./functional/$dictionary";
2
- import { Namespace } from "./functional/Namespace";
3
-
4
- import { IMetadataApplication } from "./metadata/IMetadataApplication";
5
- import { IJsonApplication } from "./schemas/IJsonApplication";
6
-
7
- import { Atomic } from "./typings/Atomic";
8
-
9
- import { MapUtil } from "./utils/MapUtil";
10
-
11
- import { CustomValidatorMap } from "./CustomValidatorMap";
12
- import { IRandomGenerator } from "./IRandomGenerator";
13
- import { IValidation } from "./IValidation";
14
- import { Primitive } from "./Primitive";
15
- import { TypeGuardError } from "./TypeGuardError";
16
-
17
- export * from "./schemas/IJsonApplication";
18
- export * from "./schemas/IJsonComponents";
19
- export * from "./schemas/IJsonSchema";
20
- export * from "./IRandomGenerator";
21
- export * from "./IValidation";
22
- export * from "./Primitive";
23
- export * from "./TypeGuardError";
24
-
25
- /* ===========================================================
26
- SINGLE FUNCTIONS
27
- - BASIC VALIDATORS
28
- - STRICT VALIDATORS
29
- - PROTOCOL BUFFER FUNCTIONS
30
- - JSON FUNCTIONS
31
- - MISCELLANEOUS
32
- ==============================================================
33
- BASIC VALIDATORS
34
- ----------------------------------------------------------- */
35
- /**
36
- * Asserts a value type.
37
- *
38
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
39
- * reason, if the parametric value is not following the type `T`. Otherwise, the
40
- * value is following the type `T`, just input parameter would be returned.
41
- *
42
- * If what you want is not asserting but just knowing whether the parametric value is
43
- * following the type `T` or not, you can choose the {@link is} function instead.
44
- * Otherwise you want to know all the errors, {@link validate} is the way to go.
45
- *
46
- * On the other and, if you don't want to allow any superfluous property that is not
47
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
48
- *
49
- * @template T Type of the input value
50
- * @param input A value to be asserted
51
- * @returns Parametric input value
52
- * @throws A {@link TypeGuardError} instance with detailed reason
53
- *
54
- * @author Jeongho Nam - https://github.com/samchon
55
- */
56
- export function assert<T>(input: T): T;
57
-
58
- /**
59
- * Asserts a value type.
60
- *
61
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
62
- * reason, if the parametric value is not following the type `T`. Otherwise, the
63
- * value is following the type `T`, just input parameter would be returned.
64
- *
65
- * If what you want is not asserting but just knowing whether the parametric value is
66
- * following the type `T` or not, you can choose the {@link is} function instead.
67
- * Otherwise, you want to know all the errors, {@link validate} is the way to go.
68
- *
69
- * On the other and, if you don't want to allow any superfluous property that is not
70
- * enrolled to the type `T`, you can use {@link assertEquals} function instead.
71
- *
72
- * @template T Type of the input value
73
- * @param input A value to be asserted
74
- * @returns Parametric input value casted as `T`
75
- * @throws A {@link TypeGuardError} instance with detailed reason
76
- *
77
- * @author Jeongho Nam - https://github.com/samchon
78
- */
79
- export function assert<T>(input: unknown): T;
80
-
81
- /**
82
- * @internal
83
- */
84
- export function assert(): never {
85
- halt("assert");
86
- }
87
- Object.assign(assert, Namespace.assert("assert"));
88
-
89
- /**
90
- * Asserts a value type.
91
- *
92
- * Duplicated function of {@link assert} for `typescript-is` users.
93
- *
94
- * @template T Type of the input value
95
- * @param input A value to be asserted
96
- * @returns Parametric input value
97
- * @throws A {@link TypeGuardError} instance with detailed reason
98
- *
99
- * @author Jeongho Nam - https://github.com/samchon
100
- * @deprecated
101
- */
102
- export function assertType<T>(input: T): T;
103
-
104
- /**
105
- * Asserts a value type.
106
- *
107
- * Duplicated function of {@link assert} for `typescript-is` users.
108
- *
109
- * @template T Type of the input value
110
- * @param input A value to be asserted
111
- * @returns Parametric input value
112
- * @throws A {@link TypeGuardError} instance with detailed reason
113
- *
114
- * @author Jeongho Nam - https://github.com/samchon
115
- * @deprecated
116
- */
117
- export function assertType<T>(input: unknown): T;
118
-
119
- /**
120
- * @internal
121
- */
122
- export function assertType(): never {
123
- halt("assertType");
124
- }
125
- Object.assign(assertType, Namespace.assert("assertType"));
126
-
127
- /**
128
- * Tests a value type.
129
- *
130
- * Tests a parametric value type and returns whether it's following the type `T` or not.
131
- * If the parametric value is matched with the type `T`, `true` value would be returned.
132
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
133
- * returned.
134
- *
135
- * If what you want is not just knowing whether the parametric value is following the
136
- * type `T` or not, but throwing an exception with detailed reason, you can choose
137
- * {@link assert} function instead. Also, if you want to know all the errors with
138
- * detailed reasons, {@link validate} function would be useful.
139
- *
140
- * On the other and, if you don't want to allow any superfluous property that is not
141
- * enrolled to the type `T`, you can use {@link equals} function instead.
142
- *
143
- * @template T Type of the input value
144
- * @param input A value to be tested
145
- * @returns Whether the parametric value is following the type `T` or not
146
- *
147
- * @author Jeongho Nam - https://github.com/samchon
148
- */
149
- export function is<T>(input: T): input is T;
150
-
151
- /**
152
- * Tests a value type.
153
- *
154
- * Tests a parametric value type and returns whether it's following the type `T` or not.
155
- * If the parametric value is matched with the type `T`, `true` value would be returned.
156
- * Otherwise, the parametric value is not following the type `T`, `false` value would be
157
- * returned.
158
- *
159
- * If what you want is not just knowing whether the parametric value is following the
160
- * type `T` or not, but throwing an exception with detailed reason, you can choose
161
- * {@link assert} function instead. Also, if you want to know all the errors with
162
- * detailed reasons, {@link validate} function would be useful.
163
- *
164
- * On the other and, if you don't want to allow any superfluous property that is not
165
- * enrolled to the type `T`, you can use {@link equals} function instead.
166
- *
167
- * @template T Type of the input value
168
- * @param input A value to be tested
169
- * @returns Whether the parametric value is following the type `T` or not
170
- *
171
- * @author Jeongho Nam - https://github.com/samchon
172
- */
173
- export function is<T>(input: unknown): input is T;
174
-
175
- /**
176
- * @internal
177
- */
178
- export function is(): never {
179
- halt("is");
180
- }
181
- Object.assign(is, Namespace.assert("is"));
182
-
183
- /**
184
- * Validates a value type.
185
- *
186
- * Validates a parametric value type and archives all the type errors into an
187
- * {@link IValidation.errors} array, if the parametric value is not following the
188
- * type `T`. Of course, if the parametric value is following the type `T`, the
189
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
190
- * would have the `true` value.
191
- *
192
- * If what you want is not finding all the error, but asserting the parametric value
193
- * type with exception throwing, you can choose {@link assert} function instead.
194
- * Otherwise, you just want to know whether the parametric value is matched with the
195
- * type `T`, {@link is} function is the way to go.
196
- *
197
- * On the other and, if you don't want to allow any superfluous property that is not
198
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
199
- *
200
- * @template Type of the input value
201
- * @param input A value to be validated
202
- * @returns Validation result
203
- *
204
- * @author Jeongho Nam - https://github.com/samchon
205
- */
206
- export function validate<T>(input: T): IValidation<T>;
207
-
208
- /**
209
- * Validates a value type.
210
- *
211
- * Validates a parametric value type and archives all the type errors into an
212
- * {@link IValidation.errors} array, if the parametric value is not following the
213
- * type `T`. Of course, if the parametric value is following the type `T`, the
214
- * {@link IValidation.errors} array would be empty and {@link IValidation.success}
215
- * would have the `true` value.
216
- *
217
- * If what you want is not finding all the error, but asserting the parametric value
218
- * type with exception throwing, you can choose {@link assert} function instead.
219
- * Otherwise, you just want to know whether the parametric value is matched with the
220
- * type `T`, {@link is} function is the way to go.
221
- *
222
- * On the other and, if you don't want to allow any superfluous property that is not
223
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
224
- *
225
- * @template Type of the input value
226
- * @param input A value to be validated
227
- * @returns Validation result
228
- *
229
- * @author Jeongho Nam - https://github.com/samchon
230
- */
231
- export function validate<T>(input: unknown): IValidation<T>;
232
-
233
- /**
234
- * @internal
235
- */
236
- export function validate(): never {
237
- halt("validate");
238
- }
239
- Object.assign(validate, Namespace.validate());
240
-
241
- /* -----------------------------------------------------------
242
- STRICT VALIDATORS
243
- ----------------------------------------------------------- */
244
- /**
245
- * Asserts equality between a value and its type.
246
- *
247
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
248
- * reason, if the parametric value is not following the type `T` or some superfluous
249
- * property that is not listed on the type `T` has been found. Otherwise, the value is
250
- * following the type `T` without any superfluous property, just input parameter would
251
- * be returned.
252
- *
253
- * If what you want is not asserting but just knowing whether the parametric value is
254
- * following the type `T` or not, you can choose the {@link equals} function instead.
255
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
256
- *
257
- * On the other hand, if you want to allow superfluous property that is not enrolled
258
- * to the type `T`, you can use {@link assert} function instead.
259
- *
260
- * @template T Type of the input value
261
- * @param input A value to be asserted
262
- * @returns Parametric input value
263
- * @throws A {@link TypeGuardError} instance with detailed reason
264
- *
265
- * @author Jeongho Nam - https://github.com/samchon
266
- */
267
- export function assertEquals<T>(input: T): T;
268
-
269
- /**
270
- * Asserts equality between a value and its type.
271
- *
272
- * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
273
- * reason, if the parametric value is not following the type `T` or some superfluous
274
- * property that is not listed on the type `T` has been found. Otherwise, the value is
275
- * following the type `T` without any superfluous property, just input parameter would
276
- * be returned.
277
- *
278
- * If what you want is not asserting but just knowing whether the parametric value is
279
- * following the type `T` or not, you can choose the {@link equals} function instead.
280
- * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
281
- *
282
- * On the other hand, if you want to allow superfluous property that is not enrolled
283
- * to the type `T`, you can use {@link assert} function instead.
284
- *
285
- * @template T Type of the input value
286
- * @param input A value to be asserted
287
- * @returns Parametric input value casted as `T`
288
- * @throws A {@link TypeGuardError} instance with detailed reason
289
- *
290
- * @author Jeongho Nam - https://github.com/samchon
291
- */
292
- export function assertEquals<T>(input: unknown): T;
293
-
294
- /**
295
- * @internal
296
- */
297
- export function assertEquals(): never {
298
- halt("assertEquals");
299
- }
300
- Object.assign(assertEquals, Namespace.assert("assertEquals"));
301
-
302
- /**
303
- * Tests equality between a value and its type.
304
- *
305
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
306
- * or not. If the parametric value is matched with the type `T` and there's not any
307
- * superfluous property that is not listed on the type `T`, `true` value would be
308
- * returned. Otherwise, the parametric value is not following the type `T` or some
309
- * superfluous property exists, `false` value would be returned.
310
- *
311
- * If what you want is not just knowing whether the parametric value is following the
312
- * type `T` or not, but throwing an exception with detailed reason, you can choose
313
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
314
- * detailed reasons, {@link validateEquals} function would be useful.
315
- *
316
- * On the other hand, if you want to allow superfluous property that is not enrolled
317
- * to the type `T`, you can use {@link is} function instead.
318
- *
319
- * @template T Type of the input value
320
- * @param input A value to be tested
321
- * @returns Whether the parametric value is equivalent to the type `T` or not
322
- *
323
- * @author Jeongho Nam - https://github.com/samchon
324
- */
325
- export function equals<T>(input: T): input is T;
326
-
327
- /**
328
- * Tests equality between a value and its type.
329
- *
330
- * Tests a parametric value type and returns whether it's equivalent to the type `T`
331
- * or not. If the parametric value is matched with the type `T` and there's not any
332
- * superfluous property that is not listed on the type `T`, `true` value would be
333
- * returned. Otherwise, the parametric value is not following the type `T` or some
334
- * superfluous property exists, `false` value would be returned.
335
- *
336
- * If what you want is not just knowing whether the parametric value is following the
337
- * type `T` or not, but throwing an exception with detailed reason, you can choose
338
- * {@link assertEquals} function instead. Also, if you want to know all the errors with
339
- * detailed reasons, {@link validateEquals} function would be useful.
340
- *
341
- * On the other hand, if you want to allow superfluous property that is not enrolled
342
- * to the type `T`, you can use {@link is} function instead.
343
- *
344
- * @template T Type of the input value
345
- * @param input A value to be tested
346
- * @returns Whether the parametric value is equivalent to the type `T` or not
347
- *
348
- * @author Jeongho Nam - https://github.com/samchon
349
- */
350
- export function equals<T>(input: unknown): input is T;
351
-
352
- /**
353
- * @internal
354
- */
355
- export function equals(): never {
356
- halt("equals");
357
- }
358
- Object.assign(equals, Namespace.is());
359
-
360
- /**
361
- * Validates equality between a value and its type.
362
- *
363
- * Validates a parametric value type and archives all the type errors into an
364
- * {@link IValidation.errors} array, if the parametric value is not following the
365
- * type `T` or some superfluous property that is not listed on the type `T` has been
366
- * found. Of course, if the parametric value is following the type `T` and no
367
- * superfluous property exists, the {@link IValidation.errors} array would be empty
368
- * and {@link IValidation.success} would have the `true` value.
369
- *
370
- * If what you want is not finding all the error, but asserting the parametric value
371
- * type with exception throwing, you can choose {@link assert} function instead.
372
- * Otherwise, you just want to know whether the parametric value is matched with the
373
- * type `T`, {@link is} function is the way to go.
374
- *
375
- * On the other and, if you don't want to allow any superfluous property that is not
376
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
377
- *
378
- * @template Type of the input value
379
- * @param input A value to be validated
380
- * @returns Validation result
381
- *
382
- * @author Jeongho Nam - https://github.com/samchon
383
- */
384
- export function validateEquals<T>(input: T): IValidation<T>;
385
-
386
- /**
387
- * Validates equality between a value and its type.
388
- *
389
- * Validates a parametric value type and archives all the type errors into an
390
- * {@link IValidation.errors} array, if the parametric value is not following the
391
- * type `T` or some superfluous property that is not listed on the type `T` has been
392
- * found. Of course, if the parametric value is following the type `T` and no
393
- * superfluous property exists, the {@link IValidation.errors} array would be empty
394
- * and {@link IValidation.success} would have the `true` value.
395
- *
396
- * If what you want is not finding all the error, but asserting the parametric value
397
- * type with exception throwing, you can choose {@link assert} function instead.
398
- * Otherwise, you just want to know whether the parametric value is matched with the
399
- * type `T`, {@link is} function is the way to go.
400
- *
401
- * On the other and, if you don't want to allow any superfluous property that is not
402
- * enrolled to the type `T`, you can use {@link validateEquals} function instead.
403
- *
404
- * @template Type of the input value
405
- * @param input A value to be validated
406
- * @returns Validation result
407
- *
408
- * @author Jeongho Nam - https://github.com/samchon
409
- */
410
- export function validateEquals<T>(input: unknown): IValidation<T>;
411
-
412
- /**
413
- * @internal
414
- */
415
- export function validateEquals(): never {
416
- halt("validateEquals");
417
- }
418
- Object.assign(validateEquals, Namespace.validate());
419
-
420
- /**
421
- * Custom validators.
422
- *
423
- * If you want to add a custom validation logic utilizing comment tags,
424
- * add a closure function with its tag and type name. Below example code
425
- * would helpful to understand how to use this instance.
426
- *
427
- * ```ts
428
- * typia.customValidators.insert("powerOf")("number")(
429
- * (text: string) => {
430
- * const denominator: number = Math.log(Number(text));
431
- * return (value: number) => {
432
- * value = Math.log(value) / denominator;
433
- * return value === Math.floor(value);
434
- * };
435
- * }
436
- * );
437
- * typia.customValidators.insert("dollar")("string")(
438
- * () => (value: string) => value.startsWith("$"),
439
- * );
440
- *
441
- * interface TagCustom {
442
- * /**
443
- * * @powerOf 10
444
- * *\/
445
- * powerOf: number;
446
- *
447
- * /**
448
- * * @dollar
449
- * *\/
450
- * dollar: string;
451
- * }
452
- * ```
453
- *
454
- * @author Jeongho Nam - https://github.com/samchon
455
- */
456
- export const customValidators: CustomValidatorMap = {
457
- size: (name?: string) =>
458
- name ? $dictionary.get(name)?.size ?? 0 : $dictionary.size,
459
- has: (name) => (type) => $dictionary.get(name)?.has(type) ?? false,
460
- get: (name) => (type) => $dictionary.get(name)?.get(type),
461
- insert: (name) => (type) => (closure) => {
462
- const internal = MapUtil.take($dictionary)(name, () => new Map());
463
- if (internal.has(type)) return false;
464
- internal.set(type, closure);
465
- return true;
466
- },
467
- erase: (name) => (type) => $dictionary.get(name)?.delete(type) ?? false,
468
- };
469
-
470
- /* -----------------------------------------------------------
471
- PROTOCOL BUFFER FUNCTIONS
472
- ----------------------------------------------------------- */
473
- export function message(): never;
474
- export function message<T>(): string;
475
-
476
- export function message(): string {
477
- halt("message");
478
- }
479
-
480
- /* -----------------------------------------------------------
481
- JSON FUNCTIONS
482
- ----------------------------------------------------------- */
483
- /**
484
- * > You must configure the generic argument `T`.
485
- *
486
- * JSON Schema Application.
487
- *
488
- * Creates a JSON schema application which contains both main JSON schemas and components.
489
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
490
- * property for the `$ref` referencing.
491
- *
492
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
493
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
494
- * you should configure the *Purpose* appropriately.
495
- *
496
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
497
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
498
- * the tuple definition.
499
- *
500
- * @template Types Tuple of target types
501
- * @template Purpose Purpose of the JSON schema`
502
- * @return JSON schema application
503
- *
504
- * @author Jeongho Nam - https://github.com/samchon
505
- */
506
- export function application(): never;
507
-
508
- /**
509
- * JSON Schema Application.
510
- *
511
- * Creates a JSON schema application which contains both main JSON schemas and components.
512
- * Note that, all of the object types are stored in the {@link IJsonApplication.components}
513
- * property for the `$ref` referencing.
514
- *
515
- * Also, `typia.application()` has additional generic arguments, *Purpose*.
516
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
517
- * you should configure the *Purpose* appropriately.
518
- *
519
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
520
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
521
- * the tuple definition.
522
- *
523
- * @template Types Tuple of target types
524
- * @template Purpose Purpose of the JSON schema
525
- * @return JSON schema application
526
- *
527
- * @author Jeongho Nam - https://github.com/samchon
528
- */
529
- export function application<
530
- Types extends unknown[],
531
- Purpose extends "ajv" | "swagger" = "swagger",
532
- >(): IJsonApplication;
533
-
534
- /**
535
- * @internal
536
- */
537
- export function application(): never {
538
- halt("application");
539
- }
540
-
541
- /**
542
- * > You must configure the generic argument `T`.
543
- *
544
- * Safe `JSON.parse()` function with type assertion.
545
- *
546
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
547
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
548
- * instance with type assertion.
549
- *
550
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
551
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
552
- * the parsed value would be returned.
553
- *
554
- * @template T Expected type of parsed value
555
- * @param input JSON string
556
- * @returns Parsed value
557
- *
558
- * @author Jeongho Nam - https://github.com/samchon
559
- */
560
- export function assertParse(input: string): never;
561
-
562
- /**
563
- * Safe `JSON.parse()` function with type assertion.
564
- *
565
- * `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
566
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
567
- * instance with type assertion.
568
- *
569
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
570
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
571
- * the parsed value would be returned.
572
- *
573
- * @template T Expected type of parsed value
574
- * @param input JSON string
575
- * @returns Parsed value
576
- *
577
- * @author Jeongho Nam - https://github.com/samchon
578
- */
579
- export function assertParse<T>(input: string): Primitive<T>;
580
-
581
- /**
582
- * @internal
583
- */
584
- export function assertParse<T>(): Primitive<T> {
585
- halt("assertParse");
586
- }
587
- Object.assign(assertParse, Namespace.assert("assertParse"));
588
-
589
- /**
590
- * > You must configure the generic argument `T`.
591
- *
592
- * Safe `JSON.parse()` function with type checking.
593
- *
594
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
595
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
596
- * instance with type checking.
597
- *
598
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
599
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
600
- * value would be returned.
601
- *
602
- * @template T Expected type of parsed value
603
- * @param input JSON string
604
- * @returns Parsed value when exact type, otherwise `null`
605
- *
606
- * @author Jeongho Nam - https://github.com/samchon
607
- */
608
- export function isParse(input: string): never;
609
-
610
- /**
611
- * Safe `JSON.parse()` function with type checking.
612
- *
613
- * `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
614
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
615
- * instance with type checking.
616
- *
617
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
618
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
619
- * value would be returned.
620
- *
621
- * @template T Expected type of parsed value
622
- * @param input JSON string
623
- * @returns Parsed value when exact type, otherwise `null`
624
- *
625
- * @author Jeongho Nam - https://github.com/samchon
626
- */
627
- export function isParse<T>(input: string): Primitive<T> | null;
628
-
629
- /**
630
- * @internal
631
- */
632
- export function isParse<T>(): Primitive<T> | null {
633
- halt("isParse");
634
- }
635
- Object.assign(isParse, is);
636
-
637
- /**
638
- * > You must configure the generic argument `T`.
639
- *
640
- * Safe `JSON.parse()` function with detailed type validation.
641
- *
642
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
643
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
644
- * to a `T` typed instance with detailed type validation.
645
- *
646
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
647
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
648
- * there's no problem on the parsed value, the parsed value would be stored in `data`
649
- * property of the output {@link IValidation.ISuccess} instance.
650
- *
651
- * @template T Expected type of parsed value
652
- * @param input JSON string
653
- * @returns Validation result with JSON parsed value
654
- *
655
- * @author Jeongho Nam - https://github.com/samchon
656
- */
657
- export function validateParse(input: string): never;
658
-
659
- /**
660
- * Safe `JSON.parse()` function with detailed type validation.
661
- *
662
- * `typia.validateParse()` is a combination function of `JSON.parse()` and
663
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
664
- * to a `T` typed instance with detailed type validation.
665
- *
666
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
667
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
668
- * there's no problem on the parsed value, the parsed value would be stored in `data`
669
- * property of the output {@link IValidation.ISuccess} instance.
670
- *
671
- * @template T Expected type of parsed value
672
- * @param input JSON string
673
- * @returns Validation result with JSON parsed value
674
- *
675
- * @author Jeongho Nam - https://github.com/samchon
676
- */
677
- export function validateParse<T>(input: string): IValidation<Primitive<T>>;
678
-
679
- /**
680
- * @internal
681
- */
682
- export function validateParse<T>(): IValidation<Primitive<T>> {
683
- halt("validateParse");
684
- }
685
- Object.assign(validateParse, validate);
686
-
687
- /**
688
- * 8x faster `JSON.stringify()` function.
689
- *
690
- * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
691
- * than the native `JSON.stringify()` function. The 5x faster principle is because
692
- * it writes an optimized JSON conversion plan, only for the type `T`.
693
- *
694
- * For reference, this `typia.stringify()` does not validate the input value type.
695
- * It just believes that the input value is following the type `T`. Therefore, if you
696
- * can't ensure the input value type, it would be better to call one of below functions
697
- * instead.
698
- *
699
- * - {@link assertStringify}
700
- * - {@link isStringify}
701
- * - {@link validateStringify}
702
- *
703
- * @template T Type of the input value
704
- * @param input A value to be converted
705
- * @return JSON string value
706
- *
707
- * @author Jeongho Nam - https://github.com/samchon
708
- */
709
- export function stringify<T>(input: T): string;
710
-
711
- /**
712
- * @internal
713
- */
714
- export function stringify(): never {
715
- halt("stringify");
716
- }
717
- Object.assign(stringify, Namespace.stringify("stringify"));
718
-
719
- /**
720
- * 5x faster `JSON.stringify()` function with type assertion.
721
- *
722
- * `typia.assertStringify()` is a combination function of {@link assert} and
723
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
724
- * Notation) string, with type assertion.
725
- *
726
- * In such reason, when `input` value is not matched with the type `T`, it throws an
727
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
728
- * string would be returned.
729
- *
730
- * For reference, with type assertion, it is even 5x times faster than the native
731
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
732
- * with confidence.
733
- *
734
- * @template T Type of the input value
735
- * @param input A value to be asserted and converted
736
- * @return JSON string value
737
- *
738
- * @author Jeongho Nam - https://github.com/samchon
739
- */
740
- export function assertStringify<T>(input: T): string;
741
-
742
- /**
743
- * 5x faster `JSON.stringify()` function with type assertion.
744
- *
745
- * `typia.assertStringify()` is a combination function of {@link assert} and
746
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
747
- * Notation) string, with type assertion.
748
- *
749
- * In such reason, when `input` value is not matched with the type `T`, it throws an
750
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
751
- * string would be returned.
752
- *
753
- * For reference, with type assertion, it is even 5x times faster than the native
754
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
755
- * with confidence.
756
- *
757
- * @template T Type of the input value
758
- * @param input A value to be asserted and converted
759
- * @return JSON string value
760
- *
761
- * @author Jeongho Nam - https://github.com/samchon
762
- */
763
- export function assertStringify<T>(input: T): unknown;
764
-
765
- /**
766
- * @internal
767
- */
768
- export function assertStringify(): string {
769
- halt("assertStringify");
770
- }
771
- Object.assign(assertStringify, Namespace.assert("assertStringify"));
772
- Object.assign(assertStringify, Namespace.stringify("assertStringify"));
773
-
774
- /**
775
- * 7x faster `JSON.stringify()` function with type checking.
776
- *
777
- * `typia.stringify()` is a combination function of {@link is} and
778
- * {@link stringify}. Therefore, it converts an input value to JSON
779
- * (JavaScript Object Notation) string, with type checking.
780
- *
781
- * In such reason, when `input` value is not matched with the type `T`, it returns
782
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
783
- * be returned.
784
- *
785
- * For reference, with type checking, it is even 7x times faster than the native
786
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
787
- * with confidence.
788
- *
789
- * @template T Type of the input value
790
- * @param input A value to be checked and converted
791
- * @return JSON string value when exact type, otherwise null
792
- *
793
- * @author Jeongho Nam - https://github.com/samchon
794
- */
795
- export function isStringify<T>(input: T): string | null;
796
-
797
- /**
798
- * 7x faster `JSON.stringify()` function with type checking.
799
- *
800
- * `typia.isStringify()` is a combination function of {@link is} and
801
- * {@link stringify}. Therefore, it converts an input value to JSON
802
- * (JavaScript Object Notation) string, with type checking.
803
- *f
804
- * In such reason, when `input` value is not matched with the type `T`, it returns
805
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string would
806
- * be returned.
807
- *
808
- * For reference, with type checking, it is even 7x times faster than the native
809
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
810
- * with confidence.
811
- *
812
- * @template T Type of the input value
813
- * @param input A value to be checked and converted
814
- * @return JSON string value when exact type, otherwise null
815
- *
816
- * @author Jeongho Nam - https://github.com/samchon
817
- */
818
- export function isStringify<T>(input: unknown): string | null;
819
-
820
- /**
821
- * @internal
822
- */
823
- export function isStringify(): string | null {
824
- halt("isStringify");
825
- }
826
-
827
- Object.assign(isStringify, Namespace.is());
828
- Object.assign(isStringify, Namespace.stringify("isStringify"));
829
-
830
- /**
831
- * 5x faster `JSON.stringify()` function with detailed type validation.
832
- *
833
- * `typia.validateStringify()` is a combination function of {@link validate} and
834
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
835
- * Notation) string, with detailed type validation.
836
- *
837
- * In such reason, when `input` value is not matched with the type `T`, it returns
838
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
839
- * problem on the `input` value, JSON string would be stored in `data` property of
840
- * the output {@link IValidation.ISuccess} instance.
841
- *
842
- * For reference, with detailed type validation, it is even 5x times faster than the
843
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
844
- * with confidence.
845
- *
846
- * @template T Type of the input value
847
- * @param input A value to be checked and converted
848
- * @returns Validation result with JSON string value
849
- *
850
- * @author Jeongho Nam - https://github.com/samchon
851
- */
852
- export function validateStringify<T>(input: T): IValidation<string>;
853
-
854
- /**
855
- * 5x faster `JSON.stringify()` function with detailed type validation.
856
- *
857
- * `typia.validateStringify()` is a combination function of {@link validate} and
858
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
859
- * Notation) string, with detailed type validation.
860
- *
861
- * In such reason, when `input` value is not matched with the type `T`, it returns
862
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
863
- * problem on the `input` value, JSON string would be stored in `data` property of
864
- * the output {@link IValidation.ISuccess} instance.
865
- *
866
- * For reference, with detailed type validation, it is even 5x times faster than the
867
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
868
- * with confidence.
869
- *
870
- * @template T Type of the input value
871
- * @param input A value to be checked and converted
872
- * @returns Validation result with JSON string value
873
- *
874
- * @author Jeongho Nam - https://github.com/samchon
875
- */
876
- export function validateStringify<T>(input: unknown): IValidation<string>;
877
-
878
- /**
879
- * @internal
880
- */
881
- export function validateStringify(): IValidation<string> {
882
- halt("validateStringify");
883
- }
884
- Object.assign(validateStringify, Namespace.validate());
885
- Object.assign(validateStringify, Namespace.stringify("validateStringify"));
886
-
887
- /* -----------------------------------------------------------
888
- MISCELLANEOUS
889
- ----------------------------------------------------------- */
890
- /**
891
- * @internal
892
- */
893
- export function metadata(): never;
894
-
895
- /**
896
- * @internal
897
- */
898
- export function metadata<Types extends unknown[]>(): IMetadataApplication;
899
-
900
- /**
901
- * @internal
902
- */
903
- export function metadata(): never {
904
- halt("metadata");
905
- }
906
-
907
- /**
908
- * > You must configure the generic argument `T`.
909
- *
910
- * Generate random data.
911
- *
912
- * Generates a random data following type the `T`.
913
- *
914
- * For reference, this `typia.random()` function generates only primitive type.
915
- * If there're some methods in the type `T` or its nested instances, those would
916
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
917
- * would be generated instead.
918
- *
919
- * @template T Type of data to generate
920
- * @param generator Random data generator
921
- * @return Randomly generated data
922
- *
923
- * @author Jeongho Nam - https://github.com/samchon
924
- */
925
- export function random(generator?: Partial<IRandomGenerator>): never;
926
-
927
- /**
928
- * Generate random data.
929
- *
930
- * Generates a random data following type the `T`.
931
- *
932
- * For reference, this `typia.random()` function generates only primitive type.
933
- * If there're some methods in the type `T` or its nested instances, those would
934
- * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
935
- * would be generated instead.
936
- *
937
- * @template T Type of data to generate
938
- * @param generator Random data generator
939
- * @return Randomly generated data
940
- *
941
- * @author Jeongho Nam - https://github.com/samchon
942
- */
943
- export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
944
-
945
- /**
946
- * @internal
947
- */
948
- export function random(): never {
949
- halt("random");
950
- }
951
- Object.assign(random, Namespace.random());
952
-
953
- /**
954
- * > You must configure the generic argument `T`.
955
- *
956
- * Union literal type to array.
957
- *
958
- * Converts a union literal type to an array of its members.
959
- *
960
- * ```typescript
961
- * literals<"A" | "B" | 1>; // ["A", "B", 1]
962
- * ```
963
- *
964
- * @template T Union literal type
965
- * @return Array of union literal type's members
966
- *
967
- * @author Jeongho Nam - https://github.com/samchon
968
- */
969
- export function literals(): never;
970
-
971
- /**
972
- * Union literal type to array.
973
- *
974
- * Converts a union literal type to an array of its members.
975
- *
976
- * ```typescript
977
- * literals<"A" | "B" | 1>; // ["A", "B", 1]
978
- * ```
979
- *
980
- * @template T Union literal type
981
- * @return Array of union literal type's members
982
- *
983
- * @author Jeongho Nam - https://github.com/samchon
984
- */
985
- export function literals<T extends Atomic.Type | null>(): T[];
986
-
987
- /**
988
- * @internal
989
- */
990
- export function literals(): never {
991
- halt("literals");
992
- }
993
-
994
- /**
995
- * Clone a data.
996
- *
997
- * Clones an instance following type `T`. If the target *input* value or its member
998
- * variable contains a class instance that is having a `toJSON()` method, its return
999
- * value would be cloned.
1000
- *
1001
- * For reference, this `typia.clone()` function does not validate the input value type.
1002
- * It just believes that the input value is following the type `T`. Therefore, if you
1003
- * can't ensure the input value type, it would be better to call {@link assertClone}
1004
- * function instead.
1005
- *
1006
- * @template T Type of the input value
1007
- * @param input A value to be cloned
1008
- * @return Cloned data
1009
- *
1010
- * @author Jeongho Nam - https://github.com/samchon
1011
- */
1012
- export function clone<T>(input: T): Primitive<T>;
1013
-
1014
- /**
1015
- * @internal
1016
- */
1017
- export function clone(): never {
1018
- halt("clone");
1019
- }
1020
- Object.assign(clone, Namespace.clone("clone"));
1021
-
1022
- /**
1023
- * Clone a data with type assertion.
1024
- *
1025
- * Clones an instance following type `T`, with type assertion. If the target `input`
1026
- * value or its member variable contains a class instance that is having a `toJSON()`
1027
- * method, its return value would be cloned.
1028
- *
1029
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1030
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1031
- * data would be returned.
1032
- *
1033
- * @template T Type of the input value
1034
- * @param input A value to be cloned
1035
- * @return Cloned data
1036
- *
1037
- * @author Jeongho Nam - https://github.com/samchon
1038
- */
1039
- export function assertClone<T>(input: T): Primitive<T>;
1040
-
1041
- /**
1042
- * Clone a data with type assertion.
1043
- *
1044
- * Clones an instance following type `T`, with type assertion. If the target `input`
1045
- * value or its member variable contains a class instance that is having a `toJSON()`
1046
- * method, its return value would be cloned.
1047
- *
1048
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1049
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
1050
- * data would be returned.
1051
- *
1052
- * @template T Type of the input value
1053
- * @param input A value to be cloned
1054
- * @return Cloned data
1055
- *
1056
- * @author Jeongho Nam - https://github.com/samchon
1057
- */
1058
- export function assertClone<T>(input: unknown): Primitive<T>;
1059
-
1060
- /**
1061
- * @internal
1062
- */
1063
- export function assertClone(): never {
1064
- halt("assertClone");
1065
- }
1066
- Object.assign(assertClone, Namespace.assert("assertClone"));
1067
- Object.assign(assertClone, Namespace.clone("assertClone"));
1068
-
1069
- /**
1070
- * Clone a data with type checking.
1071
- *
1072
- * Clones an instance following type `T`, with type checking. If the target `input`
1073
- * value or its member variable contains a class instance that is having a `toJSON()`
1074
- * method, its return value would be cloned.
1075
- *
1076
- * In such reason, when `input` value is not matched with the type `T`, it returns
1077
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1078
- * data would be returned.
1079
- *
1080
- * @template T Type of the input value
1081
- * @param input A value to be cloned
1082
- * @return Cloned data when exact type, otherwise null
1083
- *
1084
- * @author Jeongho Nam - https://github.com/samchon
1085
- */
1086
- export function isClone<T>(input: T): Primitive<T> | null;
1087
-
1088
- /**
1089
- * Clone a data with type checking.
1090
- *
1091
- * Clones an instance following type `T`, with type checking. If the target `input`
1092
- * value or its member variable contains a class instance that is having a `toJSON()`
1093
- * method, its return value would be cloned.
1094
- *
1095
- * In such reason, when `input` value is not matched with the type `T`, it returns
1096
- * `null` value instead. Otherwise, there's no problem on the `input` value, cloned
1097
- * data would be returned.
1098
- *
1099
- * @template T Type of the input value
1100
- * @param input A value to be cloned
1101
- * @return Cloned data when exact type, otherwise null
1102
- *
1103
- * @author Jeongho Nam - https://github.com/samchon
1104
- */
1105
- export function isClone<T>(input: unknown): Primitive<T> | null;
1106
-
1107
- /**
1108
- * @internal
1109
- */
1110
- export function isClone(): never {
1111
- halt("isClone");
1112
- }
1113
- Object.assign(isClone, Namespace.is());
1114
- Object.assign(isClone, Namespace.clone("isClone"));
1115
-
1116
- /**
1117
- * Clone a data with detailed type validation.
1118
- *
1119
- * Clones an instance following type `T`, with detailed type validation. If the target
1120
- * `input` value or its member variable contains a class instance that is having a
1121
- * `toJSON()` method, its return value would be cloned.
1122
- *
1123
- * In such reason, when `input` value is not matched with the type `T`, it returns
1124
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1125
- * value, cloned data would be stored in `data` property of the output
1126
- * {@link IValidation.Success} instance.
1127
- *
1128
- * @template T Type of the input value
1129
- * @param input A value to be cloned
1130
- * @returns Validation result with cloned value
1131
- */
1132
- export function validateClone<T>(input: T): IValidation<Primitive<T>>;
1133
-
1134
- /**
1135
- * Clone a data with detailed type validation.
1136
- *
1137
- * Clones an instance following type `T`, with detailed type validation. If the target
1138
- * `input` value or its member variable contains a class instance that is having a
1139
- * `toJSON()` method, its return value would be cloned.
1140
- *
1141
- * In such reason, when `input` value is not matched with the type `T`, it returns
1142
- * {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
1143
- * value, cloned data would be stored in `data` property of the output
1144
- * {@link IValidation.Success} instance.
1145
- *
1146
- * @template T Type of the input value
1147
- * @param input A value to be cloned
1148
- * @returns Validation result with cloned value
1149
- */
1150
- export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
1151
-
1152
- /**
1153
- * @internal
1154
- */
1155
- export function validateClone(): never {
1156
- halt("validateClone");
1157
- }
1158
- Object.assign(validateClone, Namespace.validate());
1159
- Object.assign(validateClone, Namespace.clone("validateClone"));
1160
-
1161
- /**
1162
- * Prune, erase superfluous properties.
1163
- *
1164
- * Remove every superfluous properties from the `input` object, even including nested
1165
- * objects. Note that, as every superfluous properties would be deleted, you never can
1166
- * read those superfluous properties after calling this `prune()` function.
1167
- *
1168
- * For reference, this `typia.prune()` function does not validate the input value type.
1169
- * It just believes that the input value is following the type `T`. Therefore, if you
1170
- * can't ensure the input value type, it would better to call one of below functions
1171
- * instead.
1172
- *
1173
- * - {@link assertPrune}
1174
- * - {@link isPrune}
1175
- * - {@link validatePrune}
1176
- *
1177
- * @template T Type of the input value
1178
- * @param input Target instance to prune
1179
- *
1180
- * @author Jeongho Nam - https://github.com/samchon
1181
- */
1182
- export function prune<T extends object>(input: T): void;
1183
-
1184
- /**
1185
- * @internal
1186
- */
1187
- export function prune(): never {
1188
- halt("prune");
1189
- }
1190
- Object.assign(prune, Namespace.prune("prune"));
1191
-
1192
- /**
1193
- * Prune, erase superfluous properties, with type assertion.
1194
- *
1195
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1196
- * Therefore, it removes every superfluous properties from the `input` object including
1197
- * nested objects, with type assertion.
1198
- *
1199
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1200
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1201
- * every superfluous properties would be removed, including nested objects.
1202
- *
1203
- * @template T Type of the input value
1204
- * @param input Target instance to assert and prune
1205
- *
1206
- * @author Jeongho Nam - https://github.com/samchon
1207
- */
1208
- export function assertPrune<T>(input: T): T;
1209
-
1210
- /**
1211
- * Prune, erase superfluous properties, with type assertion.
1212
- *
1213
- * `typia.assertPrune()` is a combination function of {@link assert} and {@link prune}.
1214
- * Therefore, it removes every superfluous properties from the `input` object including
1215
- * nested objects, with type assertion.
1216
- *
1217
- * In such reason, when `input` value is not matched with the type `T`, it throws an
1218
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, its
1219
- * every superfluous properties would be removed, including nested objects.
1220
- *
1221
- * @template T Type of the input value
1222
- * @param input Target instance to assert and prune
1223
- *
1224
- * @author Jeongho Nam - https://github.com/samchon
1225
- */
1226
- export function assertPrune<T>(input: unknown): T;
1227
-
1228
- /**
1229
- * @internal
1230
- */
1231
- export function assertPrune(): unknown {
1232
- halt("assertPrune");
1233
- }
1234
- Object.assign(assertPrune, Namespace.assert("assertPrune"));
1235
- Object.assign(assertPrune, Namespace.prune("assertPrune"));
1236
-
1237
- /**
1238
- * Prune, erase superfluous properties, with type checking.
1239
- *
1240
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1241
- * Therefore, it removes every superfluous properties from the `input` object including
1242
- * nested objects, with type checking.
1243
- *
1244
- * In such reason, when `input` value is not matched with the type `T`, it returns
1245
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1246
- * `true` after removing every superfluous properties, including nested objects.
1247
- *
1248
- * @template T Type of the input value
1249
- * @param input Target instance to check and prune
1250
- * @returns Whether the parametric value is following the type `T` or not
1251
- *
1252
- * @author Jeongho Nam - https://github.com/samchon
1253
- */
1254
- export function isPrune<T>(input: T): input is T;
1255
-
1256
- /**
1257
- * Prune, erase superfluous properties, with type checking.
1258
- *
1259
- * `typia.assertPrune()` is a combination function of {@link is} and {@link prune}.
1260
- * Therefore, it removes every superfluous properties from the `input` object including
1261
- * nested objects, with type checking.
1262
- *
1263
- * In such reason, when `input` value is not matched with the type `T`, it returns
1264
- * `false` value. Otherwise, there's no problem on the `input` value, it returns
1265
- * `true` after removing every superfluous properties, including nested objects.
1266
- *
1267
- * @template T Type of the input value
1268
- * @param input Target instance to check and prune
1269
- * @returns Whether the parametric value is following the type `T` or not
1270
- *
1271
- * @author Jeongho Nam - https://github.com/samchon
1272
- */
1273
- export function isPrune<T>(input: unknown): input is T;
1274
-
1275
- /**
1276
- * @internal
1277
- */
1278
- export function isPrune(): never {
1279
- halt("isPrune");
1280
- }
1281
- Object.assign(isPrune, Namespace.is());
1282
- Object.assign(isPrune, Namespace.prune("isPrune"));
1283
-
1284
- /**
1285
- * Prune, erase superfluous properties, with type validation.
1286
- *
1287
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1288
- * Therefore, it removes every superfluous properties from the `input` object including
1289
- * nested objects, with type validation.
1290
- *
1291
- * In such reason, when `input` value is not matched with the type `T`, it returns
1292
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1293
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1294
- * removing every superfluous properties, including nested objects.
1295
- *
1296
- * @template T Type of the input value
1297
- * @param input Target instance to validate and prune
1298
- * @returns Validation result
1299
- *
1300
- * @author Jeongho Nam - https://github.com/samchon
1301
- */
1302
- export function validatePrune<T>(input: T): IValidation<T>;
1303
-
1304
- /**
1305
- * Prune, erase superfluous properties, with type validation.
1306
- *
1307
- * `typia.validatePrune()` is a combination function of {@link validate} and {@link prune}.
1308
- * Therefore, it removes every superfluous properties from the `input` object including
1309
- * nested objects, with type validation.
1310
- *
1311
- * In such reason, when `input` value is not matched with the type `T`, it returns
1312
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
1313
- * no problem on the `input` value, it returns {@link IValidation.ISucess} value after
1314
- * removing every superfluous properties, including nested objects.
1315
- *
1316
- * @template T Type of the input value
1317
- * @param input Target instance to validate and prune
1318
- * @returns Validation result
1319
- *
1320
- * @author Jeongho Nam - https://github.com/samchon
1321
- */
1322
- export function validatePrune<T>(input: unknown): IValidation<T>;
1323
-
1324
- /**
1325
- * @internal
1326
- */
1327
- export function validatePrune<T>(): IValidation<T> {
1328
- halt("validatePrune");
1329
- }
1330
- Object.assign(validatePrune, Namespace.prune("validatePrune"));
1331
- Object.assign(validatePrune, Namespace.validate());
1332
-
1333
- /* ===========================================================
1334
- FACTORY FUNCTIONS
1335
- - BASIC VALIDATORS
1336
- - STRICT VALIDATORS
1337
- - JSON FUNCTIONS
1338
- - MISCELLANEOUS
1339
- ==============================================================
1340
- BASIC VALIDATORS
1341
- ----------------------------------------------------------- */
1342
- /**
1343
- * Creates a reusable {@link assert} function.
1344
- *
1345
- * @danger You have to specify the generic argument `T`
1346
- * @return Nothing until specifying the generic argument `T`
1347
- * @throws compile error
1348
- *
1349
- * @author Jeongho Nam - https://github.com/samchon
1350
- */
1351
- export function createAssert(): never;
1352
-
1353
- /**
1354
- * Creates a reusable {@link assert} function.
1355
- *
1356
- * @template T Type of the input value
1357
- * @returns A reusable `assert` function
1358
- *
1359
- * @author Jeongho Nam - https://github.com/samchon
1360
- */
1361
- export function createAssert<T>(): (input: unknown) => T;
1362
-
1363
- /**
1364
- * @internal
1365
- */
1366
- export function createAssert<T>(): (input: unknown) => T {
1367
- halt("createAssert");
1368
- }
1369
- Object.assign(createAssert, assert);
1370
-
1371
- /**
1372
- * Creates a reusable {@link assertType} function.
1373
- *
1374
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1375
- *
1376
- * @danger You have to specify the generic argument `T`
1377
- * @return Nothing until specifying the generic argument `T`
1378
- * @throws compile error
1379
- *
1380
- * @author Jeongho Nam - https://github.com/samchon
1381
- * @deprecated
1382
- */
1383
- export function createAssertType(): never;
1384
-
1385
- /**
1386
- * Creates a reusable {@link assertType} function.
1387
- *
1388
- * Duplicated function of {@link createAssert} for `typescript-is` users.
1389
- *
1390
- * @template T Type of the input value
1391
- * @returns A reusable `assert` function
1392
- *
1393
- * @author Jeongho Nam - https://github.com/samchon
1394
- * @deprecated
1395
- */
1396
- export function createAssertType<T>(): (input: unknown) => T;
1397
-
1398
- /**
1399
- * @internal
1400
- */
1401
- export function createAssertType<T>(): (input: unknown) => T {
1402
- halt("createAssertType");
1403
- }
1404
- Object.assign(createAssertType, assertType);
1405
-
1406
- /**
1407
- * Creates a reusable {@link is} function.
1408
- *
1409
- * @danger You have to specify the generic argument `T`
1410
- * @return Nothing until specifying the generic argument `T`
1411
- * @throws compile error
1412
- *
1413
- * @author Jeongho Nam - https://github.com/samchon
1414
- */
1415
- export function createIs(): never;
1416
-
1417
- /**
1418
- * Creates a reusable {@link is} function.
1419
- *
1420
- * @template T Type of the input value
1421
- * @returns A reusable `is` function
1422
- *
1423
- * @author Jeongho Nam - https://github.com/samchon
1424
- */
1425
- export function createIs<T>(): (input: unknown) => input is T;
1426
-
1427
- /**
1428
- * @internal
1429
- */
1430
- export function createIs<T>(): (input: unknown) => input is T {
1431
- halt("createIs");
1432
- }
1433
- Object.assign(createIs, is);
1434
-
1435
- /**
1436
- * Creates a reusable {@link validate} function.
1437
- *
1438
- * @danger You have to specify the generic argument `T`
1439
- * @return Nothing until specifying the generic argument `T`
1440
- * @throws compile error
1441
- *
1442
- * @author Jeongho Nam - https://github.com/samchon
1443
- */
1444
- export function createValidate(): never;
1445
-
1446
- /**
1447
- * Creates a reusable {@link validate} function.
1448
- *
1449
- * @template T Type of the input value
1450
- * @returns A reusable `validate` function
1451
- *
1452
- * @author Jeongho Nam - https://github.com/samchon
1453
- */
1454
- export function createValidate<T>(): (input: unknown) => IValidation<T>;
1455
-
1456
- /**
1457
- * @internal
1458
- */
1459
- export function createValidate(): (input: unknown) => IValidation {
1460
- halt("createValidate");
1461
- }
1462
- Object.assign(createValidate, validate);
1463
-
1464
- /* -----------------------------------------------------------
1465
- STRICT VALIDATORS
1466
- ----------------------------------------------------------- */
1467
- /**
1468
- * Creates a reusable {@link assertEquals} function.
1469
- *
1470
- * @danger You have to specify the generic argument `T`
1471
- * @return Nothing until specifying the generic argument `T`
1472
- * @throws compile error
1473
- *
1474
- * @author Jeongho Nam - https://github.com/samchon
1475
- */
1476
- export function createAssertEquals(): never;
1477
-
1478
- /**
1479
- * Creates a reusable {@link assertEquals} function.
1480
- *
1481
- * @template T Type of the input value
1482
- * @returns A reusable `assertEquals` function
1483
- *
1484
- * @author Jeongho Nam - https://github.com/samchon
1485
- */
1486
- export function createAssertEquals<T>(): (input: unknown) => T;
1487
-
1488
- /**
1489
- * @internal
1490
- */
1491
- export function createAssertEquals<T>(): (input: unknown) => T {
1492
- halt("createAssertEquals");
1493
- }
1494
- Object.assign(createAssertEquals, assertEquals);
1495
-
1496
- /**
1497
- * Creates a reusable {@link equals} function.
1498
- *
1499
- * @danger You have to specify the generic argument `T`
1500
- * @return Nothing until specifying the generic argument `T`
1501
- * @throws compile error
1502
- *
1503
- * @author Jeongho Nam - https://github.com/samchon
1504
- */
1505
- export function createEquals(): never;
1506
-
1507
- /**
1508
- * Creates a reusable {@link equals} function.
1509
- *
1510
- * @template T Type of the input value
1511
- * @returns A reusable `equals` function
1512
- *
1513
- * @author Jeongho Nam - https://github.com/samchon
1514
- */
1515
- export function createEquals<T>(): (input: unknown) => input is T;
1516
-
1517
- /**
1518
- * @internal
1519
- */
1520
- export function createEquals<T>(): (input: unknown) => input is T {
1521
- halt("createEquals");
1522
- }
1523
- Object.assign(createEquals, equals);
1524
-
1525
- /**
1526
- * Creates a reusable {@link validateEquals} function.
1527
- *
1528
- * @danger You have to specify the generic argument `T`
1529
- * @return Nothing until specifying the generic argument `T`
1530
- * @throws compile error
1531
- *
1532
- * @author Jeongho Nam - https://github.com/samchon
1533
- */
1534
- export function createValidateEquals(): never;
1535
-
1536
- /**
1537
- * Creates a reusable {@link validateEquals} function.
1538
- *
1539
- * @template T Type of the input value
1540
- * @returns A reusable `validateEquals` function
1541
- *
1542
- * @author Jeongho Nam - https://github.com/samchon
1543
- */
1544
- export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
1545
-
1546
- /**
1547
- * @internal
1548
- */
1549
- export function createValidateEquals(): (input: unknown) => IValidation {
1550
- halt("createValidateEquals");
1551
- }
1552
- Object.assign(createValidateEquals, validateEquals);
1553
-
1554
- /* -----------------------------------------------------------
1555
- JSON FUNCTIONS
1556
- ----------------------------------------------------------- */
1557
- /**
1558
- * Creates a reusable {@link isParse} function.
1559
- *
1560
- * @danger You have to specify the generic argument `T`
1561
- * @return Nothing until specifying the generic argument `T`
1562
- * @throws compile error
1563
- *
1564
- * @author Jeongho Nam - https://github.com/samchon
1565
- */
1566
- export function createIsParse(): never;
1567
-
1568
- /**
1569
- * Creates a reusable {@link isParse} function.
1570
- *
1571
- * @template T Expected type of parsed value
1572
- * @returns A reusable `isParse` function
1573
- *
1574
- * @author Jeongho Nam - https://github.com/samchon
1575
- */
1576
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
1577
-
1578
- /**
1579
- * @internal
1580
- */
1581
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
1582
- halt("createIsParse");
1583
- }
1584
- Object.assign(createIsParse, isParse);
1585
-
1586
- /**
1587
- * Creates a reusable {@link assertParse} function.
1588
- *
1589
- * @danger You have to specify the generic argument `T`
1590
- * @return Nothing until specifying the generic argument `T`
1591
- * @throws compile error
1592
- *
1593
- * @author Jeongho Nam - https://github.com/samchon
1594
- */
1595
- export function createAssertParse(): never;
1596
-
1597
- /**
1598
- * Creates a reusable {@link assertParse} function.
1599
- *
1600
- * @template T Expected type of parsed value
1601
- * @returns A reusable `assertParse` function
1602
- *
1603
- * @author Jeongho Nam - https://github.com/samchon
1604
- */
1605
- export function createAssertParse<T>(): (input: string) => Primitive<T>;
1606
-
1607
- /**
1608
- * @internal
1609
- */
1610
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
1611
- halt("createAssertParse");
1612
- }
1613
- Object.assign(createAssertParse, assertParse);
1614
-
1615
- /**
1616
- * Creates a reusable {@link validateParse} function.
1617
- *
1618
- * @danger You have to specify the generic argument `T`
1619
- * @return Nothing until specifying the generic argument `T`
1620
- * @throws compile error
1621
- *
1622
- * @author Jeongho Nam - https://github.com/samchon
1623
- */
1624
- export function createValidateParse(): never;
1625
-
1626
- /**
1627
- * Creates a reusable {@link validateParse} function.
1628
- *
1629
- * @template T Expected type of parsed value
1630
- * @returns A reusable `validateParse` function
1631
- *
1632
- * @author Jeongho Nam - https://github.com/samchon
1633
- */
1634
- export function createValidateParse<T>(): (
1635
- input: string,
1636
- ) => IValidation<Primitive<T>>;
1637
-
1638
- /**
1639
- * @internal
1640
- */
1641
- export function createValidateParse<T>(): (
1642
- input: string,
1643
- ) => IValidation<Primitive<T>> {
1644
- halt("createValidateParse");
1645
- }
1646
- Object.assign(createValidateParse, validateParse);
1647
-
1648
- /**
1649
- * Creates a reusable {@link stringify} function.
1650
- *
1651
- * @danger You have to specify the generic argument `T`
1652
- * @return Nothing until specifying the generic argument `T`
1653
- * @throws compile error
1654
- *
1655
- * @author Jeongho Nam - https://github.com/samchon
1656
- */
1657
- export function createStringify(): never;
1658
-
1659
- /**
1660
- * Creates a reusable {@link stringify} function.
1661
- *
1662
- * @template T Type of the input value
1663
- * @returns A reusable `stringify` function
1664
- *
1665
- * @author Jeongho Nam - https://github.com/samchon
1666
- */
1667
- export function createStringify<T>(): (input: T) => string;
1668
-
1669
- /**
1670
- * @internal
1671
- */
1672
- export function createStringify<T>(): (input: T) => string {
1673
- halt("createStringify");
1674
- }
1675
- Object.assign(createStringify, stringify);
1676
-
1677
- /**
1678
- * Creates a reusable {@link assertStringify} function.
1679
- *
1680
- * @danger You have to specify the generic argument `T`
1681
- * @return Nothing until specifying the generic argument `T`
1682
- * @throws compile error
1683
- *
1684
- * @author Jeongho Nam - https://github.com/samchon
1685
- */
1686
- export function createAssertStringify(): never;
1687
-
1688
- /**
1689
- * Creates a reusable {@link assertStringify} function.
1690
- *
1691
- * @template T Type of the input value
1692
- * @returns A reusable `assertStringify` function
1693
- *
1694
- * @author Jeongho Nam - https://github.com/samchon
1695
- */
1696
- export function createAssertStringify<T>(): (input: unknown) => string;
1697
-
1698
- /**
1699
- * @internal
1700
- */
1701
- export function createAssertStringify(): (input: unknown) => string {
1702
- halt("createAssertStringify");
1703
- }
1704
- Object.assign(createAssertStringify, assertStringify);
1705
-
1706
- /**
1707
- * Creates a reusable {@link isStringify} function.
1708
- *
1709
- * @danger You have to specify the generic argument `T`
1710
- * @return Nothing until specifying the generic argument `T`
1711
- * @throws compile error
1712
- *
1713
- * @author Jeongho Nam - https://github.com/samchon
1714
- */
1715
- export function createIsStringify(): never;
1716
-
1717
- /**
1718
- * Creates a reusable {@link isStringify} function.
1719
- *
1720
- * @template T Type of the input value
1721
- * @returns A reusable `isStringify` function
1722
- *
1723
- * @author Jeongho Nam - https://github.com/samchon
1724
- */
1725
- export function createIsStringify<T>(): (input: unknown) => string | null;
1726
-
1727
- /**
1728
- * @internal
1729
- */
1730
- export function createIsStringify(): (input: unknown) => string | null {
1731
- halt("createIsStringify");
1732
- }
1733
- Object.assign(createIsStringify, isStringify);
1734
-
1735
- /**
1736
- * Creates a reusable {@link validateStringify} function.
1737
- *
1738
- * @danger You have to specify the generic argument `T`
1739
- * @return Nothing until specifying the generic argument `T`
1740
- * @throws compile error
1741
- *
1742
- * @author Jeongho Nam - https://github.com/samchon
1743
- */
1744
- export function createValidateStringify(): never;
1745
-
1746
- /**
1747
- * Creates a reusable {@link validateStringify} function.
1748
- *
1749
- * @template T Type of the input value
1750
- * @returns A reusable `validateStringify` function
1751
-
1752
- * @author Jeongho Nam - https://github.com/samchon
1753
- */
1754
- export function createValidateStringify<T>(): (
1755
- input: unknown,
1756
- ) => IValidation<string>;
1757
-
1758
- /**
1759
- * @internal
1760
- */
1761
- export function createValidateStringify(): (
1762
- input: unknown,
1763
- ) => IValidation<string> {
1764
- halt("createValidateStringify");
1765
- }
1766
- Object.assign(createValidateStringify, validateStringify);
1767
-
1768
- /* -----------------------------------------------------------
1769
- MISCELLANEOUS
1770
- ----------------------------------------------------------- */
1771
- /**
1772
- * Creates a reusable {@link random} function.
1773
- *
1774
- * @danger You have to specify the generic argument `T`
1775
- * @param generator Random data generator
1776
- * @return Nothing until specifying the generic argument `T`
1777
- * @throws compile error
1778
- *
1779
- * @author Jeongho Nam - https://github.com/samchon
1780
- */
1781
- export function createRandom(generator?: Partial<IRandomGenerator>): never;
1782
-
1783
- /**
1784
- * Creates a resuable {@link random} function.
1785
- *
1786
- * @template T Type of the input value
1787
- * @param generator Random data generator
1788
- * @returns A reusable `random` function
1789
- *
1790
- * @author Jeongho Nam - https://github.com/samchon
1791
- */
1792
- export function createRandom<T>(
1793
- generator?: Partial<IRandomGenerator>,
1794
- ): () => Primitive<T>;
1795
-
1796
- /**
1797
- * @internal
1798
- */
1799
- export function createRandom(): never {
1800
- halt("createRandom");
1801
- }
1802
- Object.assign(createRandom, random);
1803
-
1804
- /**
1805
- * Creates a reusable {@link clone} function.
1806
- *
1807
- * @danger You have to specify the generic argument `T`
1808
- * @return Nothing until specifying the generic argument `T`
1809
- * @throws compile error
1810
- *
1811
- * @author Jeongho Nam - https://github.com/samchon
1812
- */
1813
- export function createClone(): never;
1814
-
1815
- /**
1816
- * Creates a resuable {@link clone} function.
1817
- *
1818
- * @template T Type of the input value
1819
- * @returns A reusable `clone` function
1820
- *
1821
- * @author Jeongho Nam - https://github.com/samchon
1822
- */
1823
- export function createClone<T>(): (input: T) => Primitive<T>;
1824
-
1825
- /**
1826
- * @internal
1827
- */
1828
- export function createClone(): never {
1829
- halt("createClone");
1830
- }
1831
- Object.assign(createClone, clone);
1832
-
1833
- /**
1834
- * Creates a reusable {@link assertClone} function.
1835
- *
1836
- * @danger You have to specify the generic argument `T`
1837
- * @return Nothing until specifying the generic argument `T`
1838
- * @throws compile error
1839
- *
1840
- * @author Jeongho Nam - https://github.com/samchon
1841
- */
1842
- export function createAssertClone(): never;
1843
-
1844
- /**
1845
- * Creates a resuable {@link assertClone} function.
1846
- *
1847
- * @template T Type of the input value
1848
- * @returns A reusable `clone` function
1849
- *
1850
- * @author Jeongho Nam - https://github.com/samchon
1851
- */
1852
- export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
1853
-
1854
- /**
1855
- * @internal
1856
- */
1857
- export function createAssertClone(): never {
1858
- halt("createAssertClone");
1859
- }
1860
- Object.assign(createAssertClone, assertClone);
1861
-
1862
- /**
1863
- * Creates a reusable {@link isClone} function.
1864
- *
1865
- * @danger You have to specify the generic argument `T`
1866
- * @return Nothing until specifying the generic argument `T`
1867
- * @throws compile error
1868
- *
1869
- * @author Jeongho Nam - https://github.com/samchon
1870
- */
1871
- export function createIsClone(): never;
1872
-
1873
- /**
1874
- * Creates a resuable {@link isClone} function.
1875
- *
1876
- * @template T Type of the input value
1877
- * @returns A reusable `clone` function
1878
- *
1879
- * @author Jeongho Nam - https://github.com/samchon
1880
- */
1881
- export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
1882
-
1883
- /**
1884
- * @internal
1885
- */
1886
- export function createIsClone(): never {
1887
- halt("createIsClone");
1888
- }
1889
- Object.assign(createIsClone, isClone);
1890
-
1891
- /**
1892
- * Creates a reusable {@link validateClone} function.
1893
- *
1894
- * @danger You have to specify the generic argument `T`
1895
- * @return Nothing until specifying the generic argument `T`
1896
- * @throws compile error
1897
- *
1898
- * @author Jeongho Nam - https://github.com/samchon
1899
- */
1900
- export function createValidateClone(): never;
1901
-
1902
- /**
1903
- * Creates a resuable {@link validateClone} function.
1904
- *
1905
- * @template T Type of the input value
1906
- * @returns A reusable `clone` function
1907
- *
1908
- * @author Jeongho Nam - https://github.com/samchon
1909
- */
1910
- export function createValidateClone<T>(): (
1911
- input: unknown,
1912
- ) => IValidation<Primitive<T>>;
1913
-
1914
- /**
1915
- * @internal
1916
- */
1917
- export function createValidateClone(): never {
1918
- halt("createValidateClone");
1919
- }
1920
- Object.assign(createValidateClone, validateClone);
1921
-
1922
- /**
1923
- * Creates a reusable {@link prune} function.
1924
- *
1925
- * @danger You have to specify the generic argument `T`
1926
- * @return Nothing until specifying the generic argument `T`
1927
- * @throws compile error
1928
- *
1929
- * @author Jeongho Nam - https://github.com/samchon
1930
- */
1931
- export function createPrune(): never;
1932
-
1933
- /**
1934
- * Creates a resuable {@link prune} function.
1935
- *
1936
- * @template T Type of the input value
1937
- * @returns A reusable `prune` function
1938
- *
1939
- * @author Jeongho Nam - https://github.com/samchon
1940
- */
1941
- export function createPrune<T extends object>(): (input: T) => void;
1942
-
1943
- /**
1944
- * @internal
1945
- */
1946
- export function createPrune<T extends object>(): (input: T) => void {
1947
- halt("createPrune");
1948
- }
1949
- Object.assign(createPrune, prune);
1950
-
1951
- /**
1952
- * Creates a reusable {@link assertPrune} function.
1953
- *
1954
- * @danger You have to specify the generic argument `T`
1955
- * @return Nothing until specifying the generic argument `T`
1956
- * @throws compile error
1957
- *
1958
- * @author Jeongho Nam - https://github.com/samchon
1959
- */
1960
- export function createAssertPrune(): never;
1961
-
1962
- /**
1963
- * Creates a resuable {@link assertPrune} function.
1964
- *
1965
- * @template T Type of the input value
1966
- * @returns A reusable `isPrune` function
1967
- *
1968
- * @author Jeongho Nam - https://github.com/samchon
1969
- */
1970
- export function createAssertPrune<T extends object>(): (input: T) => T;
1971
-
1972
- /**
1973
- * @internal
1974
- */
1975
- export function createAssertPrune<T extends object>(): (input: T) => T {
1976
- halt("createAssertPrune");
1977
- }
1978
- Object.assign(createAssertPrune, assertPrune);
1979
-
1980
- /**
1981
- * Creates a reusable {@link isPrune} function.
1982
- *
1983
- * @danger You have to specify the generic argument `T`
1984
- * @return Nothing until specifying the generic argument `T`
1985
- * @throws compile error
1986
- *
1987
- * @author Jeongho Nam - https://github.com/samchon
1988
- */
1989
- export function createIsPrune(): never;
1990
-
1991
- /**
1992
- * Creates a resuable {@link isPrune} function.
1993
- *
1994
- * @template T Type of the input value
1995
- * @returns A reusable `isPrune` function
1996
- *
1997
- * @author Jeongho Nam - https://github.com/samchon
1998
- */
1999
- export function createIsPrune<T extends object>(): (input: T) => input is T;
2000
-
2001
- /**
2002
- * @internal
2003
- */
2004
- export function createIsPrune<T extends object>(): (input: T) => input is T {
2005
- halt("createIsPrune");
2006
- }
2007
- Object.assign(createIsPrune, isPrune);
2008
-
2009
- /**
2010
- * Creates a reusable {@link validatePrune} function.
2011
- *
2012
- * @danger You have to specify the generic argument `T`
2013
- * @return Nothing until specifying the generic argument `T`
2014
- * @throws compile error
2015
- *
2016
- * @author Jeongho Nam - https://github.com/samchon
2017
- */
2018
- export function createValidatePrune(): never;
2019
-
2020
- /**
2021
- * Creates a resuable {@link validatePrune} function.
2022
- *
2023
- * @template T Type of the input value
2024
- * @returns A reusable `validatePrune` function
2025
- *
2026
- * @author Jeongho Nam - https://github.com/samchon
2027
- */
2028
- export function createValidatePrune<T extends object>(): (
2029
- input: T,
2030
- ) => IValidation<T>;
2031
-
2032
- /**
2033
- * @internal
2034
- */
2035
- export function createValidatePrune<T extends object>(): (
2036
- input: T,
2037
- ) => IValidation<T> {
2038
- halt("createValidatePrune");
2039
- }
2040
- Object.assign(createValidatePrune, validatePrune);
2041
-
2042
- /**
2043
- * @internal
2044
- */
2045
- function halt(name: string): never {
2046
- throw new Error(
2047
- `Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
2048
- );
2049
- }
1
+ import { $dictionary } from "./functional/$dictionary";
2
+ import { Namespace } from "./functional/Namespace";
3
+
4
+ import { IMetadataApplication } from "./metadata/IMetadataApplication";
5
+
6
+ import { MapUtil } from "./utils/MapUtil";
7
+
8
+ import { CustomValidatorMap } from "./CustomValidatorMap";
9
+ import { IRandomGenerator } from "./IRandomGenerator";
10
+ import { IValidation } from "./IValidation";
11
+ import { Primitive } from "./Primitive";
12
+
13
+ export * as json from "./json";
14
+ export * as protobuf from "./protobuf";
15
+ export * as misc from "./misc";
16
+
17
+ export * from "./schemas/IJsonApplication";
18
+ export * from "./schemas/IJsonComponents";
19
+ export * from "./schemas/IJsonSchema";
20
+ export * from "./IRandomGenerator";
21
+ export * from "./IValidation";
22
+ export * from "./Primitive";
23
+ export * from "./TypeGuardError";
24
+
25
+ /**
26
+ * Custom validators.
27
+ *
28
+ * If you want to add a custom validation logic utilizing comment tags,
29
+ * add a closure function with its tag and type name. Below example code
30
+ * would helpful to understand how to use this instance.
31
+ *
32
+ * ```ts
33
+ * typia.customValidators.insert("powerOf")("number")(
34
+ * (text: string) => {
35
+ * const denominator: number = Math.log(Number(text));
36
+ * return (value: number) => {
37
+ * value = Math.log(value) / denominator;
38
+ * return value === Math.floor(value);
39
+ * };
40
+ * }
41
+ * );
42
+ * typia.customValidators.insert("dollar")("string")(
43
+ * () => (value: string) => value.startsWith("$"),
44
+ * );
45
+ *
46
+ * interface TagCustom {
47
+ * /**
48
+ * * @powerOf 10
49
+ * *\/
50
+ * powerOf: number;
51
+ *
52
+ * /**
53
+ * * @dollar
54
+ * *\/
55
+ * dollar: string;
56
+ * }
57
+ * ```
58
+ *
59
+ * @author Jeongho Nam - https://github.com/samchon
60
+ */
61
+ export const customValidators: CustomValidatorMap = {
62
+ size: (name?: string) =>
63
+ name ? $dictionary.get(name)?.size ?? 0 : $dictionary.size,
64
+ has: (name) => (type) => $dictionary.get(name)?.has(type) ?? false,
65
+ get: (name) => (type) => $dictionary.get(name)?.get(type),
66
+ insert: (name) => (type) => (closure) => {
67
+ const internal = MapUtil.take($dictionary)(name, () => new Map());
68
+ if (internal.has(type)) return false;
69
+ internal.set(type, closure);
70
+ return true;
71
+ },
72
+ erase: (name) => (type) => $dictionary.get(name)?.delete(type) ?? false,
73
+ };
74
+
75
+ /* -----------------------------------------------------------
76
+ BASIC VALIDATORS
77
+ ----------------------------------------------------------- */
78
+ /**
79
+ * Asserts a value type.
80
+ *
81
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
82
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
83
+ * value is following the type `T`, just input parameter would be returned.
84
+ *
85
+ * If what you want is not asserting but just knowing whether the parametric value is
86
+ * following the type `T` or not, you can choose the {@link is} function instead.
87
+ * Otherwise you want to know all the errors, {@link validate} is the way to go.
88
+ *
89
+ * On the other and, if you don't want to allow any superfluous property that is not
90
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
91
+ *
92
+ * @template T Type of the input value
93
+ * @param input A value to be asserted
94
+ * @returns Parametric input value
95
+ * @throws A {@link TypeGuardError} instance with detailed reason
96
+ *
97
+ * @author Jeongho Nam - https://github.com/samchon
98
+ */
99
+ export function assert<T>(input: T): T;
100
+
101
+ /**
102
+ * Asserts a value type.
103
+ *
104
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
105
+ * reason, if the parametric value is not following the type `T`. Otherwise, the
106
+ * value is following the type `T`, just input parameter would be returned.
107
+ *
108
+ * If what you want is not asserting but just knowing whether the parametric value is
109
+ * following the type `T` or not, you can choose the {@link is} function instead.
110
+ * Otherwise, you want to know all the errors, {@link validate} is the way to go.
111
+ *
112
+ * On the other and, if you don't want to allow any superfluous property that is not
113
+ * enrolled to the type `T`, you can use {@link assertEquals} function instead.
114
+ *
115
+ * @template T Type of the input value
116
+ * @param input A value to be asserted
117
+ * @returns Parametric input value casted as `T`
118
+ * @throws A {@link TypeGuardError} instance with detailed reason
119
+ *
120
+ * @author Jeongho Nam - https://github.com/samchon
121
+ */
122
+ export function assert<T>(input: unknown): T;
123
+
124
+ /**
125
+ * @internal
126
+ */
127
+ export function assert(): never {
128
+ halt("assert");
129
+ }
130
+ Object.assign(assert, Namespace.assert("assert"));
131
+
132
+ /**
133
+ * Asserts a value type.
134
+ *
135
+ * Duplicated function of {@link assert} for `typescript-is` users.
136
+ *
137
+ * @template T Type of the input value
138
+ * @param input A value to be asserted
139
+ * @returns Parametric input value
140
+ * @throws A {@link TypeGuardError} instance with detailed reason
141
+ *
142
+ * @author Jeongho Nam - https://github.com/samchon
143
+ * @deprecated
144
+ */
145
+ export function assertType<T>(input: T): T;
146
+
147
+ /**
148
+ * Asserts a value type.
149
+ *
150
+ * Duplicated function of {@link assert} for `typescript-is` users.
151
+ *
152
+ * @template T Type of the input value
153
+ * @param input A value to be asserted
154
+ * @returns Parametric input value
155
+ * @throws A {@link TypeGuardError} instance with detailed reason
156
+ *
157
+ * @author Jeongho Nam - https://github.com/samchon
158
+ * @deprecated
159
+ */
160
+ export function assertType<T>(input: unknown): T;
161
+
162
+ /**
163
+ * @internal
164
+ */
165
+ export function assertType(): never {
166
+ halt("assertType");
167
+ }
168
+ Object.assign(assertType, Namespace.assert("assertType"));
169
+
170
+ /**
171
+ * Tests a value type.
172
+ *
173
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
174
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
175
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
176
+ * returned.
177
+ *
178
+ * If what you want is not just knowing whether the parametric value is following the
179
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
180
+ * {@link assert} function instead. Also, if you want to know all the errors with
181
+ * detailed reasons, {@link validate} function would be useful.
182
+ *
183
+ * On the other and, if you don't want to allow any superfluous property that is not
184
+ * enrolled to the type `T`, you can use {@link equals} function instead.
185
+ *
186
+ * @template T Type of the input value
187
+ * @param input A value to be tested
188
+ * @returns Whether the parametric value is following the type `T` or not
189
+ *
190
+ * @author Jeongho Nam - https://github.com/samchon
191
+ */
192
+ export function is<T>(input: T): input is T;
193
+
194
+ /**
195
+ * Tests a value type.
196
+ *
197
+ * Tests a parametric value type and returns whether it's following the type `T` or not.
198
+ * If the parametric value is matched with the type `T`, `true` value would be returned.
199
+ * Otherwise, the parametric value is not following the type `T`, `false` value would be
200
+ * returned.
201
+ *
202
+ * If what you want is not just knowing whether the parametric value is following the
203
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
204
+ * {@link assert} function instead. Also, if you want to know all the errors with
205
+ * detailed reasons, {@link validate} function would be useful.
206
+ *
207
+ * On the other and, if you don't want to allow any superfluous property that is not
208
+ * enrolled to the type `T`, you can use {@link equals} function instead.
209
+ *
210
+ * @template T Type of the input value
211
+ * @param input A value to be tested
212
+ * @returns Whether the parametric value is following the type `T` or not
213
+ *
214
+ * @author Jeongho Nam - https://github.com/samchon
215
+ */
216
+ export function is<T>(input: unknown): input is T;
217
+
218
+ /**
219
+ * @internal
220
+ */
221
+ export function is(): never {
222
+ halt("is");
223
+ }
224
+ Object.assign(is, Namespace.assert("is"));
225
+
226
+ /**
227
+ * Validates a value type.
228
+ *
229
+ * Validates a parametric value type and archives all the type errors into an
230
+ * {@link IValidation.errors} array, if the parametric value is not following the
231
+ * type `T`. Of course, if the parametric value is following the type `T`, the
232
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
233
+ * would have the `true` value.
234
+ *
235
+ * If what you want is not finding all the error, but asserting the parametric value
236
+ * type with exception throwing, you can choose {@link assert} function instead.
237
+ * Otherwise, you just want to know whether the parametric value is matched with the
238
+ * type `T`, {@link is} function is the way to go.
239
+ *
240
+ * On the other and, if you don't want to allow any superfluous property that is not
241
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
242
+ *
243
+ * @template Type of the input value
244
+ * @param input A value to be validated
245
+ * @returns Validation result
246
+ *
247
+ * @author Jeongho Nam - https://github.com/samchon
248
+ */
249
+ export function validate<T>(input: T): IValidation<T>;
250
+
251
+ /**
252
+ * Validates a value type.
253
+ *
254
+ * Validates a parametric value type and archives all the type errors into an
255
+ * {@link IValidation.errors} array, if the parametric value is not following the
256
+ * type `T`. Of course, if the parametric value is following the type `T`, the
257
+ * {@link IValidation.errors} array would be empty and {@link IValidation.success}
258
+ * would have the `true` value.
259
+ *
260
+ * If what you want is not finding all the error, but asserting the parametric value
261
+ * type with exception throwing, you can choose {@link assert} function instead.
262
+ * Otherwise, you just want to know whether the parametric value is matched with the
263
+ * type `T`, {@link is} function is the way to go.
264
+ *
265
+ * On the other and, if you don't want to allow any superfluous property that is not
266
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
267
+ *
268
+ * @template Type of the input value
269
+ * @param input A value to be validated
270
+ * @returns Validation result
271
+ *
272
+ * @author Jeongho Nam - https://github.com/samchon
273
+ */
274
+ export function validate<T>(input: unknown): IValidation<T>;
275
+
276
+ /**
277
+ * @internal
278
+ */
279
+ export function validate(): never {
280
+ halt("validate");
281
+ }
282
+ Object.assign(validate, Namespace.validate());
283
+
284
+ /* -----------------------------------------------------------
285
+ STRICT VALIDATORS
286
+ ----------------------------------------------------------- */
287
+ /**
288
+ * Asserts equality between a value and its type.
289
+ *
290
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
291
+ * reason, if the parametric value is not following the type `T` or some superfluous
292
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
293
+ * following the type `T` without any superfluous property, just input parameter would
294
+ * be returned.
295
+ *
296
+ * If what you want is not asserting but just knowing whether the parametric value is
297
+ * following the type `T` or not, you can choose the {@link equals} function instead.
298
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
299
+ *
300
+ * On the other hand, if you want to allow superfluous property that is not enrolled
301
+ * to the type `T`, you can use {@link assert} function instead.
302
+ *
303
+ * @template T Type of the input value
304
+ * @param input A value to be asserted
305
+ * @returns Parametric input value
306
+ * @throws A {@link TypeGuardError} instance with detailed reason
307
+ *
308
+ * @author Jeongho Nam - https://github.com/samchon
309
+ */
310
+ export function assertEquals<T>(input: T): T;
311
+
312
+ /**
313
+ * Asserts equality between a value and its type.
314
+ *
315
+ * Asserts a parametric value type and throws a {@link TypeGuardError} with detailed
316
+ * reason, if the parametric value is not following the type `T` or some superfluous
317
+ * property that is not listed on the type `T` has been found. Otherwise, the value is
318
+ * following the type `T` without any superfluous property, just input parameter would
319
+ * be returned.
320
+ *
321
+ * If what you want is not asserting but just knowing whether the parametric value is
322
+ * following the type `T` or not, you can choose the {@link equals} function instead.
323
+ * Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
324
+ *
325
+ * On the other hand, if you want to allow superfluous property that is not enrolled
326
+ * to the type `T`, you can use {@link assert} function instead.
327
+ *
328
+ * @template T Type of the input value
329
+ * @param input A value to be asserted
330
+ * @returns Parametric input value casted as `T`
331
+ * @throws A {@link TypeGuardError} instance with detailed reason
332
+ *
333
+ * @author Jeongho Nam - https://github.com/samchon
334
+ */
335
+ export function assertEquals<T>(input: unknown): T;
336
+
337
+ /**
338
+ * @internal
339
+ */
340
+ export function assertEquals(): never {
341
+ halt("assertEquals");
342
+ }
343
+ Object.assign(assertEquals, Namespace.assert("assertEquals"));
344
+
345
+ /**
346
+ * Tests equality between a value and its type.
347
+ *
348
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
349
+ * or not. If the parametric value is matched with the type `T` and there's not any
350
+ * superfluous property that is not listed on the type `T`, `true` value would be
351
+ * returned. Otherwise, the parametric value is not following the type `T` or some
352
+ * superfluous property exists, `false` value would be returned.
353
+ *
354
+ * If what you want is not just knowing whether the parametric value is following the
355
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
356
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
357
+ * detailed reasons, {@link validateEquals} function would be useful.
358
+ *
359
+ * On the other hand, if you want to allow superfluous property that is not enrolled
360
+ * to the type `T`, you can use {@link is} function instead.
361
+ *
362
+ * @template T Type of the input value
363
+ * @param input A value to be tested
364
+ * @returns Whether the parametric value is equivalent to the type `T` or not
365
+ *
366
+ * @author Jeongho Nam - https://github.com/samchon
367
+ */
368
+ export function equals<T>(input: T): input is T;
369
+
370
+ /**
371
+ * Tests equality between a value and its type.
372
+ *
373
+ * Tests a parametric value type and returns whether it's equivalent to the type `T`
374
+ * or not. If the parametric value is matched with the type `T` and there's not any
375
+ * superfluous property that is not listed on the type `T`, `true` value would be
376
+ * returned. Otherwise, the parametric value is not following the type `T` or some
377
+ * superfluous property exists, `false` value would be returned.
378
+ *
379
+ * If what you want is not just knowing whether the parametric value is following the
380
+ * type `T` or not, but throwing an exception with detailed reason, you can choose
381
+ * {@link assertEquals} function instead. Also, if you want to know all the errors with
382
+ * detailed reasons, {@link validateEquals} function would be useful.
383
+ *
384
+ * On the other hand, if you want to allow superfluous property that is not enrolled
385
+ * to the type `T`, you can use {@link is} function instead.
386
+ *
387
+ * @template T Type of the input value
388
+ * @param input A value to be tested
389
+ * @returns Whether the parametric value is equivalent to the type `T` or not
390
+ *
391
+ * @author Jeongho Nam - https://github.com/samchon
392
+ */
393
+ export function equals<T>(input: unknown): input is T;
394
+
395
+ /**
396
+ * @internal
397
+ */
398
+ export function equals(): never {
399
+ halt("equals");
400
+ }
401
+ Object.assign(equals, Namespace.is());
402
+
403
+ /**
404
+ * Validates equality between a value and its type.
405
+ *
406
+ * Validates a parametric value type and archives all the type errors into an
407
+ * {@link IValidation.errors} array, if the parametric value is not following the
408
+ * type `T` or some superfluous property that is not listed on the type `T` has been
409
+ * found. Of course, if the parametric value is following the type `T` and no
410
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
411
+ * and {@link IValidation.success} would have the `true` value.
412
+ *
413
+ * If what you want is not finding all the error, but asserting the parametric value
414
+ * type with exception throwing, you can choose {@link assert} function instead.
415
+ * Otherwise, you just want to know whether the parametric value is matched with the
416
+ * type `T`, {@link is} function is the way to go.
417
+ *
418
+ * On the other and, if you don't want to allow any superfluous property that is not
419
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
420
+ *
421
+ * @template Type of the input value
422
+ * @param input A value to be validated
423
+ * @returns Validation result
424
+ *
425
+ * @author Jeongho Nam - https://github.com/samchon
426
+ */
427
+ export function validateEquals<T>(input: T): IValidation<T>;
428
+
429
+ /**
430
+ * Validates equality between a value and its type.
431
+ *
432
+ * Validates a parametric value type and archives all the type errors into an
433
+ * {@link IValidation.errors} array, if the parametric value is not following the
434
+ * type `T` or some superfluous property that is not listed on the type `T` has been
435
+ * found. Of course, if the parametric value is following the type `T` and no
436
+ * superfluous property exists, the {@link IValidation.errors} array would be empty
437
+ * and {@link IValidation.success} would have the `true` value.
438
+ *
439
+ * If what you want is not finding all the error, but asserting the parametric value
440
+ * type with exception throwing, you can choose {@link assert} function instead.
441
+ * Otherwise, you just want to know whether the parametric value is matched with the
442
+ * type `T`, {@link is} function is the way to go.
443
+ *
444
+ * On the other and, if you don't want to allow any superfluous property that is not
445
+ * enrolled to the type `T`, you can use {@link validateEquals} function instead.
446
+ *
447
+ * @template Type of the input value
448
+ * @param input A value to be validated
449
+ * @returns Validation result
450
+ *
451
+ * @author Jeongho Nam - https://github.com/samchon
452
+ */
453
+ export function validateEquals<T>(input: unknown): IValidation<T>;
454
+
455
+ /**
456
+ * @internal
457
+ */
458
+ export function validateEquals(): never {
459
+ halt("validateEquals");
460
+ }
461
+ Object.assign(validateEquals, Namespace.validate());
462
+
463
+ /* -----------------------------------------------------------
464
+ RANDOM
465
+ ----------------------------------------------------------- */
466
+ /**
467
+ * > You must configure the generic argument `T`.
468
+ *
469
+ * Generate random data.
470
+ *
471
+ * Generates a random data following type the `T`.
472
+ *
473
+ * For reference, this `typia.random()` function generates only primitive type.
474
+ * If there're some methods in the type `T` or its nested instances, those would
475
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
476
+ * would be generated instead.
477
+ *
478
+ * @template T Type of data to generate
479
+ * @param generator Random data generator
480
+ * @return Randomly generated data
481
+ *
482
+ * @author Jeongho Nam - https://github.com/samchon
483
+ */
484
+ export function random(generator?: Partial<IRandomGenerator>): never;
485
+
486
+ /**
487
+ * Generate random data.
488
+ *
489
+ * Generates a random data following type the `T`.
490
+ *
491
+ * For reference, this `typia.random()` function generates only primitive type.
492
+ * If there're some methods in the type `T` or its nested instances, those would
493
+ * be ignored. Also, when the type `T` has a `toJSON()` method, its return type
494
+ * would be generated instead.
495
+ *
496
+ * @template T Type of data to generate
497
+ * @param generator Random data generator
498
+ * @return Randomly generated data
499
+ *
500
+ * @author Jeongho Nam - https://github.com/samchon
501
+ */
502
+ export function random<T>(generator?: Partial<IRandomGenerator>): Primitive<T>;
503
+
504
+ /**
505
+ * @internal
506
+ */
507
+ export function random(): never {
508
+ halt("random");
509
+ }
510
+ Object.assign(random, Namespace.random());
511
+
512
+ /**
513
+ * @internal
514
+ */
515
+ export function metadata(): never;
516
+
517
+ /**
518
+ * @internal
519
+ */
520
+ export function metadata<Types extends unknown[]>(): IMetadataApplication;
521
+
522
+ /**
523
+ * @internal
524
+ */
525
+ export function metadata(): never {
526
+ halt("metadata");
527
+ }
528
+
529
+ /* -----------------------------------------------------------
530
+ FACTORY FUNCTIONS
531
+ ----------------------------------------------------------- */
532
+ /**
533
+ * Creates a reusable {@link assert} function.
534
+ *
535
+ * @danger You have to specify the generic argument `T`
536
+ * @return Nothing until specifying the generic argument `T`
537
+ * @throws compile error
538
+ *
539
+ * @author Jeongho Nam - https://github.com/samchon
540
+ */
541
+ export function createAssert(): never;
542
+
543
+ /**
544
+ * Creates a reusable {@link assert} function.
545
+ *
546
+ * @template T Type of the input value
547
+ * @returns A reusable `assert` function
548
+ *
549
+ * @author Jeongho Nam - https://github.com/samchon
550
+ */
551
+ export function createAssert<T>(): (input: unknown) => T;
552
+
553
+ /**
554
+ * @internal
555
+ */
556
+ export function createAssert<T>(): (input: unknown) => T {
557
+ halt("createAssert");
558
+ }
559
+ Object.assign(createAssert, assert);
560
+
561
+ /**
562
+ * Creates a reusable {@link assertType} function.
563
+ *
564
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
565
+ *
566
+ * @danger You have to specify the generic argument `T`
567
+ * @return Nothing until specifying the generic argument `T`
568
+ * @throws compile error
569
+ *
570
+ * @author Jeongho Nam - https://github.com/samchon
571
+ * @deprecated
572
+ */
573
+ export function createAssertType(): never;
574
+
575
+ /**
576
+ * Creates a reusable {@link assertType} function.
577
+ *
578
+ * Duplicated function of {@link createAssert} for `typescript-is` users.
579
+ *
580
+ * @template T Type of the input value
581
+ * @returns A reusable `assert` function
582
+ *
583
+ * @author Jeongho Nam - https://github.com/samchon
584
+ * @deprecated
585
+ */
586
+ export function createAssertType<T>(): (input: unknown) => T;
587
+
588
+ /**
589
+ * @internal
590
+ */
591
+ export function createAssertType<T>(): (input: unknown) => T {
592
+ halt("createAssertType");
593
+ }
594
+ Object.assign(createAssertType, assertType);
595
+
596
+ /**
597
+ * Creates a reusable {@link is} function.
598
+ *
599
+ * @danger You have to specify the generic argument `T`
600
+ * @return Nothing until specifying the generic argument `T`
601
+ * @throws compile error
602
+ *
603
+ * @author Jeongho Nam - https://github.com/samchon
604
+ */
605
+ export function createIs(): never;
606
+
607
+ /**
608
+ * Creates a reusable {@link is} function.
609
+ *
610
+ * @template T Type of the input value
611
+ * @returns A reusable `is` function
612
+ *
613
+ * @author Jeongho Nam - https://github.com/samchon
614
+ */
615
+ export function createIs<T>(): (input: unknown) => input is T;
616
+
617
+ /**
618
+ * @internal
619
+ */
620
+ export function createIs<T>(): (input: unknown) => input is T {
621
+ halt("createIs");
622
+ }
623
+ Object.assign(createIs, is);
624
+
625
+ /**
626
+ * Creates a reusable {@link validate} function.
627
+ *
628
+ * @danger You have to specify the generic argument `T`
629
+ * @return Nothing until specifying the generic argument `T`
630
+ * @throws compile error
631
+ *
632
+ * @author Jeongho Nam - https://github.com/samchon
633
+ */
634
+ export function createValidate(): never;
635
+
636
+ /**
637
+ * Creates a reusable {@link validate} function.
638
+ *
639
+ * @template T Type of the input value
640
+ * @returns A reusable `validate` function
641
+ *
642
+ * @author Jeongho Nam - https://github.com/samchon
643
+ */
644
+ export function createValidate<T>(): (input: unknown) => IValidation<T>;
645
+
646
+ /**
647
+ * @internal
648
+ */
649
+ export function createValidate(): (input: unknown) => IValidation {
650
+ halt("createValidate");
651
+ }
652
+ Object.assign(createValidate, validate);
653
+
654
+ /**
655
+ * Creates a reusable {@link assertEquals} function.
656
+ *
657
+ * @danger You have to specify the generic argument `T`
658
+ * @return Nothing until specifying the generic argument `T`
659
+ * @throws compile error
660
+ *
661
+ * @author Jeongho Nam - https://github.com/samchon
662
+ */
663
+ export function createAssertEquals(): never;
664
+
665
+ /**
666
+ * Creates a reusable {@link assertEquals} function.
667
+ *
668
+ * @template T Type of the input value
669
+ * @returns A reusable `assertEquals` function
670
+ *
671
+ * @author Jeongho Nam - https://github.com/samchon
672
+ */
673
+ export function createAssertEquals<T>(): (input: unknown) => T;
674
+
675
+ /**
676
+ * @internal
677
+ */
678
+ export function createAssertEquals<T>(): (input: unknown) => T {
679
+ halt("createAssertEquals");
680
+ }
681
+ Object.assign(createAssertEquals, assertEquals);
682
+
683
+ /**
684
+ * Creates a reusable {@link equals} function.
685
+ *
686
+ * @danger You have to specify the generic argument `T`
687
+ * @return Nothing until specifying the generic argument `T`
688
+ * @throws compile error
689
+ *
690
+ * @author Jeongho Nam - https://github.com/samchon
691
+ */
692
+ export function createEquals(): never;
693
+
694
+ /**
695
+ * Creates a reusable {@link equals} function.
696
+ *
697
+ * @template T Type of the input value
698
+ * @returns A reusable `equals` function
699
+ *
700
+ * @author Jeongho Nam - https://github.com/samchon
701
+ */
702
+ export function createEquals<T>(): (input: unknown) => input is T;
703
+
704
+ /**
705
+ * @internal
706
+ */
707
+ export function createEquals<T>(): (input: unknown) => input is T {
708
+ halt("createEquals");
709
+ }
710
+ Object.assign(createEquals, equals);
711
+
712
+ /**
713
+ * Creates a reusable {@link validateEquals} function.
714
+ *
715
+ * @danger You have to specify the generic argument `T`
716
+ * @return Nothing until specifying the generic argument `T`
717
+ * @throws compile error
718
+ *
719
+ * @author Jeongho Nam - https://github.com/samchon
720
+ */
721
+ export function createValidateEquals(): never;
722
+
723
+ /**
724
+ * Creates a reusable {@link validateEquals} function.
725
+ *
726
+ * @template T Type of the input value
727
+ * @returns A reusable `validateEquals` function
728
+ *
729
+ * @author Jeongho Nam - https://github.com/samchon
730
+ */
731
+ export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
732
+
733
+ /**
734
+ * @internal
735
+ */
736
+ export function createValidateEquals(): (input: unknown) => IValidation {
737
+ halt("createValidateEquals");
738
+ }
739
+ Object.assign(createValidateEquals, validateEquals);
740
+
741
+ /**
742
+ * Creates a reusable {@link random} function.
743
+ *
744
+ * @danger You have to specify the generic argument `T`
745
+ * @param generator Random data generator
746
+ * @return Nothing until specifying the generic argument `T`
747
+ * @throws compile error
748
+ *
749
+ * @author Jeongho Nam - https://github.com/samchon
750
+ */
751
+ export function createRandom(generator?: Partial<IRandomGenerator>): never;
752
+
753
+ /**
754
+ * Creates a resuable {@link random} function.
755
+ *
756
+ * @template T Type of the input value
757
+ * @param generator Random data generator
758
+ * @returns A reusable `random` function
759
+ *
760
+ * @author Jeongho Nam - https://github.com/samchon
761
+ */
762
+ export function createRandom<T>(
763
+ generator?: Partial<IRandomGenerator>,
764
+ ): () => Primitive<T>;
765
+
766
+ /**
767
+ * @internal
768
+ */
769
+ export function createRandom(): never {
770
+ halt("createRandom");
771
+ }
772
+ Object.assign(createRandom, random);
773
+
774
+ /**
775
+ * @internal
776
+ */
777
+ function halt(name: string): never {
778
+ throw new Error(
779
+ `Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
780
+ );
781
+ }