diff --git a/cases/rescript-schema.ts b/cases/rescript-schema.ts index 928eab6ba..03bc1ad68 100644 --- a/cases/rescript-schema.ts +++ b/cases/rescript-schema.ts @@ -2,65 +2,50 @@ import * as S from 'rescript-schema'; import { createCase } from '../benchmarks'; -const makeSchema = () => - S.object({ - number: S.number, - negNumber: S.number, - maxNumber: S.number, - string: S.string, - longString: S.string, - boolean: S.boolean, - deeplyNested: S.object({ - foo: S.string, - num: S.number, - bool: S.boolean, - }), - }); +S.setGlobalConfig({ + disableNanNumberValidation: true, +}); -createCase('rescript-schema', 'parseSafe', () => { - S.setGlobalConfig({ - disableNanNumberCheck: true, - }); - const schema = makeSchema(); +const schema = S.schema({ + number: S.number, + negNumber: S.number, + maxNumber: S.number, + string: S.string, + longString: S.string, + boolean: S.boolean, + deeplyNested: { + foo: S.string, + num: S.number, + bool: S.boolean, + }, +}); +createCase('rescript-schema', 'parseSafe', () => { + const parseSafe = S.compile(schema, 'Any', 'Output', 'Sync'); return data => { - return schema.parseOrThrow(data); + return parseSafe(data); }; }); createCase('rescript-schema', 'parseStrict', () => { - S.setGlobalConfig({ - disableNanNumberCheck: true, - defaultUnknownKeys: 'Strict', - }); - const schema = makeSchema(); - + const parseStrict = S.compile(S.deepStrict(schema), 'Any', 'Output', 'Sync'); return data => { - return schema.parseOrThrow(data); + return parseStrict(data); }; }); createCase('rescript-schema', 'assertLoose', () => { - S.setGlobalConfig({ - disableNanNumberCheck: true, - }); - const schema = makeSchema(); - + const assertLoose = S.compile(schema, 'Any', 'Assert', 'Sync'); return data => { - schema.assert(data)!; + assertLoose(data)!; return true; }; }); createCase('rescript-schema', 'assertStrict', () => { - S.setGlobalConfig({ - disableNanNumberCheck: true, - defaultUnknownKeys: 'Strict', - }); - const schema = makeSchema(); - + const assertStrict = S.compile(S.deepStrict(schema), 'Any', 'Assert', 'Sync'); return data => { - schema.assert(data)!; + assertStrict(data)!; return true; }; }); diff --git a/package-lock.json b/package-lock.json index 5391ee252..deb0369c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ "r-assign": "1.9.0", "reflect-metadata": "0.2.2", "rescript": "11.1.4", - "rescript-schema": "8.4.0", + "rescript-schema": "9.0.0", "rulr": "10.5.0", "runtypes": "6.7.0", "serve": "14.2.4", @@ -9334,9 +9334,9 @@ } }, "node_modules/rescript-schema": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/rescript-schema/-/rescript-schema-8.4.0.tgz", - "integrity": "sha512-X39lDpAXv0T5Jeux9GU6VCs6lpjVMn6kNKrm1lXqE4d1fmfhq+YYbf4emkIZSZxcEZOBFgNBdsFg14UuW1n4CA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/rescript-schema/-/rescript-schema-9.0.0.tgz", + "integrity": "sha512-JLZmA04dfd16In03vEwI/cbQyq02uyoKWWHVZctzdOzRzGJpNJLgGZto32rRfQcxEsTU1CdsXi4gH6zJ/uOBqw==", "license": "MIT", "peerDependencies": { "rescript": "11.x" @@ -18122,9 +18122,9 @@ "integrity": "sha512-0bGU0bocihjSC6MsE3TMjHjY0EUpchyrREquLS8VsZ3ohSMD+VHUEwimEfB3kpBI1vYkw3UFZ3WD8R28guz/Vw==" }, "rescript-schema": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/rescript-schema/-/rescript-schema-8.4.0.tgz", - "integrity": "sha512-X39lDpAXv0T5Jeux9GU6VCs6lpjVMn6kNKrm1lXqE4d1fmfhq+YYbf4emkIZSZxcEZOBFgNBdsFg14UuW1n4CA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/rescript-schema/-/rescript-schema-9.0.0.tgz", + "integrity": "sha512-JLZmA04dfd16In03vEwI/cbQyq02uyoKWWHVZctzdOzRzGJpNJLgGZto32rRfQcxEsTU1CdsXi4gH6zJ/uOBqw==", "requires": {} }, "resolve": { diff --git a/package.json b/package.json index 86e6cbb1c..a3c7372d0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "compile:typia": "rimraf cases/typia/build && tsc -p cases/typia/tsconfig.json", "compile:ts-auto-guard": "rimraf cases/ts-auto-guard/build && ts-auto-guard --project cases/ts-auto-guard/tsconfig.json && tsc -p cases/ts-auto-guard/tsconfig.json", "prepare": "ts-patch install", - "download-packages-popularity": "ts-node download-packages-popularity.ts" + "download-packages-popularity": "ts-node download-packages-popularity.ts" }, "dependencies": { "@aeriajs/validation": "0.0.141", @@ -70,7 +70,7 @@ "r-assign": "1.9.0", "reflect-metadata": "0.2.2", "rescript": "11.1.4", - "rescript-schema": "8.4.0", + "rescript-schema": "9.0.0", "rulr": "10.5.0", "runtypes": "6.7.0", "serve": "14.2.4",