Skip to content

Commit

Permalink
Change MetadataAtomic.toJSON() policy to allow bigint type's `tag…
Browse files Browse the repository at this point in the history
…` property.
  • Loading branch information
samchon committed Aug 11, 2024
1 parent 2b69ce4 commit 651de83
Show file tree
Hide file tree
Showing 22 changed files with 193 additions and 48 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.8.0-dev.20240811.tgz"
"typia": "../typia-6.8.0-dev.20240811-2.tgz"
}
}
19 changes: 19 additions & 0 deletions debug/src/bigint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import typia, { IJsonApplication, tags } from "typia";

import { IMetadataApplication } from "typia/lib/schemas/metadata/IMetadataApplication";
import { MetadataApplication } from "typia/lib/schemas/metadata/MetadataApplication";

import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer";

const raw: IMetadataApplication =
typia.reflect.metadata<
[
bigint & tags.Minimum<0n> & tags.Maximum<100n> & tags.MultipleOf<5n>,
bigint & tags.ExclusiveMinimum<0n> & tags.ExclusiveMaximum<100n>,
]
>();
const app: MetadataApplication = MetadataApplication.from(raw);
const json: IJsonApplication = JsonApplicationProgrammer.write("3.1")(
app.metadatas,
) as IJsonApplication;
console.log(json.schemas);
7 changes: 0 additions & 7 deletions debug/src/prune.ts

This file was deleted.

2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.8.0-dev.20240811.tgz"
"typia": "../typia-6.8.0-dev.20240811-2.tgz"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "6.8.0-dev.20240811",
"version": "6.8.0-dev.20240811-2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "6.8.0-dev.20240811",
"version": "6.8.0-dev.20240811-2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "6.8.0-dev.20240811"
"typia": "6.8.0-dev.20240811-2"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.6.0"
Expand Down
3 changes: 1 addition & 2 deletions src/programmers/internal/application_v30_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export const application_v30_schema =
else insert(application_v30_constant(constant));
for (const a of meta.atomics)
if (a.type === "boolean") application_boolean(a).forEach(insert);
else if (a.type === "bigint")
application_bigint(a).forEach(insert as any);
else if (a.type === "bigint") application_bigint(a).forEach(insert);
else if (a.type === "number") application_number(a).forEach(insert);
else if (a.type === "string") application_string(a).forEach(insert);

Expand Down
2 changes: 1 addition & 1 deletion src/schemas/metadata/MetadataAtomic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class MetadataAtomic {
: tag.value,
validate: tag.validate,
exclusive: tag.exclusive,
schema: this.type !== "bigint" ? tag.schema : undefined,
schema: tag.schema,
})),
),
};
Expand Down
2 changes: 1 addition & 1 deletion test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"typia": "../typia-6.8.0-dev.20240811.tgz"
"typia": "../typia-6.8.0-dev.20240811-2.tgz"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.8.0-dev.20240811.tgz"
"typia": "../typia-6.8.0-dev.20240811-2.tgz"
}
}
10 changes: 8 additions & 2 deletions test/schemas/reflect/metadata/ArraySimpleProtobuf.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@
"kind": "type",
"value": "int64",
"validate": "true",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down Expand Up @@ -784,7 +787,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
10 changes: 8 additions & 2 deletions test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@
"kind": "type",
"value": "int64",
"validate": "true",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down Expand Up @@ -784,7 +787,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
10 changes: 8 additions & 2 deletions test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@
"kind": "type",
"value": "int64",
"validate": "true",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down Expand Up @@ -784,7 +787,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
5 changes: 4 additions & 1 deletion test/schemas/reflect/metadata/DynamicTag.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
5 changes: 4 additions & 1 deletion test/schemas/reflect/metadata/ObjectHttpTypeTag.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
5 changes: 4 additions & 1 deletion test/schemas/reflect/metadata/ObjectSimpleProtobuf.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@
"kind": "type",
"value": "uint64",
"validate": "BigInt(0) <= $input",
"exclusive": true
"exclusive": true,
"schema": {
"type": "integer"
}
}
]
]
Expand Down
25 changes: 20 additions & 5 deletions test/schemas/reflect/metadata/TypeTagBigInt.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@
"exclusive": [
"minimum",
"exclusiveMinimum"
]
],
"schema": {
"minimum": 0
}
},
{
"target": "bigint",
Expand All @@ -149,7 +152,10 @@
"exclusive": [
"maximum",
"exclusiveMaximum"
]
],
"schema": {
"maximum": 100
}
}
]
]
Expand Down Expand Up @@ -222,7 +228,10 @@
"exclusive": [
"minimum",
"exclusiveMinimum"
]
],
"schema": {
"minimum": 0
}
}
]
]
Expand Down Expand Up @@ -295,7 +304,10 @@
"exclusive": [
"maximum",
"exclusiveMaximum"
]
],
"schema": {
"maximum": 100
}
}
]
]
Expand Down Expand Up @@ -365,7 +377,10 @@
"value": "3"
},
"validate": "$input % BigInt(3) === BigInt(0)",
"exclusive": true
"exclusive": true,
"schema": {
"multipleOf": 3
}
}
]
]
Expand Down
Loading

0 comments on commit 651de83

Please sign in to comment.