Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 25 additions & 40 deletions cases/rescript-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
});
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.140",
Expand Down Expand Up @@ -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",
Expand Down
Loading