From 8a6af5982238974bd7058f5168e95921f7345228 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 29 Nov 2022 16:16:27 +0900 Subject: [PATCH] Fixing #351 - stop using TS 4.9 for a while --- package.json | 5 ++++- src/programmers/internal/application_number.ts | 4 ++++ src/schemas/IJsonSchema.ts | 1 + .../application/ajv/test_application_ajv_TagStep.ts | 1 + .../application/ajv/test_application_ajv_UltimateUnion.ts | 5 +++++ test/features/application/replace.js | 6 +++++- .../application/swagger/test_application_swagger_TagStep.ts | 1 + .../swagger/test_application_swagger_UltimateUnion.ts | 5 +++++ 8 files changed, 26 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba7fcdfaa5..288315a74b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "3.3.39", + "version": "3.3.40", "description": "Runtime type checkers and 5x faster JSON.stringify() function", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -52,6 +52,9 @@ "url": "https://github.com/samchon/typescript-json/issues" }, "homepage": "https://github.com/samchon/typescript-json#readme", + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x" + }, "devDependencies": { "@fastify/type-provider-typebox": "^2.3.0", "@trivago/prettier-plugin-sort-imports": "^3.3.0", diff --git a/src/programmers/internal/application_number.ts b/src/programmers/internal/application_number.ts index c2766f4f44..b66bba8a32 100644 --- a/src/programmers/internal/application_number.ts +++ b/src/programmers/internal/application_number.ts @@ -33,6 +33,8 @@ export const application_number = ( output.maximum = tag.maximum.value; else output.exclusiveMaximum = tag.maximum.value; } + // MULTIPLE-OF + else if (tag.kind === "multipleOf") output.multipleOf = tag.value; } // WHEN UNSIGNED INT @@ -64,6 +66,8 @@ export const application_number = ( conditions.push(value > output.exclusiveMinimum); if (output.exclusiveMaximum !== undefined) conditions.push(value < output.exclusiveMaximum); + if (output.multipleOf !== undefined) + conditions.push(value % output.multipleOf === 0); return conditions.every((cond) => cond); })((str) => Number(str)); diff --git a/src/schemas/IJsonSchema.ts b/src/schemas/IJsonSchema.ts index 88097b46d0..f8cba6badc 100644 --- a/src/schemas/IJsonSchema.ts +++ b/src/schemas/IJsonSchema.ts @@ -43,6 +43,7 @@ export namespace IJsonSchema { maximum?: number; exclusiveMinimum?: number; exclusiveMaximum?: number; + multipleOf?: number; } export interface IBoolean extends IAtomic<"boolean"> {} export interface IBigInt extends IAtomic<"bigint"> {} diff --git a/test/features/application/ajv/test_application_ajv_TagStep.ts b/test/features/application/ajv/test_application_ajv_TagStep.ts index 9862cffd37..365a0f079e 100644 --- a/test/features/application/ajv/test_application_ajv_TagStep.ts +++ b/test/features/application/ajv/test_application_ajv_TagStep.ts @@ -157,6 +157,7 @@ export const test_application_ajv_TagStep = _test_application("ajv")( }, ], "x-tson-required": true, + multipleOf: 5, }, }, nullable: false, diff --git a/test/features/application/ajv/test_application_ajv_UltimateUnion.ts b/test/features/application/ajv/test_application_ajv_UltimateUnion.ts index 518fdde1b9..4f722f9da0 100644 --- a/test/features/application/ajv/test_application_ajv_UltimateUnion.ts +++ b/test/features/application/ajv/test_application_ajv_UltimateUnion.ts @@ -1214,6 +1214,11 @@ export const test_application_ajv_UltimateUnion = _test_application("ajv")( nullable: false, "x-tson-required": false, }, + multipleOf: { + type: "number", + nullable: false, + "x-tson-required": false, + }, default: { type: "number", nullable: false, diff --git a/test/features/application/replace.js b/test/features/application/replace.js index 4ae8a20ca9..da4067e800 100644 --- a/test/features/application/replace.js +++ b/test/features/application/replace.js @@ -15,7 +15,11 @@ function replace(type, file, schema) { const newContent = content.substring(0, first) + symbol + schema + "\n" + ");"; - fs.writeFileSync(file, newContent, "utf8"); + fs.writeFileSync( + file, + newContent.split("\r\n").join("\n"), + "utf8" + ); } function iterate(type) { diff --git a/test/features/application/swagger/test_application_swagger_TagStep.ts b/test/features/application/swagger/test_application_swagger_TagStep.ts index 50d82d4d45..d53a794a2b 100644 --- a/test/features/application/swagger/test_application_swagger_TagStep.ts +++ b/test/features/application/swagger/test_application_swagger_TagStep.ts @@ -156,6 +156,7 @@ export const test_application_swagger_TagStep = _test_application("swagger")( }, ], "x-tson-required": true, + multipleOf: 5, }, }, nullable: false, diff --git a/test/features/application/swagger/test_application_swagger_UltimateUnion.ts b/test/features/application/swagger/test_application_swagger_UltimateUnion.ts index 327e43b65c..0502779408 100644 --- a/test/features/application/swagger/test_application_swagger_UltimateUnion.ts +++ b/test/features/application/swagger/test_application_swagger_UltimateUnion.ts @@ -1184,6 +1184,11 @@ export const test_application_swagger_UltimateUnion = _test_application( nullable: false, "x-tson-required": false, }, + multipleOf: { + type: "number", + nullable: false, + "x-tson-required": false, + }, default: { type: "number", nullable: false,