@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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/lib/http/IHttpConnection.d.ts +163 -0
- package/lib/http/IHttpConnection.js +4 -0
- package/lib/http/IHttpConnection.js.map +1 -0
- package/lib/http/IHttpLlmApplication.d.ts +73 -0
- package/lib/http/IHttpLlmApplication.js +3 -0
- package/lib/http/IHttpLlmApplication.js.map +1 -0
- package/lib/http/IHttpLlmController.d.ts +86 -0
- package/lib/http/IHttpLlmController.js +3 -0
- package/lib/http/IHttpLlmController.js.map +1 -0
- package/lib/http/IHttpLlmFunction.d.ts +79 -0
- package/lib/http/IHttpLlmFunction.js +3 -0
- package/lib/http/IHttpLlmFunction.js.map +1 -0
- package/lib/http/IHttpMigrateApplication.d.ts +42 -0
- package/lib/http/IHttpMigrateApplication.js +3 -0
- package/lib/http/IHttpMigrateApplication.js.map +1 -0
- package/lib/http/IHttpMigrateRoute.d.ts +121 -0
- package/lib/http/IHttpMigrateRoute.js +3 -0
- package/lib/http/IHttpMigrateRoute.js.map +1 -0
- package/lib/http/IHttpResponse.d.ts +40 -0
- package/lib/http/IHttpResponse.js +3 -0
- package/lib/http/IHttpResponse.js.map +1 -0
- package/lib/http/index.d.ts +7 -0
- package/lib/http/index.js +24 -0
- package/lib/http/index.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/metadata/IJsDocTagInfo.d.ts +23 -0
- package/lib/metadata/IJsDocTagInfo.js +3 -0
- package/lib/metadata/IJsDocTagInfo.js.map +1 -0
- package/lib/metadata/IMetadataComponents.d.ts +20 -0
- package/lib/metadata/IMetadataComponents.js +3 -0
- package/lib/metadata/IMetadataComponents.js.map +1 -0
- package/lib/metadata/IMetadataSchema.d.ts +219 -0
- package/lib/metadata/IMetadataSchema.js +3 -0
- package/lib/metadata/IMetadataSchema.js.map +1 -0
- package/lib/metadata/IMetadataSchemaCollection.d.ts +18 -0
- package/lib/metadata/IMetadataSchemaCollection.js +3 -0
- package/lib/metadata/IMetadataSchemaCollection.js.map +1 -0
- package/lib/metadata/IMetadataSchemaUnit.d.ts +18 -0
- package/lib/metadata/IMetadataSchemaUnit.js +3 -0
- package/lib/metadata/IMetadataSchemaUnit.js.map +1 -0
- package/lib/metadata/IMetadataTypeTag.d.ts +28 -0
- package/lib/metadata/IMetadataTypeTag.js +3 -0
- package/lib/metadata/IMetadataTypeTag.js.map +1 -0
- package/lib/metadata/index.d.ts +6 -0
- package/lib/metadata/index.js +23 -0
- package/lib/metadata/index.js.map +1 -0
- package/lib/openapi/OpenApi.d.ts +454 -0
- package/lib/openapi/OpenApi.js +3 -0
- package/lib/openapi/OpenApi.js.map +1 -0
- package/lib/openapi/OpenApiV3.d.ts +420 -0
- package/lib/openapi/OpenApiV3.js +3 -0
- package/lib/openapi/OpenApiV3.js.map +1 -0
- package/lib/openapi/OpenApiV3_1.d.ts +463 -0
- package/lib/openapi/OpenApiV3_1.js +3 -0
- package/lib/openapi/OpenApiV3_1.js.map +1 -0
- package/lib/openapi/SwaggerV2.d.ts +343 -0
- package/lib/openapi/SwaggerV2.js +3 -0
- package/lib/openapi/SwaggerV2.js.map +1 -0
- package/lib/openapi/index.d.ts +4 -0
- package/lib/openapi/index.js +21 -0
- package/lib/openapi/index.js.map +1 -0
- package/lib/protobuf/ProtobufWire.d.ts +46 -0
- package/lib/protobuf/ProtobufWire.js +3 -0
- package/lib/protobuf/ProtobufWire.js.map +1 -0
- package/lib/protobuf/index.d.ts +1 -0
- package/lib/protobuf/index.js +18 -0
- package/lib/protobuf/index.js.map +1 -0
- package/lib/schema/IJsonSchemaApplication.d.ts +232 -0
- package/lib/schema/IJsonSchemaApplication.js +3 -0
- package/lib/schema/IJsonSchemaApplication.js.map +1 -0
- package/lib/schema/IJsonSchemaAttribute.d.ts +152 -0
- package/lib/schema/IJsonSchemaAttribute.js +3 -0
- package/lib/schema/IJsonSchemaAttribute.js.map +1 -0
- package/lib/schema/IJsonSchemaCollection.d.ts +109 -0
- package/lib/schema/IJsonSchemaCollection.js +3 -0
- package/lib/schema/IJsonSchemaCollection.js.map +1 -0
- package/lib/schema/IJsonSchemaTransformError.d.ts +81 -0
- package/lib/schema/IJsonSchemaTransformError.js +3 -0
- package/lib/schema/IJsonSchemaTransformError.js.map +1 -0
- package/lib/schema/IJsonSchemaUnit.d.ts +106 -0
- package/lib/schema/IJsonSchemaUnit.js +3 -0
- package/lib/schema/IJsonSchemaUnit.js.map +1 -0
- package/lib/schema/ILlmApplication.d.ts +95 -0
- package/lib/schema/ILlmApplication.js +3 -0
- package/lib/schema/ILlmApplication.js.map +1 -0
- package/lib/schema/ILlmController.d.ts +53 -0
- package/lib/schema/ILlmController.js +3 -0
- package/lib/schema/ILlmController.js.map +1 -0
- package/lib/schema/ILlmFunction.d.ts +134 -0
- package/lib/schema/ILlmFunction.js +3 -0
- package/lib/schema/ILlmFunction.js.map +1 -0
- package/lib/schema/ILlmSchema.d.ts +412 -0
- package/lib/schema/ILlmSchema.js +3 -0
- package/lib/schema/ILlmSchema.js.map +1 -0
- package/lib/schema/IResult.d.ts +81 -0
- package/lib/schema/IResult.js +3 -0
- package/lib/schema/IResult.js.map +1 -0
- package/lib/schema/IValidation.d.ts +123 -0
- package/lib/schema/IValidation.js +3 -0
- package/lib/schema/IValidation.js.map +1 -0
- package/lib/schema/index.d.ts +11 -0
- package/lib/schema/index.js +28 -0
- package/lib/schema/index.js.map +1 -0
- package/lib/tags/Constant.d.ts +44 -0
- package/lib/tags/Constant.js +3 -0
- package/lib/tags/Constant.js.map +1 -0
- package/lib/tags/ContentMediaType.d.ts +39 -0
- package/lib/tags/ContentMediaType.js +3 -0
- package/lib/tags/ContentMediaType.js.map +1 -0
- package/lib/tags/Default.d.ts +42 -0
- package/lib/tags/Default.js +3 -0
- package/lib/tags/Default.js.map +1 -0
- package/lib/tags/Example.d.ts +38 -0
- package/lib/tags/Example.js +3 -0
- package/lib/tags/Example.js.map +1 -0
- package/lib/tags/Examples.d.ts +44 -0
- package/lib/tags/Examples.js +3 -0
- package/lib/tags/Examples.js.map +1 -0
- package/lib/tags/ExclusiveMaximum.d.ts +39 -0
- package/lib/tags/ExclusiveMaximum.js +3 -0
- package/lib/tags/ExclusiveMaximum.js.map +1 -0
- package/lib/tags/ExclusiveMinimum.d.ts +39 -0
- package/lib/tags/ExclusiveMinimum.js +3 -0
- package/lib/tags/ExclusiveMinimum.js.map +1 -0
- package/lib/tags/Format.d.ts +43 -0
- package/lib/tags/Format.js +3 -0
- package/lib/tags/Format.js.map +1 -0
- package/lib/tags/JsonSchemaPlugin.d.ts +44 -0
- package/lib/tags/JsonSchemaPlugin.js +3 -0
- package/lib/tags/JsonSchemaPlugin.js.map +1 -0
- package/lib/tags/MaxItems.d.ts +38 -0
- package/lib/tags/MaxItems.js +3 -0
- package/lib/tags/MaxItems.js.map +1 -0
- package/lib/tags/MaxLength.d.ts +36 -0
- package/lib/tags/MaxLength.js +3 -0
- package/lib/tags/MaxLength.js.map +1 -0
- package/lib/tags/Maximum.d.ts +41 -0
- package/lib/tags/Maximum.js +3 -0
- package/lib/tags/Maximum.js.map +1 -0
- package/lib/tags/MinItems.d.ts +38 -0
- package/lib/tags/MinItems.js +3 -0
- package/lib/tags/MinItems.js.map +1 -0
- package/lib/tags/MinLength.d.ts +36 -0
- package/lib/tags/MinLength.js +3 -0
- package/lib/tags/MinLength.js.map +1 -0
- package/lib/tags/Minimum.d.ts +41 -0
- package/lib/tags/Minimum.js +3 -0
- package/lib/tags/Minimum.js.map +1 -0
- package/lib/tags/MultipleOf.d.ts +49 -0
- package/lib/tags/MultipleOf.js +3 -0
- package/lib/tags/MultipleOf.js.map +1 -0
- package/lib/tags/Pattern.d.ts +51 -0
- package/lib/tags/Pattern.js +3 -0
- package/lib/tags/Pattern.js.map +1 -0
- package/lib/tags/Sequence.d.ts +42 -0
- package/lib/tags/Sequence.js +3 -0
- package/lib/tags/Sequence.js.map +1 -0
- package/lib/tags/TagBase.d.ts +109 -0
- package/lib/tags/TagBase.js +3 -0
- package/lib/tags/TagBase.js.map +1 -0
- package/lib/tags/Type.d.ts +53 -0
- package/lib/tags/Type.js +3 -0
- package/lib/tags/Type.js.map +1 -0
- package/lib/tags/UniqueItems.d.ts +41 -0
- package/lib/tags/UniqueItems.js +3 -0
- package/lib/tags/UniqueItems.js.map +1 -0
- package/lib/tags/index.d.ts +21 -0
- package/lib/tags/index.js +38 -0
- package/lib/tags/index.js.map +1 -0
- package/lib/typings/AssertionGuard.d.ts +12 -0
- package/lib/typings/AssertionGuard.js +3 -0
- package/lib/typings/AssertionGuard.js.map +1 -0
- package/lib/typings/Atomic.d.ts +19 -0
- package/lib/typings/Atomic.js +3 -0
- package/lib/typings/Atomic.js.map +1 -0
- package/lib/typings/CamelCase.d.ts +26 -0
- package/lib/typings/CamelCase.js +3 -0
- package/lib/typings/CamelCase.js.map +1 -0
- package/lib/typings/ClassProperties.d.ts +14 -0
- package/lib/typings/ClassProperties.js +3 -0
- package/lib/typings/ClassProperties.js.map +1 -0
- package/lib/typings/OmitNever.d.ts +11 -0
- package/lib/typings/OmitNever.js +3 -0
- package/lib/typings/OmitNever.js.map +1 -0
- package/lib/typings/PascalCase.d.ts +25 -0
- package/lib/typings/PascalCase.js +3 -0
- package/lib/typings/PascalCase.js.map +1 -0
- package/lib/typings/Primitive.d.ts +29 -0
- package/lib/typings/Primitive.js +3 -0
- package/lib/typings/Primitive.js.map +1 -0
- package/lib/typings/ProtobufAtomic.d.ts +15 -0
- package/lib/typings/ProtobufAtomic.js +3 -0
- package/lib/typings/ProtobufAtomic.js.map +1 -0
- package/lib/typings/Resolved.d.ts +23 -0
- package/lib/typings/Resolved.js +3 -0
- package/lib/typings/Resolved.js.map +1 -0
- package/lib/typings/SnakeCase.d.ts +31 -0
- package/lib/typings/SnakeCase.js +3 -0
- package/lib/typings/SnakeCase.js.map +1 -0
- package/lib/typings/SpecialFields.d.ts +13 -0
- package/lib/typings/SpecialFields.js +3 -0
- package/lib/typings/SpecialFields.js.map +1 -0
- package/lib/typings/ValidationPipe.d.ts +18 -0
- package/lib/typings/ValidationPipe.js +3 -0
- package/lib/typings/ValidationPipe.js.map +1 -0
- package/lib/typings/index.d.ts +12 -0
- package/lib/typings/index.js +29 -0
- package/lib/typings/index.js.map +1 -0
- package/lib/typings/internal/Equal.d.ts +11 -0
- package/lib/typings/internal/Equal.js +3 -0
- package/lib/typings/internal/Equal.js.map +1 -0
- package/lib/typings/internal/IsTuple.d.ts +13 -0
- package/lib/typings/internal/IsTuple.js +3 -0
- package/lib/typings/internal/IsTuple.js.map +1 -0
- package/lib/typings/internal/NativeClass.d.ts +9 -0
- package/lib/typings/internal/NativeClass.js +3 -0
- package/lib/typings/internal/NativeClass.js.map +1 -0
- package/lib/typings/internal/ValueOf.d.ts +15 -0
- package/lib/typings/internal/ValueOf.js +3 -0
- package/lib/typings/internal/ValueOf.js.map +1 -0
- package/lib/utils/IRandomGenerator.d.ts +68 -0
- package/lib/utils/IRandomGenerator.js +3 -0
- package/lib/utils/IRandomGenerator.js.map +1 -0
- package/lib/utils/IReadableURLSearchParams.d.ts +22 -0
- package/lib/utils/IReadableURLSearchParams.js +3 -0
- package/lib/utils/IReadableURLSearchParams.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +79 -0
- package/src/http/IHttpConnection.ts +200 -0
- package/src/http/IHttpLlmApplication.ts +83 -0
- package/src/http/IHttpLlmController.ts +96 -0
- package/src/http/IHttpLlmFunction.ts +93 -0
- package/src/http/IHttpMigrateApplication.ts +48 -0
- package/src/http/IHttpMigrateRoute.ts +165 -0
- package/src/http/IHttpResponse.ts +42 -0
- package/src/http/index.ts +7 -0
- package/src/index.ts +9 -0
- package/src/metadata/IJsDocTagInfo.ts +25 -0
- package/src/metadata/IMetadataComponents.ts +24 -0
- package/src/metadata/IMetadataSchema.ts +293 -0
- package/src/metadata/IMetadataSchemaCollection.ts +20 -0
- package/src/metadata/IMetadataSchemaUnit.ts +20 -0
- package/src/metadata/IMetadataTypeTag.ts +39 -0
- package/src/metadata/index.ts +6 -0
- package/src/openapi/OpenApi.ts +643 -0
- package/src/openapi/OpenApiV3.ts +655 -0
- package/src/openapi/OpenApiV3_1.ts +735 -0
- package/src/openapi/SwaggerV2.ts +559 -0
- package/src/openapi/index.ts +4 -0
- package/src/protobuf/ProtobufWire.ts +51 -0
- package/src/protobuf/index.ts +1 -0
- package/src/schema/IJsonSchemaApplication.ts +274 -0
- package/src/schema/IJsonSchemaAttribute.ts +158 -0
- package/src/schema/IJsonSchemaCollection.ts +123 -0
- package/src/schema/IJsonSchemaTransformError.ts +86 -0
- package/src/schema/IJsonSchemaUnit.ts +120 -0
- package/src/schema/ILlmApplication.ts +103 -0
- package/src/schema/ILlmController.ts +57 -0
- package/src/schema/ILlmFunction.ts +144 -0
- package/src/schema/ILlmSchema.ts +484 -0
- package/src/schema/IResult.ts +84 -0
- package/src/schema/IValidation.ts +134 -0
- package/src/schema/index.ts +13 -0
- package/src/tags/Constant.ts +49 -0
- package/src/tags/ContentMediaType.ts +40 -0
- package/src/tags/Default.ts +50 -0
- package/src/tags/Example.ts +48 -0
- package/src/tags/Examples.ts +50 -0
- package/src/tags/ExclusiveMaximum.ts +46 -0
- package/src/tags/ExclusiveMinimum.ts +46 -0
- package/src/tags/Format.ts +76 -0
- package/src/tags/JsonSchemaPlugin.ts +45 -0
- package/src/tags/MaxItems.ts +39 -0
- package/src/tags/MaxLength.ts +37 -0
- package/src/tags/Maximum.ts +44 -0
- package/src/tags/MinItems.ts +39 -0
- package/src/tags/MinLength.ts +37 -0
- package/src/tags/Minimum.ts +44 -0
- package/src/tags/MultipleOf.ts +54 -0
- package/src/tags/Pattern.ts +59 -0
- package/src/tags/Sequence.ts +43 -0
- package/src/tags/TagBase.ts +131 -0
- package/src/tags/Type.ts +70 -0
- package/src/tags/UniqueItems.ts +44 -0
- package/src/tags/index.ts +21 -0
- package/src/typings/AssertionGuard.ts +12 -0
- package/src/typings/Atomic.ts +21 -0
- package/src/typings/CamelCase.ts +75 -0
- package/src/typings/ClassProperties.ts +15 -0
- package/src/typings/OmitNever.ts +12 -0
- package/src/typings/PascalCase.ts +71 -0
- package/src/typings/Primitive.ts +71 -0
- package/src/typings/ProtobufAtomic.ts +30 -0
- package/src/typings/Resolved.ts +58 -0
- package/src/typings/SnakeCase.ts +126 -0
- package/src/typings/SpecialFields.ts +13 -0
- package/src/typings/ValidationPipe.ts +20 -0
- package/src/typings/index.ts +13 -0
- package/src/typings/internal/Equal.ts +14 -0
- package/src/typings/internal/IsTuple.ts +17 -0
- package/src/typings/internal/NativeClass.ts +31 -0
- package/src/typings/internal/ValueOf.ts +29 -0
- package/src/utils/IRandomGenerator.ts +105 -0
- package/src/utils/IReadableURLSearchParams.ts +25 -0
- package/src/utils/index.ts +2 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Documentation metadata for literal/constant values.
|
|
4
|
+
*
|
|
5
|
+
* `Constant<Value, Content>` enhances literal type values with human-readable
|
|
6
|
+
* documentation that appears in generated JSON Schema output. This is useful
|
|
7
|
+
* for enum-like values where each literal needs individual documentation.
|
|
8
|
+
*
|
|
9
|
+
* Unlike TypeScript enums which lose their documentation in schema generation,
|
|
10
|
+
* `Constant` preserves title and description for each value. This helps API
|
|
11
|
+
* consumers understand the meaning of each allowed value.
|
|
12
|
+
*
|
|
13
|
+
* The tag itself doesn't perform validation - it only adds metadata. The
|
|
14
|
+
* literal type constraint is enforced by TypeScript's type system.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* type OrderStatus =
|
|
19
|
+
* | Constant<
|
|
20
|
+
* "pending",
|
|
21
|
+
* { title: "Pending"; description: "Order placed" }
|
|
22
|
+
* >
|
|
23
|
+
* | Constant<"shipped", { title: "Shipped"; description: "In transit" }>
|
|
24
|
+
* | Constant<
|
|
25
|
+
* "delivered",
|
|
26
|
+
* { title: "Delivered"; description: "Complete" }
|
|
27
|
+
* >;
|
|
28
|
+
*
|
|
29
|
+
* interface Order {
|
|
30
|
+
* status: OrderStatus;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @template Value The literal value (boolean, number, string, or bigint)
|
|
34
|
+
* @template Content Object with optional `title` and `description` properties
|
|
35
|
+
*/
|
|
36
|
+
export type Constant<Value extends boolean | number | string | bigint, Content extends {
|
|
37
|
+
title?: string | undefined;
|
|
38
|
+
description?: string | undefined;
|
|
39
|
+
}> = Value & TagBase<{
|
|
40
|
+
target: "string" | "boolean" | "number" | "bigint";
|
|
41
|
+
kind: "constant";
|
|
42
|
+
value: undefined;
|
|
43
|
+
schema: Content;
|
|
44
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../src/tags/Constant.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* MIME type metadata for string content.
|
|
4
|
+
*
|
|
5
|
+
* `ContentMediaType<Type>` is a type tag that documents the media type of
|
|
6
|
+
* string content. This is metadata-only - no runtime validation is performed.
|
|
7
|
+
* The information appears in generated JSON Schema output.
|
|
8
|
+
*
|
|
9
|
+
* This is useful when a string property contains encoded binary data or
|
|
10
|
+
* structured content that should be interpreted according to a specific media
|
|
11
|
+
* type, such as base64-encoded images or embedded JSON.
|
|
12
|
+
*
|
|
13
|
+
* Common MIME types:
|
|
14
|
+
*
|
|
15
|
+
* - `"application/json"`: JSON data as string
|
|
16
|
+
* - `"application/xml"`: XML data as string
|
|
17
|
+
* - `"image/png"`: Base64-encoded PNG image
|
|
18
|
+
* - `"image/jpeg"`: Base64-encoded JPEG image
|
|
19
|
+
* - `"application/octet-stream"`: Generic binary data
|
|
20
|
+
*
|
|
21
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
22
|
+
* @example
|
|
23
|
+
* interface Document {
|
|
24
|
+
* // Base64-encoded PNG image
|
|
25
|
+
* thumbnail: string & ContentMediaType<"image/png">;
|
|
26
|
+
* // JSON stored as string
|
|
27
|
+
* metadata: string & ContentMediaType<"application/json">;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @template Value MIME type string literal
|
|
31
|
+
*/
|
|
32
|
+
export type ContentMediaType<Value extends string> = TagBase<{
|
|
33
|
+
target: "string";
|
|
34
|
+
kind: "contentMediaType";
|
|
35
|
+
value: undefined;
|
|
36
|
+
schema: {
|
|
37
|
+
contentMediaType: Value;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentMediaType.js","sourceRoot":"","sources":["../../src/tags/ContentMediaType.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Default value metadata for JSON Schema generation.
|
|
4
|
+
*
|
|
5
|
+
* `Default<Value>` is a type tag that specifies a default value for a property
|
|
6
|
+
* in the generated JSON Schema. This is metadata-only - typia does not
|
|
7
|
+
* automatically apply default values at runtime.
|
|
8
|
+
*
|
|
9
|
+
* The default value appears in the `default` field of the JSON Schema output,
|
|
10
|
+
* which API documentation tools and code generators can use to show default
|
|
11
|
+
* values or generate code that applies them.
|
|
12
|
+
*
|
|
13
|
+
* Only primitive literal types are supported: `boolean`, `bigint`, `number`,
|
|
14
|
+
* and `string`. For complex defaults, consider using optional properties with
|
|
15
|
+
* runtime default assignment.
|
|
16
|
+
*
|
|
17
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
18
|
+
* @example
|
|
19
|
+
* interface Config {
|
|
20
|
+
* // Default to 10 items per page
|
|
21
|
+
* pageSize: (number & Default<10>) | undefined;
|
|
22
|
+
* // Default to enabled
|
|
23
|
+
* enabled: (boolean & Default<true>) | undefined;
|
|
24
|
+
* // Default sort order
|
|
25
|
+
* sortOrder: (string & Default<"asc">) | undefined;
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @template Value The default value literal (must be a primitive)
|
|
29
|
+
*/
|
|
30
|
+
export type Default<Value extends boolean | bigint | number | string> = TagBase<{
|
|
31
|
+
target: Value extends boolean ? "boolean" : Value extends bigint ? "bigint" : Value extends number ? "number" : "string";
|
|
32
|
+
kind: "default";
|
|
33
|
+
value: Value;
|
|
34
|
+
exclusive: true;
|
|
35
|
+
schema: Value extends bigint ? {
|
|
36
|
+
default: Numeric<Value>;
|
|
37
|
+
} : {
|
|
38
|
+
default: Value;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}` ? N : never;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Default.js","sourceRoot":"","sources":["../../src/tags/Default.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Single example value for JSON Schema documentation.
|
|
4
|
+
*
|
|
5
|
+
* `Example<Value>` is a type tag that adds a representative example value to
|
|
6
|
+
* the generated JSON Schema. This is metadata-only - it appears in the
|
|
7
|
+
* `example` field of the schema and helps API consumers understand expected
|
|
8
|
+
* values.
|
|
9
|
+
*
|
|
10
|
+
* Examples are displayed in API documentation tools like Swagger UI and can be
|
|
11
|
+
* used by code generators to produce more helpful client code.
|
|
12
|
+
*
|
|
13
|
+
* Supports all JSON-compatible types: primitives, objects, arrays, and null.
|
|
14
|
+
* For multiple named examples, use {@link Examples} instead.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface User {
|
|
19
|
+
* email: string & Format<"email"> & Example<"user@example.com">;
|
|
20
|
+
* age: number & Minimum<0> & Example<25>;
|
|
21
|
+
* tags: string[] & Example<["admin", "active"]>;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @template Value The example value (any JSON-compatible type)
|
|
25
|
+
*/
|
|
26
|
+
export type Example<Value extends boolean | bigint | number | string | object | Array<unknown> | null> = TagBase<{
|
|
27
|
+
target: "boolean" | "bigint" | "number" | "string" | "array" | "object";
|
|
28
|
+
kind: "example";
|
|
29
|
+
value: Value;
|
|
30
|
+
exclusive: true;
|
|
31
|
+
schema: Value extends bigint ? {
|
|
32
|
+
example: Numeric<Value>;
|
|
33
|
+
} : {
|
|
34
|
+
example: Value;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}` ? N : never;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Example.js","sourceRoot":"","sources":["../../src/tags/Example.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Multiple named examples for JSON Schema documentation.
|
|
4
|
+
*
|
|
5
|
+
* `Examples<Record>` is a type tag that adds multiple labeled example values to
|
|
6
|
+
* the generated JSON Schema. Each example has a name and a value, providing
|
|
7
|
+
* rich documentation for different use cases or scenarios.
|
|
8
|
+
*
|
|
9
|
+
* This is useful when a property can have various valid values and you want to
|
|
10
|
+
* illustrate multiple possibilities, such as different user types, edge cases,
|
|
11
|
+
* or common configurations.
|
|
12
|
+
*
|
|
13
|
+
* The examples appear in the `examples` field of the JSON Schema and are
|
|
14
|
+
* displayed by API documentation tools. For a single unnamed example, use
|
|
15
|
+
* {@link Example} instead.
|
|
16
|
+
*
|
|
17
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
18
|
+
* @example
|
|
19
|
+
* interface Product {
|
|
20
|
+
* price: number &
|
|
21
|
+
* Examples<{
|
|
22
|
+
* budget: 9.99;
|
|
23
|
+
* premium: 99.99;
|
|
24
|
+
* enterprise: 999.99;
|
|
25
|
+
* }>;
|
|
26
|
+
* status: string &
|
|
27
|
+
* Examples<{
|
|
28
|
+
* active: "active";
|
|
29
|
+
* discontinued: "discontinued";
|
|
30
|
+
* preorder: "preorder";
|
|
31
|
+
* }>;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @template Value Record mapping example names to their values
|
|
35
|
+
*/
|
|
36
|
+
export type Examples<Value extends Record<string, boolean | bigint | number | string | object | Array<unknown> | null>> = TagBase<{
|
|
37
|
+
target: "boolean" | "bigint" | "number" | "string" | "array" | "object";
|
|
38
|
+
kind: "examples";
|
|
39
|
+
value: Value;
|
|
40
|
+
exclusive: true;
|
|
41
|
+
schema: {
|
|
42
|
+
examples: Value;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Examples.js","sourceRoot":"","sources":["../../src/tags/Examples.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Exclusive maximum value constraint (value < max).
|
|
4
|
+
*
|
|
5
|
+
* `ExclusiveMaximum<N>` is a type tag that validates numeric values are
|
|
6
|
+
* strictly less than the specified bound (not equal). Apply it to `number` or
|
|
7
|
+
* `bigint` properties using TypeScript intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is **mutually exclusive** with {@link Maximum} - you cannot
|
|
10
|
+
* use both on the same property. Use `ExclusiveMaximum` for exclusive bounds
|
|
11
|
+
* (<) and `Maximum` for inclusive bounds (<=).
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It also generates `exclusiveMaximum` in JSON Schema.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface Temperature {
|
|
19
|
+
* // Must be less than 100 (boiling point), not equal
|
|
20
|
+
* celsius: number & ExclusiveMaximum<100>;
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @template Value The maximum bound (exclusive - value must be less)
|
|
24
|
+
*/
|
|
25
|
+
export type ExclusiveMaximum<Value extends number | bigint> = TagBase<{
|
|
26
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
27
|
+
kind: "exclusiveMaximum";
|
|
28
|
+
value: Value;
|
|
29
|
+
validate: `$input < ${Cast<Value>}`;
|
|
30
|
+
exclusive: ["exclusiveMaximum", "maximum"];
|
|
31
|
+
schema: Value extends bigint ? {
|
|
32
|
+
exclusiveMaximum: Numeric<Value>;
|
|
33
|
+
} : {
|
|
34
|
+
exclusiveMaximum: Value;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
type Cast<Value extends number | bigint> = Value extends number ? Value : `BigInt(${Value})`;
|
|
38
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}` ? N : never;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExclusiveMaximum.js","sourceRoot":"","sources":["../../src/tags/ExclusiveMaximum.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Exclusive minimum value constraint (value > min).
|
|
4
|
+
*
|
|
5
|
+
* `ExclusiveMinimum<N>` is a type tag that validates numeric values are
|
|
6
|
+
* strictly greater than the specified bound (not equal). Apply it to `number`
|
|
7
|
+
* or `bigint` properties using TypeScript intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is **mutually exclusive** with {@link Minimum} - you cannot
|
|
10
|
+
* use both on the same property. Use `ExclusiveMinimum` for exclusive bounds
|
|
11
|
+
* (>) and `Minimum` for inclusive bounds (>=).
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It also generates `exclusiveMinimum` in JSON Schema.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface PositiveNumber {
|
|
19
|
+
* // Must be greater than 0, not equal to 0
|
|
20
|
+
* value: number & ExclusiveMinimum<0>;
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @template Value The minimum bound (exclusive - value must be greater)
|
|
24
|
+
*/
|
|
25
|
+
export type ExclusiveMinimum<Value extends number | bigint> = TagBase<{
|
|
26
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
27
|
+
kind: "exclusiveMinimum";
|
|
28
|
+
value: Value;
|
|
29
|
+
validate: `${Cast<Value>} < $input`;
|
|
30
|
+
exclusive: ["exclusiveMinimum", "minimum"];
|
|
31
|
+
schema: Value extends bigint ? {
|
|
32
|
+
exclusiveMinimum: Numeric<Value>;
|
|
33
|
+
} : {
|
|
34
|
+
exclusiveMinimum: Value;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
type Cast<Value extends number | bigint> = Value extends number ? Value : `BigInt(${Value})`;
|
|
38
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}` ? N : never;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExclusiveMinimum.js","sourceRoot":"","sources":["../../src/tags/ExclusiveMinimum.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* String format validation constraint.
|
|
4
|
+
*
|
|
5
|
+
* `Format<Value>` validates strings against predefined formats (email, uuid,
|
|
6
|
+
* url, date-time, etc.). Mutually exclusive with {@link Pattern}.
|
|
7
|
+
*
|
|
8
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
+
* @template Value Format identifier (see {@link Format.Value} for options)
|
|
10
|
+
*/
|
|
11
|
+
export type Format<Value extends Format.Value> = TagBase<{
|
|
12
|
+
target: "string";
|
|
13
|
+
kind: "format";
|
|
14
|
+
value: Value;
|
|
15
|
+
validate: `$importInternal("isFormat${PascalizeString<Value>}")($input)`;
|
|
16
|
+
exclusive: ["format", "pattern"];
|
|
17
|
+
schema: {
|
|
18
|
+
format: Value;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare namespace Format {
|
|
22
|
+
/**
|
|
23
|
+
* Supported format identifiers.
|
|
24
|
+
*
|
|
25
|
+
* Standard JSON Schema formats:
|
|
26
|
+
*
|
|
27
|
+
* - `email`, `idn-email`: Email addresses
|
|
28
|
+
* - `hostname`, `idn-hostname`: Hostnames
|
|
29
|
+
* - `uri`, `uri-reference`, `uri-template`, `url`: URLs
|
|
30
|
+
* - `iri`, `iri-reference`: Internationalized URLs
|
|
31
|
+
* - `uuid`: UUID strings
|
|
32
|
+
* - `ipv4`, `ipv6`: IP addresses
|
|
33
|
+
* - `date-time`, `date`, `time`, `duration`: Date/time formats
|
|
34
|
+
* - `json-pointer`, `relative-json-pointer`: JSON pointers
|
|
35
|
+
* - `regex`: Regular expression patterns
|
|
36
|
+
* - `byte`: Base64-encoded data
|
|
37
|
+
* - `password`: Password fields (for documentation only)
|
|
38
|
+
*/
|
|
39
|
+
type Value = "byte" | "password" | "regex" | "uuid" | "email" | "hostname" | "idn-email" | "idn-hostname" | "iri" | "iri-reference" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "uri-template" | "url" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer";
|
|
40
|
+
}
|
|
41
|
+
type PascalizeString<Key extends string> = Key extends `-${infer R}` ? `${PascalizeString<R>}` : Key extends `${infer _F}-${infer _R}` ? PascalizeSnakeString<Key> : Capitalize<Key>;
|
|
42
|
+
type PascalizeSnakeString<Key extends string> = Key extends `-${infer R}` ? PascalizeSnakeString<R> : Key extends `${infer F}${infer M}-${infer R}` ? `${Uppercase<F>}${Lowercase<M>}${PascalizeSnakeString<R>}` : Key extends `${infer F}${infer R}` ? `${Uppercase<F>}${Lowercase<R>}` : Key;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../src/tags/Format.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Injects custom properties into generated JSON Schema.
|
|
4
|
+
*
|
|
5
|
+
* `JsonSchemaPlugin<Schema>` is a type tag that merges custom properties into
|
|
6
|
+
* the generated JSON Schema output. This enables vendor extensions (typically
|
|
7
|
+
* prefixed with `x-`) and custom metadata that tools in your ecosystem may
|
|
8
|
+
* require.
|
|
9
|
+
*
|
|
10
|
+
* This is metadata-only - it does not affect runtime validation. The properties
|
|
11
|
+
* are simply merged into the schema for the annotated type.
|
|
12
|
+
*
|
|
13
|
+
* Common use cases:
|
|
14
|
+
*
|
|
15
|
+
* - OpenAPI vendor extensions (`x-*` properties)
|
|
16
|
+
* - Custom UI hints for form generators
|
|
17
|
+
* - Tool-specific metadata
|
|
18
|
+
* - Integration with third-party schema consumers
|
|
19
|
+
*
|
|
20
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
21
|
+
* @example
|
|
22
|
+
* interface FormField {
|
|
23
|
+
* // Add custom UI hints for form generation
|
|
24
|
+
* email: string &
|
|
25
|
+
* Format<"email"> &
|
|
26
|
+
* JsonSchemaPlugin<{
|
|
27
|
+
* "x-ui-widget": "email-input";
|
|
28
|
+
* "x-ui-placeholder": "Enter your email";
|
|
29
|
+
* }>;
|
|
30
|
+
* // Add custom sorting metadata
|
|
31
|
+
* priority: number &
|
|
32
|
+
* JsonSchemaPlugin<{
|
|
33
|
+
* "x-sort-order": "descending";
|
|
34
|
+
* }>;
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* @template Schema Object type containing the custom properties to merge
|
|
38
|
+
*/
|
|
39
|
+
export type JsonSchemaPlugin<Schema extends object> = TagBase<{
|
|
40
|
+
target: "string" | "boolean" | "bigint" | "number" | "array" | "object";
|
|
41
|
+
kind: "jsonPlugin";
|
|
42
|
+
value: undefined;
|
|
43
|
+
schema: Schema;
|
|
44
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchemaPlugin.js","sourceRoot":"","sources":["../../src/tags/JsonSchemaPlugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Array maximum items constraint.
|
|
4
|
+
*
|
|
5
|
+
* `MaxItems<N>` is a type tag that validates array values have at most the
|
|
6
|
+
* specified number of elements. Apply it to array properties using TypeScript
|
|
7
|
+
* intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is commonly combined with {@link MinItems} to define a valid
|
|
10
|
+
* size range. It can also be combined with {@link UniqueItems} to require unique
|
|
11
|
+
* elements.
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It generates `maxItems` in JSON Schema output.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface Upload {
|
|
19
|
+
* // Maximum 5 files per upload
|
|
20
|
+
* files: (File & MaxItems<5>)[];
|
|
21
|
+
* }
|
|
22
|
+
* interface Config {
|
|
23
|
+
* // Between 1-3 backup servers allowed
|
|
24
|
+
* backupServers: (Server & MinItems<1> & MaxItems<3>)[];
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @template Value Maximum number of elements allowed
|
|
28
|
+
*/
|
|
29
|
+
export type MaxItems<Value extends number> = TagBase<{
|
|
30
|
+
target: "array";
|
|
31
|
+
kind: "maxItems";
|
|
32
|
+
value: Value;
|
|
33
|
+
validate: `$input.length <= ${Value}`;
|
|
34
|
+
exclusive: true;
|
|
35
|
+
schema: {
|
|
36
|
+
maxItems: Value;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxItems.js","sourceRoot":"","sources":["../../src/tags/MaxItems.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* String maximum length constraint.
|
|
4
|
+
*
|
|
5
|
+
* `MaxLength<N>` is a type tag that validates string values have at most the
|
|
6
|
+
* specified number of characters. Apply it to `string` properties using
|
|
7
|
+
* TypeScript intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is commonly combined with {@link MinLength} to define a valid
|
|
10
|
+
* length range. Multiple length constraints can be applied to the same property
|
|
11
|
+
* (all must pass).
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It generates `maxLength` in JSON Schema output.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface Article {
|
|
19
|
+
* // Title limited to 100 characters
|
|
20
|
+
* title: string & MaxLength<100>;
|
|
21
|
+
* // Description between 10-500 characters
|
|
22
|
+
* description: string & MinLength<10> & MaxLength<500>;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @template Value Maximum number of characters allowed
|
|
26
|
+
*/
|
|
27
|
+
export type MaxLength<Value extends number> = TagBase<{
|
|
28
|
+
target: "string";
|
|
29
|
+
kind: "maxLength";
|
|
30
|
+
value: Value;
|
|
31
|
+
validate: `$input.length <= ${Value}`;
|
|
32
|
+
exclusive: true;
|
|
33
|
+
schema: {
|
|
34
|
+
maxLength: Value;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxLength.js","sourceRoot":"","sources":["../../src/tags/MaxLength.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Inclusive maximum value constraint (value <= max).
|
|
4
|
+
*
|
|
5
|
+
* `Maximum<N>` is a type tag that validates numeric values are less than or
|
|
6
|
+
* equal to the specified bound. Apply it to `number` or `bigint` properties
|
|
7
|
+
* using TypeScript intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is **mutually exclusive** with {@link ExclusiveMaximum} - you
|
|
10
|
+
* cannot use both on the same property. Use `Maximum` for inclusive bounds (<=)
|
|
11
|
+
* and `ExclusiveMaximum` for exclusive bounds (<).
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It also generates `maximum` in JSON Schema output.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface Rating {
|
|
19
|
+
* // Score from 0-100
|
|
20
|
+
* score: number & Minimum<0> & Maximum<100>;
|
|
21
|
+
* // Percentage cannot exceed 1.0
|
|
22
|
+
* ratio: number & Maximum<1.0>;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @template Value The maximum allowed value (inclusive)
|
|
26
|
+
*/
|
|
27
|
+
export type Maximum<Value extends number | bigint> = TagBase<{
|
|
28
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
29
|
+
kind: "maximum";
|
|
30
|
+
value: Value;
|
|
31
|
+
validate: `$input <= ${Cast<Value>}`;
|
|
32
|
+
exclusive: ["maximum", "exclusiveMaximum"];
|
|
33
|
+
schema: Value extends bigint ? {
|
|
34
|
+
maximum: Numeric<Value>;
|
|
35
|
+
} : {
|
|
36
|
+
maximum: Value;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
type Cast<Value extends number | bigint> = Value extends number ? Value : `BigInt(${Value})`;
|
|
40
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}` ? N : never;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Maximum.js","sourceRoot":"","sources":["../../src/tags/Maximum.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
/**
|
|
3
|
+
* Array minimum items constraint.
|
|
4
|
+
*
|
|
5
|
+
* `MinItems<N>` is a type tag that validates array values have at least the
|
|
6
|
+
* specified number of elements. Apply it to array properties using TypeScript
|
|
7
|
+
* intersection types.
|
|
8
|
+
*
|
|
9
|
+
* This constraint is commonly combined with {@link MaxItems} to define a valid
|
|
10
|
+
* size range. It can also be combined with {@link UniqueItems} to require unique
|
|
11
|
+
* elements.
|
|
12
|
+
*
|
|
13
|
+
* The constraint is enforced at runtime by `typia.is()`, `typia.assert()`, and
|
|
14
|
+
* `typia.validate()`. It generates `minItems` in JSON Schema output.
|
|
15
|
+
*
|
|
16
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
17
|
+
* @example
|
|
18
|
+
* interface Order {
|
|
19
|
+
* // Must have at least 1 item
|
|
20
|
+
* items: (Product & MinItems<1>)[];
|
|
21
|
+
* }
|
|
22
|
+
* interface Team {
|
|
23
|
+
* // Team must have 2-10 members
|
|
24
|
+
* members: (User & MinItems<2> & MaxItems<10>)[];
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @template Value Minimum number of elements required
|
|
28
|
+
*/
|
|
29
|
+
export type MinItems<Value extends number> = TagBase<{
|
|
30
|
+
target: "array";
|
|
31
|
+
kind: "minItems";
|
|
32
|
+
value: Value;
|
|
33
|
+
validate: `${Value} <= $input.length`;
|
|
34
|
+
exclusive: true;
|
|
35
|
+
schema: {
|
|
36
|
+
minItems: Value;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinItems.js","sourceRoot":"","sources":["../../src/tags/MinItems.ts"],"names":[],"mappings":""}
|