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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* [deepkit](https://deepkit.io/)
* [@effect/schema](https://github.com/Effect-TS/effect/blob/main/packages/schema/README.md)
* [io-ts](https://github.com/gcanti/io-ts)
* [jet-schema](https://github.com/seanpmaxwell/jet-schema)
* [jet-validators](https://github.com/seanpmaxwell/jet-validators)
* [joi] (https://github.com/hapijs/joi)
* [jointz](https://github.com/moodysalem/jointz)
* [json-decoder](https://github.com/venil7/json-decoder)
Expand Down
4 changes: 2 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"decoders": "1.25.5",
"fp-ts": "2.16.9",
"io-ts": "2.2.22",
"jet-schema": "1.4.3",
"jet-validators": "1.4.3",
"joi": "17.13.3",
"jointz": "7.0.4",
"json-decoder": "1.4.1",
Expand Down Expand Up @@ -1039,7 +1039,7 @@

"jackspeak": ["jackspeak@4.1.0", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" } }, "sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw=="],

"jet-schema": ["jet-schema@1.4.3", "", {}, "sha512-BDA5Z8Kkk1SppmV9KOuTwY3OExHGt37tTZumsoKwNfp+0XXsEXPfk9oZfVqM7na0EUsMB/zcvsjQBU7Qu6YQ0A=="],
"jet-validators": ["jet-validators@1.4.3", "", {}, "sha512-BDA5Z8Kkk1SppmV9KOuTwY3OExHGt37tTZumsoKwNfp+0XXsEXPfk9oZfVqM7na0EUsMB/zcvsjQBU7Qu6YQ0A=="],

"joi": ["joi@17.13.3", "", { "dependencies": { "@hapi/hoek": "^9.3.0", "@hapi/topo": "^5.1.0", "@sideway/address": "^4.1.5", "@sideway/formula": "^3.0.1", "@sideway/pinpoint": "^2.0.0" } }, "sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA=="],

Expand Down
2 changes: 1 addition & 1 deletion cases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const cases = [
'effect-schema',
'ts-auto-guard',
'type-predicate-generator',
'jet-schema',
'jet-validators',
] as const;

export type CaseName = (typeof cases)[number];
Expand Down
110 changes: 0 additions & 110 deletions cases/jet-schema.ts

This file was deleted.

99 changes: 99 additions & 0 deletions cases/jet-validators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { isString, isNumber, isBoolean } from 'jet-validators';

import {
parseObject,
testObject,
looseTestObject,
strictParseObject,
strictTestObject,
} from 'jet-validators/utils';

import { createCase } from '../benchmarks';

// **** Init Schema **** //

const safeParse = parseObject({
number: isNumber,
negNumber: isNumber,
maxNumber: isNumber,
string: isString,
longString: isString,
boolean: isBoolean,
deeplyNested: testObject({
foo: isString,
num: isNumber,
bool: isBoolean,
}),
});

const looseTest = looseTestObject({
number: isNumber,
negNumber: isNumber,
maxNumber: isNumber,
string: isString,
longString: isString,
boolean: isBoolean,
deeplyNested: looseTestObject({
foo: isString,
num: isNumber,
bool: isBoolean,
}),
});

const strictParse = strictParseObject({
number: isNumber,
negNumber: isNumber,
maxNumber: isNumber,
string: isString,
longString: isString,
boolean: isBoolean,
deeplyNested: strictTestObject({
foo: isString,
num: isNumber,
bool: isBoolean,
}),
});

const strictTest = strictTestObject({
number: isNumber,
negNumber: isNumber,
maxNumber: isNumber,
string: isString,
longString: isString,
boolean: isBoolean,
deeplyNested: strictTestObject({
foo: isString,
num: isNumber,
bool: isBoolean,
}),
});

const checkFailed = (arg: unknown) => {
if (arg === false) {
throw new Error('Validation failed');
} else {
return arg;
}
};

// **** Run Tests **** //

// Parse "safe"
createCase('jet-validators', 'parseSafe', () => {
return data => checkFailed(safeParse(data));
});

// Parse "strict"
createCase('jet-validators', 'parseStrict', () => {
return data => checkFailed(strictParse(data));
});

// Test "loose"
createCase('jet-validators', 'assertLoose', () => {
return data => checkFailed(looseTest(data));
});

// Test "strict"
createCase('jet-validators', 'assertStrict', () => {
return data => checkFailed(strictTest(data));
});
11 changes: 11 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"fp-ts": "2.16.9",
"io-ts": "2.2.22",
"jet-schema": "1.4.3",
"jet-validators": "1.3.7",
"joi": "17.13.3",
"jointz": "7.0.4",
"json-decoder": "1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion test/benchmarks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import '../cases/effect-schema';
import '../cases/ts-auto-guard';
import '../cases/type-predicate-generator';
import '../cases/tiny-schema-validator';
import '../cases/jet-schema';
import '../cases/jet-validators';

test('all cases must have been imported in tests', () => {
expect(
Expand Down