@typia/interface 12.0.0-dev.20260225

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 (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/lib/http/IHttpConnection.d.ts +163 -0
  4. package/lib/http/IHttpConnection.js +4 -0
  5. package/lib/http/IHttpConnection.js.map +1 -0
  6. package/lib/http/IHttpLlmApplication.d.ts +73 -0
  7. package/lib/http/IHttpLlmApplication.js +3 -0
  8. package/lib/http/IHttpLlmApplication.js.map +1 -0
  9. package/lib/http/IHttpLlmController.d.ts +86 -0
  10. package/lib/http/IHttpLlmController.js +3 -0
  11. package/lib/http/IHttpLlmController.js.map +1 -0
  12. package/lib/http/IHttpLlmFunction.d.ts +79 -0
  13. package/lib/http/IHttpLlmFunction.js +3 -0
  14. package/lib/http/IHttpLlmFunction.js.map +1 -0
  15. package/lib/http/IHttpMigrateApplication.d.ts +42 -0
  16. package/lib/http/IHttpMigrateApplication.js +3 -0
  17. package/lib/http/IHttpMigrateApplication.js.map +1 -0
  18. package/lib/http/IHttpMigrateRoute.d.ts +121 -0
  19. package/lib/http/IHttpMigrateRoute.js +3 -0
  20. package/lib/http/IHttpMigrateRoute.js.map +1 -0
  21. package/lib/http/IHttpResponse.d.ts +40 -0
  22. package/lib/http/IHttpResponse.js +3 -0
  23. package/lib/http/IHttpResponse.js.map +1 -0
  24. package/lib/http/index.d.ts +7 -0
  25. package/lib/http/index.js +24 -0
  26. package/lib/http/index.js.map +1 -0
  27. package/lib/index.d.ts +8 -0
  28. package/lib/index.js +48 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/metadata/IJsDocTagInfo.d.ts +23 -0
  31. package/lib/metadata/IJsDocTagInfo.js +3 -0
  32. package/lib/metadata/IJsDocTagInfo.js.map +1 -0
  33. package/lib/metadata/IMetadataComponents.d.ts +20 -0
  34. package/lib/metadata/IMetadataComponents.js +3 -0
  35. package/lib/metadata/IMetadataComponents.js.map +1 -0
  36. package/lib/metadata/IMetadataSchema.d.ts +219 -0
  37. package/lib/metadata/IMetadataSchema.js +3 -0
  38. package/lib/metadata/IMetadataSchema.js.map +1 -0
  39. package/lib/metadata/IMetadataSchemaCollection.d.ts +18 -0
  40. package/lib/metadata/IMetadataSchemaCollection.js +3 -0
  41. package/lib/metadata/IMetadataSchemaCollection.js.map +1 -0
  42. package/lib/metadata/IMetadataSchemaUnit.d.ts +18 -0
  43. package/lib/metadata/IMetadataSchemaUnit.js +3 -0
  44. package/lib/metadata/IMetadataSchemaUnit.js.map +1 -0
  45. package/lib/metadata/IMetadataTypeTag.d.ts +28 -0
  46. package/lib/metadata/IMetadataTypeTag.js +3 -0
  47. package/lib/metadata/IMetadataTypeTag.js.map +1 -0
  48. package/lib/metadata/index.d.ts +6 -0
  49. package/lib/metadata/index.js +23 -0
  50. package/lib/metadata/index.js.map +1 -0
  51. package/lib/openapi/OpenApi.d.ts +454 -0
  52. package/lib/openapi/OpenApi.js +3 -0
  53. package/lib/openapi/OpenApi.js.map +1 -0
  54. package/lib/openapi/OpenApiV3.d.ts +420 -0
  55. package/lib/openapi/OpenApiV3.js +3 -0
  56. package/lib/openapi/OpenApiV3.js.map +1 -0
  57. package/lib/openapi/OpenApiV3_1.d.ts +463 -0
  58. package/lib/openapi/OpenApiV3_1.js +3 -0
  59. package/lib/openapi/OpenApiV3_1.js.map +1 -0
  60. package/lib/openapi/SwaggerV2.d.ts +343 -0
  61. package/lib/openapi/SwaggerV2.js +3 -0
  62. package/lib/openapi/SwaggerV2.js.map +1 -0
  63. package/lib/openapi/index.d.ts +4 -0
  64. package/lib/openapi/index.js +21 -0
  65. package/lib/openapi/index.js.map +1 -0
  66. package/lib/protobuf/ProtobufWire.d.ts +46 -0
  67. package/lib/protobuf/ProtobufWire.js +3 -0
  68. package/lib/protobuf/ProtobufWire.js.map +1 -0
  69. package/lib/protobuf/index.d.ts +1 -0
  70. package/lib/protobuf/index.js +18 -0
  71. package/lib/protobuf/index.js.map +1 -0
  72. package/lib/schema/IJsonSchemaApplication.d.ts +232 -0
  73. package/lib/schema/IJsonSchemaApplication.js +3 -0
  74. package/lib/schema/IJsonSchemaApplication.js.map +1 -0
  75. package/lib/schema/IJsonSchemaAttribute.d.ts +152 -0
  76. package/lib/schema/IJsonSchemaAttribute.js +3 -0
  77. package/lib/schema/IJsonSchemaAttribute.js.map +1 -0
  78. package/lib/schema/IJsonSchemaCollection.d.ts +109 -0
  79. package/lib/schema/IJsonSchemaCollection.js +3 -0
  80. package/lib/schema/IJsonSchemaCollection.js.map +1 -0
  81. package/lib/schema/IJsonSchemaTransformError.d.ts +81 -0
  82. package/lib/schema/IJsonSchemaTransformError.js +3 -0
  83. package/lib/schema/IJsonSchemaTransformError.js.map +1 -0
  84. package/lib/schema/IJsonSchemaUnit.d.ts +106 -0
  85. package/lib/schema/IJsonSchemaUnit.js +3 -0
  86. package/lib/schema/IJsonSchemaUnit.js.map +1 -0
  87. package/lib/schema/ILlmApplication.d.ts +95 -0
  88. package/lib/schema/ILlmApplication.js +3 -0
  89. package/lib/schema/ILlmApplication.js.map +1 -0
  90. package/lib/schema/ILlmController.d.ts +53 -0
  91. package/lib/schema/ILlmController.js +3 -0
  92. package/lib/schema/ILlmController.js.map +1 -0
  93. package/lib/schema/ILlmFunction.d.ts +134 -0
  94. package/lib/schema/ILlmFunction.js +3 -0
  95. package/lib/schema/ILlmFunction.js.map +1 -0
  96. package/lib/schema/ILlmSchema.d.ts +412 -0
  97. package/lib/schema/ILlmSchema.js +3 -0
  98. package/lib/schema/ILlmSchema.js.map +1 -0
  99. package/lib/schema/IResult.d.ts +81 -0
  100. package/lib/schema/IResult.js +3 -0
  101. package/lib/schema/IResult.js.map +1 -0
  102. package/lib/schema/IValidation.d.ts +123 -0
  103. package/lib/schema/IValidation.js +3 -0
  104. package/lib/schema/IValidation.js.map +1 -0
  105. package/lib/schema/index.d.ts +11 -0
  106. package/lib/schema/index.js +28 -0
  107. package/lib/schema/index.js.map +1 -0
  108. package/lib/tags/Constant.d.ts +44 -0
  109. package/lib/tags/Constant.js +3 -0
  110. package/lib/tags/Constant.js.map +1 -0
  111. package/lib/tags/ContentMediaType.d.ts +39 -0
  112. package/lib/tags/ContentMediaType.js +3 -0
  113. package/lib/tags/ContentMediaType.js.map +1 -0
  114. package/lib/tags/Default.d.ts +42 -0
  115. package/lib/tags/Default.js +3 -0
  116. package/lib/tags/Default.js.map +1 -0
  117. package/lib/tags/Example.d.ts +38 -0
  118. package/lib/tags/Example.js +3 -0
  119. package/lib/tags/Example.js.map +1 -0
  120. package/lib/tags/Examples.d.ts +44 -0
  121. package/lib/tags/Examples.js +3 -0
  122. package/lib/tags/Examples.js.map +1 -0
  123. package/lib/tags/ExclusiveMaximum.d.ts +39 -0
  124. package/lib/tags/ExclusiveMaximum.js +3 -0
  125. package/lib/tags/ExclusiveMaximum.js.map +1 -0
  126. package/lib/tags/ExclusiveMinimum.d.ts +39 -0
  127. package/lib/tags/ExclusiveMinimum.js +3 -0
  128. package/lib/tags/ExclusiveMinimum.js.map +1 -0
  129. package/lib/tags/Format.d.ts +43 -0
  130. package/lib/tags/Format.js +3 -0
  131. package/lib/tags/Format.js.map +1 -0
  132. package/lib/tags/JsonSchemaPlugin.d.ts +44 -0
  133. package/lib/tags/JsonSchemaPlugin.js +3 -0
  134. package/lib/tags/JsonSchemaPlugin.js.map +1 -0
  135. package/lib/tags/MaxItems.d.ts +38 -0
  136. package/lib/tags/MaxItems.js +3 -0
  137. package/lib/tags/MaxItems.js.map +1 -0
  138. package/lib/tags/MaxLength.d.ts +36 -0
  139. package/lib/tags/MaxLength.js +3 -0
  140. package/lib/tags/MaxLength.js.map +1 -0
  141. package/lib/tags/Maximum.d.ts +41 -0
  142. package/lib/tags/Maximum.js +3 -0
  143. package/lib/tags/Maximum.js.map +1 -0
  144. package/lib/tags/MinItems.d.ts +38 -0
  145. package/lib/tags/MinItems.js +3 -0
  146. package/lib/tags/MinItems.js.map +1 -0
  147. package/lib/tags/MinLength.d.ts +36 -0
  148. package/lib/tags/MinLength.js +3 -0
  149. package/lib/tags/MinLength.js.map +1 -0
  150. package/lib/tags/Minimum.d.ts +41 -0
  151. package/lib/tags/Minimum.js +3 -0
  152. package/lib/tags/Minimum.js.map +1 -0
  153. package/lib/tags/MultipleOf.d.ts +49 -0
  154. package/lib/tags/MultipleOf.js +3 -0
  155. package/lib/tags/MultipleOf.js.map +1 -0
  156. package/lib/tags/Pattern.d.ts +51 -0
  157. package/lib/tags/Pattern.js +3 -0
  158. package/lib/tags/Pattern.js.map +1 -0
  159. package/lib/tags/Sequence.d.ts +42 -0
  160. package/lib/tags/Sequence.js +3 -0
  161. package/lib/tags/Sequence.js.map +1 -0
  162. package/lib/tags/TagBase.d.ts +109 -0
  163. package/lib/tags/TagBase.js +3 -0
  164. package/lib/tags/TagBase.js.map +1 -0
  165. package/lib/tags/Type.d.ts +53 -0
  166. package/lib/tags/Type.js +3 -0
  167. package/lib/tags/Type.js.map +1 -0
  168. package/lib/tags/UniqueItems.d.ts +41 -0
  169. package/lib/tags/UniqueItems.js +3 -0
  170. package/lib/tags/UniqueItems.js.map +1 -0
  171. package/lib/tags/index.d.ts +21 -0
  172. package/lib/tags/index.js +38 -0
  173. package/lib/tags/index.js.map +1 -0
  174. package/lib/typings/AssertionGuard.d.ts +12 -0
  175. package/lib/typings/AssertionGuard.js +3 -0
  176. package/lib/typings/AssertionGuard.js.map +1 -0
  177. package/lib/typings/Atomic.d.ts +19 -0
  178. package/lib/typings/Atomic.js +3 -0
  179. package/lib/typings/Atomic.js.map +1 -0
  180. package/lib/typings/CamelCase.d.ts +26 -0
  181. package/lib/typings/CamelCase.js +3 -0
  182. package/lib/typings/CamelCase.js.map +1 -0
  183. package/lib/typings/ClassProperties.d.ts +14 -0
  184. package/lib/typings/ClassProperties.js +3 -0
  185. package/lib/typings/ClassProperties.js.map +1 -0
  186. package/lib/typings/OmitNever.d.ts +11 -0
  187. package/lib/typings/OmitNever.js +3 -0
  188. package/lib/typings/OmitNever.js.map +1 -0
  189. package/lib/typings/PascalCase.d.ts +25 -0
  190. package/lib/typings/PascalCase.js +3 -0
  191. package/lib/typings/PascalCase.js.map +1 -0
  192. package/lib/typings/Primitive.d.ts +29 -0
  193. package/lib/typings/Primitive.js +3 -0
  194. package/lib/typings/Primitive.js.map +1 -0
  195. package/lib/typings/ProtobufAtomic.d.ts +15 -0
  196. package/lib/typings/ProtobufAtomic.js +3 -0
  197. package/lib/typings/ProtobufAtomic.js.map +1 -0
  198. package/lib/typings/Resolved.d.ts +23 -0
  199. package/lib/typings/Resolved.js +3 -0
  200. package/lib/typings/Resolved.js.map +1 -0
  201. package/lib/typings/SnakeCase.d.ts +31 -0
  202. package/lib/typings/SnakeCase.js +3 -0
  203. package/lib/typings/SnakeCase.js.map +1 -0
  204. package/lib/typings/SpecialFields.d.ts +13 -0
  205. package/lib/typings/SpecialFields.js +3 -0
  206. package/lib/typings/SpecialFields.js.map +1 -0
  207. package/lib/typings/ValidationPipe.d.ts +18 -0
  208. package/lib/typings/ValidationPipe.js +3 -0
  209. package/lib/typings/ValidationPipe.js.map +1 -0
  210. package/lib/typings/index.d.ts +12 -0
  211. package/lib/typings/index.js +29 -0
  212. package/lib/typings/index.js.map +1 -0
  213. package/lib/typings/internal/Equal.d.ts +11 -0
  214. package/lib/typings/internal/Equal.js +3 -0
  215. package/lib/typings/internal/Equal.js.map +1 -0
  216. package/lib/typings/internal/IsTuple.d.ts +13 -0
  217. package/lib/typings/internal/IsTuple.js +3 -0
  218. package/lib/typings/internal/IsTuple.js.map +1 -0
  219. package/lib/typings/internal/NativeClass.d.ts +9 -0
  220. package/lib/typings/internal/NativeClass.js +3 -0
  221. package/lib/typings/internal/NativeClass.js.map +1 -0
  222. package/lib/typings/internal/ValueOf.d.ts +15 -0
  223. package/lib/typings/internal/ValueOf.js +3 -0
  224. package/lib/typings/internal/ValueOf.js.map +1 -0
  225. package/lib/utils/IRandomGenerator.d.ts +68 -0
  226. package/lib/utils/IRandomGenerator.js +3 -0
  227. package/lib/utils/IRandomGenerator.js.map +1 -0
  228. package/lib/utils/IReadableURLSearchParams.d.ts +22 -0
  229. package/lib/utils/IReadableURLSearchParams.js +3 -0
  230. package/lib/utils/IReadableURLSearchParams.js.map +1 -0
  231. package/lib/utils/index.d.ts +2 -0
  232. package/lib/utils/index.js +19 -0
  233. package/lib/utils/index.js.map +1 -0
  234. package/package.json +79 -0
  235. package/src/http/IHttpConnection.ts +200 -0
  236. package/src/http/IHttpLlmApplication.ts +83 -0
  237. package/src/http/IHttpLlmController.ts +96 -0
  238. package/src/http/IHttpLlmFunction.ts +93 -0
  239. package/src/http/IHttpMigrateApplication.ts +48 -0
  240. package/src/http/IHttpMigrateRoute.ts +165 -0
  241. package/src/http/IHttpResponse.ts +42 -0
  242. package/src/http/index.ts +7 -0
  243. package/src/index.ts +9 -0
  244. package/src/metadata/IJsDocTagInfo.ts +25 -0
  245. package/src/metadata/IMetadataComponents.ts +24 -0
  246. package/src/metadata/IMetadataSchema.ts +293 -0
  247. package/src/metadata/IMetadataSchemaCollection.ts +20 -0
  248. package/src/metadata/IMetadataSchemaUnit.ts +20 -0
  249. package/src/metadata/IMetadataTypeTag.ts +39 -0
  250. package/src/metadata/index.ts +6 -0
  251. package/src/openapi/OpenApi.ts +643 -0
  252. package/src/openapi/OpenApiV3.ts +655 -0
  253. package/src/openapi/OpenApiV3_1.ts +735 -0
  254. package/src/openapi/SwaggerV2.ts +559 -0
  255. package/src/openapi/index.ts +4 -0
  256. package/src/protobuf/ProtobufWire.ts +51 -0
  257. package/src/protobuf/index.ts +1 -0
  258. package/src/schema/IJsonSchemaApplication.ts +274 -0
  259. package/src/schema/IJsonSchemaAttribute.ts +158 -0
  260. package/src/schema/IJsonSchemaCollection.ts +123 -0
  261. package/src/schema/IJsonSchemaTransformError.ts +86 -0
  262. package/src/schema/IJsonSchemaUnit.ts +120 -0
  263. package/src/schema/ILlmApplication.ts +103 -0
  264. package/src/schema/ILlmController.ts +57 -0
  265. package/src/schema/ILlmFunction.ts +144 -0
  266. package/src/schema/ILlmSchema.ts +484 -0
  267. package/src/schema/IResult.ts +84 -0
  268. package/src/schema/IValidation.ts +134 -0
  269. package/src/schema/index.ts +13 -0
  270. package/src/tags/Constant.ts +49 -0
  271. package/src/tags/ContentMediaType.ts +40 -0
  272. package/src/tags/Default.ts +50 -0
  273. package/src/tags/Example.ts +48 -0
  274. package/src/tags/Examples.ts +50 -0
  275. package/src/tags/ExclusiveMaximum.ts +46 -0
  276. package/src/tags/ExclusiveMinimum.ts +46 -0
  277. package/src/tags/Format.ts +76 -0
  278. package/src/tags/JsonSchemaPlugin.ts +45 -0
  279. package/src/tags/MaxItems.ts +39 -0
  280. package/src/tags/MaxLength.ts +37 -0
  281. package/src/tags/Maximum.ts +44 -0
  282. package/src/tags/MinItems.ts +39 -0
  283. package/src/tags/MinLength.ts +37 -0
  284. package/src/tags/Minimum.ts +44 -0
  285. package/src/tags/MultipleOf.ts +54 -0
  286. package/src/tags/Pattern.ts +59 -0
  287. package/src/tags/Sequence.ts +43 -0
  288. package/src/tags/TagBase.ts +131 -0
  289. package/src/tags/Type.ts +70 -0
  290. package/src/tags/UniqueItems.ts +44 -0
  291. package/src/tags/index.ts +21 -0
  292. package/src/typings/AssertionGuard.ts +12 -0
  293. package/src/typings/Atomic.ts +21 -0
  294. package/src/typings/CamelCase.ts +75 -0
  295. package/src/typings/ClassProperties.ts +15 -0
  296. package/src/typings/OmitNever.ts +12 -0
  297. package/src/typings/PascalCase.ts +71 -0
  298. package/src/typings/Primitive.ts +71 -0
  299. package/src/typings/ProtobufAtomic.ts +30 -0
  300. package/src/typings/Resolved.ts +58 -0
  301. package/src/typings/SnakeCase.ts +126 -0
  302. package/src/typings/SpecialFields.ts +13 -0
  303. package/src/typings/ValidationPipe.ts +20 -0
  304. package/src/typings/index.ts +13 -0
  305. package/src/typings/internal/Equal.ts +14 -0
  306. package/src/typings/internal/IsTuple.ts +17 -0
  307. package/src/typings/internal/NativeClass.ts +31 -0
  308. package/src/typings/internal/ValueOf.ts +29 -0
  309. package/src/utils/IRandomGenerator.ts +105 -0
  310. package/src/utils/IReadableURLSearchParams.ts +25 -0
  311. package/src/utils/index.ts +2 -0
@@ -0,0 +1,44 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Inclusive minimum value constraint (value >= min).
5
+ *
6
+ * `Minimum<N>` is a type tag that validates numeric values are greater than or
7
+ * equal to the specified bound. Apply it to `number` or `bigint` properties
8
+ * using TypeScript intersection types.
9
+ *
10
+ * This constraint is **mutually exclusive** with {@link ExclusiveMinimum} - you
11
+ * cannot use both on the same property. Use `Minimum` for inclusive bounds (>=)
12
+ * and `ExclusiveMinimum` for exclusive bounds (>).
13
+ *
14
+ * The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
15
+ * `typia.validate()`. It also generates `minimum` in JSON Schema output.
16
+ *
17
+ * @author Jeongho Nam - https://github.com/samchon
18
+ * @example
19
+ * interface Product {
20
+ * // Price must be 0 or greater
21
+ * price: number & Minimum<0>;
22
+ * // Quantity must be at least 1
23
+ * quantity: number & Minimum<1>;
24
+ * }
25
+ *
26
+ * @template Value The minimum allowed value (inclusive)
27
+ */
28
+ export type Minimum<Value extends number | bigint> = TagBase<{
29
+ target: Value extends bigint ? "bigint" : "number";
30
+ kind: "minimum";
31
+ value: Value;
32
+ validate: `${Cast<Value>} <= $input`;
33
+ exclusive: ["minimum", "exclusiveMinimum"];
34
+ schema: Value extends bigint
35
+ ? { minimum: Numeric<Value> }
36
+ : { minimum: Value };
37
+ }>;
38
+
39
+ type Cast<Value extends number | bigint> = Value extends number
40
+ ? Value
41
+ : `BigInt(${Value})`;
42
+ type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
43
+ ? N
44
+ : never;
@@ -0,0 +1,54 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Divisibility constraint (value % divisor === 0).
5
+ *
6
+ * `MultipleOf<N>` is a type tag that validates numeric values are exactly
7
+ * divisible by the specified divisor with no remainder. Apply it to `number` or
8
+ * `bigint` properties using TypeScript intersection types.
9
+ *
10
+ * Common use cases:
11
+ *
12
+ * - `MultipleOf<2>` for even numbers
13
+ * - `MultipleOf<0.01>` for currency with 2 decimal places
14
+ * - `MultipleOf<100>` for values in hundreds
15
+ *
16
+ * This constraint can be combined with other numeric constraints like
17
+ * {@link Minimum} and {@link Maximum}. Multiple `MultipleOf` constraints on the
18
+ * same property are allowed (all must pass).
19
+ *
20
+ * The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
21
+ * `typia.validate()`. It generates `multipleOf` in JSON Schema output.
22
+ *
23
+ * @author Jeongho Nam - https://github.com/samchon
24
+ * @example
25
+ * interface Currency {
26
+ * // Must be exact cents (0.01, 0.02, ..., 1.00, 1.01, ...)
27
+ * amount: number & MultipleOf<0.01>;
28
+ * }
29
+ * interface Pagination {
30
+ * // Page size must be multiple of 10
31
+ * pageSize: number & MultipleOf<10>;
32
+ * }
33
+ *
34
+ * @template Value The divisor (value must be evenly divisible by this)
35
+ */
36
+ export type MultipleOf<Value extends number | bigint> = TagBase<{
37
+ target: Value extends bigint ? "bigint" : "number";
38
+ kind: "multipleOf";
39
+ value: Value;
40
+ validate: `$input % ${Cast<Value>} === ${Value extends bigint
41
+ ? Cast<0n>
42
+ : 0}`;
43
+ exclusive: true;
44
+ schema: Value extends bigint
45
+ ? { multipleOf: Numeric<Value> }
46
+ : { multipleOf: Value };
47
+ }>;
48
+
49
+ type Cast<Value extends number | bigint> = Value extends number
50
+ ? Value
51
+ : `BigInt(${Value})`;
52
+ type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
53
+ ? N
54
+ : never;
@@ -0,0 +1,59 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Regular expression pattern constraint for strings.
5
+ *
6
+ * `Pattern<Regex>` is a type tag that validates string values match the
7
+ * specified regular expression pattern. Apply it to `string` properties using
8
+ * TypeScript intersection types.
9
+ *
10
+ * This constraint is **mutually exclusive** with {@link Format} - you cannot use
11
+ * both on the same property. Use `Pattern` for custom regex validation, or
12
+ * `Format` for standard formats (email, uuid, etc.).
13
+ *
14
+ * The pattern should be a valid JavaScript regular expression string without
15
+ * the surrounding slashes. The entire string must match (implicit `^` and `$`
16
+ * anchors).
17
+ *
18
+ * The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
19
+ * `typia.validate()`. It generates `pattern` in JSON Schema output.
20
+ *
21
+ * @author Jeongho Nam - https://github.com/samchon
22
+ * @example
23
+ * interface Product {
24
+ * // SKU format: 3 letters, dash, 4 digits
25
+ * sku: string & Pattern<"^[A-Z]{3}-[0-9]{4}$">;
26
+ * // Phone number: digits and optional dashes
27
+ * phone: string & Pattern<"^[0-9-]+$">;
28
+ * }
29
+ *
30
+ * @template Value Regular expression pattern as a string literal
31
+ */
32
+ export type Pattern<Value extends string> = TagBase<{
33
+ target: "string";
34
+ kind: "pattern";
35
+ value: Value;
36
+ validate: `RegExp("${Serialize<Value>}").test($input)`;
37
+ exclusive: ["format", "pattern"];
38
+ schema: {
39
+ pattern: Value;
40
+ };
41
+ }>;
42
+
43
+ type Serialize<T extends string, Output extends string = ""> = string extends T
44
+ ? never
45
+ : T extends ""
46
+ ? Output
47
+ : T extends `${infer P}${infer R}`
48
+ ? Serialize<R, `${Output}${P extends keyof Escaper ? Escaper[P] : P}`>
49
+ : never;
50
+
51
+ type Escaper = {
52
+ '"': '\\"';
53
+ "\\": "\\\\";
54
+ "\b": "\\b";
55
+ "\f": "\\f";
56
+ "\n": "\\n";
57
+ "\r": "\\r";
58
+ "\t": "\\t";
59
+ };
@@ -0,0 +1,43 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Protocol Buffer field number assignment.
5
+ *
6
+ * `Sequence<N>` is a type tag that assigns a unique field number for Protocol
7
+ * Buffer serialization. In protobuf, each field in a message must have a unique
8
+ * numeric identifier that's used in the binary encoding.
9
+ *
10
+ * Field number guidelines:
11
+ *
12
+ * - **1-15**: Use one byte in encoding (ideal for frequently-used fields)
13
+ * - **16-2047**: Use two bytes
14
+ * - **2048-536,870,911**: Use more bytes (avoid for efficiency)
15
+ * - **19000-19999**: Reserved by Protocol Buffers (cannot use)
16
+ *
17
+ * If not specified, typia auto-assigns field numbers. Use `Sequence` when you
18
+ * need stable field numbers for backward compatibility or when integrating with
19
+ * existing protobuf schemas.
20
+ *
21
+ * This tag is used by `typia.protobuf.encode()` and `typia.protobuf.decode()`.
22
+ * The field number also appears in JSON Schema as `x-protobuf-sequence`.
23
+ *
24
+ * @author Jeongho Nam - https://github.com/samchon
25
+ * @example
26
+ * interface Message {
27
+ * // Frequently accessed fields use low numbers
28
+ * id: (number & Sequence<1>) & Type<"uint32">;
29
+ * name: string & Sequence<2>;
30
+ * // Less common fields use higher numbers
31
+ * metadata: (Record<string, string> & Sequence<100>) | undefined;
32
+ * }
33
+ *
34
+ * @template N Field number (1 to 536,870,911, excluding 19000-19999)
35
+ */
36
+ export type Sequence<N extends number> = TagBase<{
37
+ target: "boolean" | "bigint" | "number" | "string" | "array" | "object";
38
+ kind: "sequence";
39
+ value: N;
40
+ schema: {
41
+ "x-protobuf-sequence": N;
42
+ };
43
+ }>;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Base type for all typia validation tags.
3
+ *
4
+ * `TagBase` is the foundation for all typia type tags (constraints like
5
+ * `Minimum`, `MaxLength`, `Format`, etc.). It attaches compile-time metadata to
6
+ * TypeScript types using a phantom property pattern.
7
+ *
8
+ * The typia transformer reads these tags at compile time and generates
9
+ * appropriate runtime validation code. The tags themselves have no runtime
10
+ * presence - they exist only in the type system.
11
+ *
12
+ * This is an internal implementation detail. Use the specific tag types (e.g.,
13
+ * {@link Minimum}, {@link Format}, {@link Pattern}) rather than `TagBase`
14
+ * directly.
15
+ *
16
+ * @author Jeongho Nam - https://github.com/samchon
17
+ * @template Props Tag properties defining validation behavior and schema output
18
+ */
19
+ export type TagBase<
20
+ Props extends TagBase.IProps<any, any, any, any, any, any>,
21
+ > = {
22
+ /**
23
+ * Compile-time marker property for typia transformer.
24
+ *
25
+ * This phantom property carries tag metadata in the type system. It is never
26
+ * assigned at runtime - it exists only for the transformer to read during
27
+ * compilation.
28
+ */
29
+ "typia.tag"?: Props;
30
+ };
31
+ export namespace TagBase {
32
+ /**
33
+ * Configuration interface for validation tag properties.
34
+ *
35
+ * Defines all the metadata a validation tag can specify, including what types
36
+ * it applies to, how to validate values, and what to output in JSON Schema.
37
+ *
38
+ * @template Target Which primitive type(s) this tag can be applied to
39
+ * @template Kind Unique identifier for this tag type
40
+ * @template Value The constraint value specified by the user
41
+ * @template Validate The validation expression to generate
42
+ * @template Exclusive Whether this tag conflicts with others
43
+ * @template Schema Additional JSON Schema properties to output
44
+ */
45
+ export interface IProps<
46
+ Target extends
47
+ | "boolean"
48
+ | "bigint"
49
+ | "number"
50
+ | "string"
51
+ | "array"
52
+ | "object",
53
+ Kind extends string,
54
+ Value extends boolean | bigint | number | string | undefined,
55
+ Validate extends
56
+ | string
57
+ | {
58
+ [key in Target]?: string;
59
+ },
60
+ Exclusive extends boolean | string[],
61
+ Schema extends object | undefined,
62
+ > {
63
+ /**
64
+ * Target primitive type(s) this tag applies to.
65
+ *
66
+ * The transformer will error if the tag is applied to a property of a
67
+ * different type. For example, `MinLength` targets `"string"` and cannot be
68
+ * applied to numbers.
69
+ */
70
+ target: Target;
71
+
72
+ /**
73
+ * Unique identifier for this tag type.
74
+ *
75
+ * Used internally to identify the constraint kind. Examples: `"minimum"`,
76
+ * `"maxLength"`, `"format"`, `"pattern"`.
77
+ */
78
+ kind: Kind;
79
+
80
+ /**
81
+ * User-configured constraint value.
82
+ *
83
+ * The value provided by the user when applying the tag. For `Minimum<5>`,
84
+ * this would be `5`. For `Format<"email">`, this would be `"email"`.
85
+ */
86
+ value: Value;
87
+
88
+ /**
89
+ * Validation expression template.
90
+ *
91
+ * JavaScript expression string that validates the input value. Use `$input`
92
+ * as a placeholder for the actual value. The expression is inserted into
93
+ * the generated validation function.
94
+ *
95
+ * Can be a single string or an object mapping target types to different
96
+ * expressions (for tags supporting multiple types).
97
+ *
98
+ * @example
99
+ * `"5 <= $input"`; // For Minimum<5>
100
+ *
101
+ * @example
102
+ * `"$input.length <= 10"`; // For MaxLength<10>
103
+ */
104
+ validate?: Validate;
105
+
106
+ /**
107
+ * Tag exclusivity configuration.
108
+ *
109
+ * Controls which other tags cannot be combined with this one:
110
+ *
111
+ * - `true`: No duplicate tags of the same kind allowed
112
+ * - `string[]`: List of incompatible tag kinds
113
+ * - `false` (default): No exclusivity restrictions
114
+ *
115
+ * For example, `Minimum` and `ExclusiveMinimum` are mutually exclusive -
116
+ * only one can be applied to a property.
117
+ *
118
+ * @default false
119
+ */
120
+ exclusive?: Exclusive | string[];
121
+
122
+ /**
123
+ * Additional JSON Schema properties to output.
124
+ *
125
+ * Object containing schema properties to merge into the generated JSON
126
+ * Schema for the annotated type. For `Minimum<5>`, this would be `{
127
+ * minimum: 5 }`.
128
+ */
129
+ schema?: Schema;
130
+ }
131
+ }
@@ -0,0 +1,70 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Numeric precision and bit-width type constraint.
5
+ *
6
+ * `Type<Value>` is a type tag that constrains numeric values to specific
7
+ * bit-width representations. This is essential for Protocol Buffers
8
+ * serialization and ensures values fit within their specified ranges.
9
+ *
10
+ * Available types:
11
+ *
12
+ * - `"int32"`: Signed 32-bit integer (-2,147,483,648 to 2,147,483,647)
13
+ * - `"uint32"`: Unsigned 32-bit integer (0 to 4,294,967,295)
14
+ * - `"int64"`: Signed 64-bit integer (for `number` or `bigint`)
15
+ * - `"uint64"`: Unsigned 64-bit integer (for `number` or `bigint`)
16
+ * - `"float"`: 32-bit floating point
17
+ * - `"double"`: 64-bit floating point (default JavaScript number)
18
+ *
19
+ * For Protocol Buffers, integer types also determine the wire encoding. The
20
+ * constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
21
+ * `typia.validate()`. It generates appropriate `type` in JSON Schema.
22
+ *
23
+ * @author Jeongho Nam - https://github.com/samchon
24
+ * @example
25
+ * interface Message {
26
+ * // 32-bit unsigned integer
27
+ * id: number & Type<"uint32">;
28
+ * // 64-bit signed integer as bigint
29
+ * timestamp: bigint & Type<"int64">;
30
+ * // 32-bit float for memory efficiency
31
+ * score: number & Type<"float">;
32
+ * }
33
+ *
34
+ * @template Value Numeric type identifier
35
+ */
36
+ export type Type<
37
+ Value extends "int32" | "uint32" | "int64" | "uint64" | "float" | "double",
38
+ > = TagBase<{
39
+ target: Value extends "int64" | "uint64" ? "bigint" | "number" : "number";
40
+ kind: "type";
41
+ value: Value;
42
+ validate: Value extends "int32"
43
+ ? `$importInternal("isTypeInt32")($input)`
44
+ : Value extends "uint32"
45
+ ? `$importInternal("isTypeUint32")($input)`
46
+ : Value extends "int64"
47
+ ? {
48
+ number: `$importInternal("isTypeInt64")($input)`;
49
+ bigint: `true`;
50
+ }
51
+ : Value extends "uint64"
52
+ ? {
53
+ number: `$importInternal("isTypeUint64")($input)`;
54
+ bigint: `BigInt(0) <= $input`;
55
+ }
56
+ : Value extends "float"
57
+ ? `$importInternal("isTypeFloat")($input)`
58
+ : `true`;
59
+ exclusive: true;
60
+ schema: Value extends "uint32" | "uint64"
61
+ ? {
62
+ type: "integer";
63
+ minimum: 0;
64
+ }
65
+ : {
66
+ type: Value extends "int32" | "uint32" | "int64" | "uint64"
67
+ ? "integer"
68
+ : "number";
69
+ };
70
+ }>;
@@ -0,0 +1,44 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ /**
4
+ * Array unique elements constraint.
5
+ *
6
+ * `UniqueItems` is a type tag that validates all elements in an array are
7
+ * unique (no duplicates). Apply it to array properties using TypeScript
8
+ * intersection types.
9
+ *
10
+ * Uniqueness is determined by:
11
+ *
12
+ * - **Primitives**: Strict equality (`===`)
13
+ * - **Objects**: Deep structural comparison
14
+ *
15
+ * This constraint is commonly combined with {@link MinItems} and {@link MaxItems}
16
+ * for comprehensive array validation. It's useful for modeling set-like data
17
+ * that must be represented as arrays in JSON.
18
+ *
19
+ * The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
20
+ * `typia.validate()`. It generates `uniqueItems: true` in JSON Schema.
21
+ *
22
+ * @author Jeongho Nam - https://github.com/samchon
23
+ * @example
24
+ * interface Preferences {
25
+ * // No duplicate tags allowed
26
+ * tags: (string & UniqueItems)[];
27
+ * // Unique user IDs
28
+ * favoriteUserIds: (number & UniqueItems)[];
29
+ * }
30
+ *
31
+ * @template Value Boolean flag, defaults to `true` (enable constraint)
32
+ */
33
+ export type UniqueItems<Value extends boolean = true> = TagBase<{
34
+ target: "array";
35
+ kind: "uniqueItems";
36
+ value: Value;
37
+ validate: Value extends true
38
+ ? `$importInternal("isUniqueItems")($input)`
39
+ : undefined;
40
+ exclusive: true;
41
+ schema: {
42
+ uniqueItems: true;
43
+ };
44
+ }>;
@@ -0,0 +1,21 @@
1
+ export * from "./Constant";
2
+ export * from "./ContentMediaType";
3
+ export * from "./Default";
4
+ export * from "./Example";
5
+ export * from "./Examples";
6
+ export * from "./ExclusiveMaximum";
7
+ export * from "./ExclusiveMinimum";
8
+ export * from "./Format";
9
+ export * from "./JsonSchemaPlugin";
10
+ export * from "./Maximum";
11
+ export * from "./MaxItems";
12
+ export * from "./MaxLength";
13
+ export * from "./Minimum";
14
+ export * from "./MinItems";
15
+ export * from "./MinLength";
16
+ export * from "./MultipleOf";
17
+ export * from "./Pattern";
18
+ export * from "./Sequence";
19
+ export * from "./TagBase";
20
+ export * from "./Type";
21
+ export * from "./UniqueItems";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type for assertion guard functions that narrow input type.
3
+ *
4
+ * `AssertionGuard<T>` is a function type that validates input at runtime and
5
+ * asserts it as type `T`. Unlike regular assertions that return the value,
6
+ * assertion guards return void but narrow the input parameter's type.
7
+ *
8
+ * @author Jeongho Nam - https://github.com/samchon
9
+ * @template T Target type to assert
10
+ * @throws {TypeGuardError} When validation fails
11
+ */
12
+ export type AssertionGuard<T> = (input: unknown) => asserts input is T;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Atomic (primitive) type utilities for typia's type system.
3
+ *
4
+ * @author Jeongho Nam - https://github.com/samchon
5
+ */
6
+ export namespace Atomic {
7
+ /** Union of JavaScript primitive value types. */
8
+ export type Type = boolean | number | string | bigint;
9
+
10
+ /** String literal names for atomic types. */
11
+ export type Literal = "boolean" | "integer" | "number" | "string" | "bigint";
12
+
13
+ /** Maps literal type names to their corresponding value types. */
14
+ export type Mapper = {
15
+ boolean: boolean;
16
+ integer: number;
17
+ number: number;
18
+ string: string;
19
+ bigint: bigint;
20
+ };
21
+ }
@@ -0,0 +1,75 @@
1
+ import { Equal } from "./internal/Equal";
2
+ import { IsTuple } from "./internal/IsTuple";
3
+ import { NativeClass } from "./internal/NativeClass";
4
+ import { ValueOf } from "./internal/ValueOf";
5
+
6
+ /**
7
+ * Converts all object keys to camelCase.
8
+ *
9
+ * `CamelCase<T>` transforms object property names to camelCase format and
10
+ * erases methods like {@link Resolved}. Recursively processes nested
11
+ * structures.
12
+ *
13
+ * @author Jeongho Nam - https://github.com/samchon
14
+ * @template T Target type to transform
15
+ */
16
+ export type CamelCase<T> =
17
+ Equal<T, CamelizeMain<T>> extends true ? T : CamelizeMain<T>;
18
+
19
+ type CamelizeMain<T> = T extends [never]
20
+ ? never // special trick for (jsonable | null) type
21
+ : T extends { valueOf(): boolean | bigint | number | string }
22
+ ? ValueOf<T>
23
+ : T extends Function
24
+ ? never
25
+ : T extends object
26
+ ? CamelizeObject<T>
27
+ : T;
28
+
29
+ type CamelizeObject<T extends object> =
30
+ T extends Array<infer U>
31
+ ? IsTuple<T> extends true
32
+ ? CamelizeTuple<T>
33
+ : CamelizeMain<U>[]
34
+ : T extends Set<infer U>
35
+ ? Set<CamelizeMain<U>>
36
+ : T extends Map<infer K, infer V>
37
+ ? Map<CamelizeMain<K>, CamelizeMain<V>>
38
+ : T extends WeakSet<any> | WeakMap<any, any>
39
+ ? never
40
+ : T extends NativeClass
41
+ ? T
42
+ : {
43
+ [Key in keyof T as CamelizeString<Key & string>]: CamelizeMain<
44
+ T[Key]
45
+ >;
46
+ };
47
+
48
+ type CamelizeTuple<T extends readonly any[]> = T extends []
49
+ ? []
50
+ : T extends [infer F]
51
+ ? [CamelizeMain<F>]
52
+ : T extends [infer F, ...infer Rest extends readonly any[]]
53
+ ? [CamelizeMain<F>, ...CamelizeTuple<Rest>]
54
+ : T extends [(infer F)?]
55
+ ? [CamelizeMain<F>?]
56
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
57
+ ? [CamelizeMain<F>?, ...CamelizeTuple<Rest>]
58
+ : [];
59
+
60
+ type CamelizeString<Key extends string> = Key extends `_${infer R}`
61
+ ? `_${CamelizeString<R>}`
62
+ : Key extends `${infer _F}_${infer _R}`
63
+ ? CamelizeSnakeString<Key>
64
+ : Key extends Uppercase<Key>
65
+ ? Lowercase<Key>
66
+ : CamelizePascalString<Key>;
67
+ type CamelizePascalString<Key extends string> =
68
+ Key extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : Key;
69
+ type CamelizeSnakeString<Key extends string> = Key extends `_${infer R}`
70
+ ? CamelizeSnakeString<R>
71
+ : Key extends `${infer F}_${infer M}${infer R}`
72
+ ? M extends "_"
73
+ ? CamelizeSnakeString<`${F}_${R}`>
74
+ : `${Lowercase<F>}${Uppercase<M>}${CamelizeSnakeString<R>}`
75
+ : Lowercase<Key>;
@@ -0,0 +1,15 @@
1
+ import { OmitNever } from "./OmitNever";
2
+
3
+ /**
4
+ * Extracts non-function properties from a class type.
5
+ *
6
+ * `ClassProperties<T>` filters out all method properties from a class, keeping
7
+ * only data properties. Useful for serialization where methods should be
8
+ * excluded.
9
+ *
10
+ * @author Jeongho Nam - https://github.com/samchon
11
+ * @template T Target class type
12
+ */
13
+ export type ClassProperties<T extends object> = OmitNever<{
14
+ [K in keyof T]: T[K] extends Function ? never : T[K];
15
+ }>;
@@ -0,0 +1,12 @@
1
+ import { SpecialFields } from "./SpecialFields";
2
+
3
+ /**
4
+ * Omits properties with `never` type from an object type.
5
+ *
6
+ * `OmitNever<T>` removes all properties whose value type is `never`, producing
7
+ * a cleaner type without impossible properties.
8
+ *
9
+ * @author Jeongho Nam - https://github.com/samchon
10
+ * @template T Target object type
11
+ */
12
+ export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
@@ -0,0 +1,71 @@
1
+ import { Equal } from "./internal/Equal";
2
+ import { IsTuple } from "./internal/IsTuple";
3
+ import { NativeClass } from "./internal/NativeClass";
4
+ import { ValueOf } from "./internal/ValueOf";
5
+
6
+ /**
7
+ * Converts all object keys to PascalCase.
8
+ *
9
+ * `PascalCase<T>` transforms object property names to PascalCase format and
10
+ * erases methods like {@link Resolved}. Recursively processes nested
11
+ * structures.
12
+ *
13
+ * @author Jeongho Nam - https://github.com/samchon
14
+ * @template T Target type to transform
15
+ */
16
+ export type PascalCase<T> =
17
+ Equal<T, PascalizeMain<T>> extends true ? T : PascalizeMain<T>;
18
+
19
+ type PascalizeMain<T> = T extends [never]
20
+ ? never // special trick for (jsonable | null) type
21
+ : T extends { valueOf(): boolean | bigint | number | string }
22
+ ? ValueOf<T>
23
+ : T extends Function
24
+ ? never
25
+ : T extends object
26
+ ? PascalizeObject<T>
27
+ : T;
28
+
29
+ type PascalizeObject<T extends object> =
30
+ T extends Array<infer U>
31
+ ? IsTuple<T> extends true
32
+ ? PascalizeTuple<T>
33
+ : PascalizeMain<U>[]
34
+ : T extends Set<infer U>
35
+ ? Set<PascalizeMain<U>>
36
+ : T extends Map<infer K, infer V>
37
+ ? Map<PascalizeMain<K>, PascalizeMain<V>>
38
+ : T extends WeakSet<any> | WeakMap<any, any>
39
+ ? never
40
+ : T extends NativeClass
41
+ ? T
42
+ : {
43
+ [Key in keyof T as PascalizeString<
44
+ Key & string
45
+ >]: PascalizeMain<T[Key]>;
46
+ };
47
+
48
+ type PascalizeTuple<T extends readonly any[]> = T extends []
49
+ ? []
50
+ : T extends [infer F]
51
+ ? [PascalizeMain<F>]
52
+ : T extends [infer F, ...infer Rest extends readonly any[]]
53
+ ? [PascalizeMain<F>, ...PascalizeTuple<Rest>]
54
+ : T extends [(infer F)?]
55
+ ? [PascalizeMain<F>?]
56
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
57
+ ? [PascalizeMain<F>?, ...PascalizeTuple<Rest>]
58
+ : [];
59
+
60
+ type PascalizeString<Key extends string> = Key extends `_${infer R}`
61
+ ? `_${PascalizeString<R>}`
62
+ : Key extends `${infer _F}_${infer _R}`
63
+ ? PascalizeSnakeString<Key>
64
+ : Capitalize<Key>;
65
+ type PascalizeSnakeString<Key extends string> = Key extends `_${infer R}`
66
+ ? PascalizeSnakeString<R>
67
+ : Key extends `${infer F}${infer M}_${infer R}`
68
+ ? `${Uppercase<F>}${Lowercase<M>}${PascalizeSnakeString<R>}`
69
+ : Key extends `${infer F}${infer R}`
70
+ ? `${Uppercase<F>}${Lowercase<R>}`
71
+ : Key;