Skip to content

Commit

Permalink
Add caketype (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGL authored Oct 22, 2024
1 parent 64ae1a3 commit 724400b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [ajv](https://ajv.js.org/)
* [ArkType](https://github.com/arktypeio/arktype)
* [bueno](https://github.com/philipnilsson/bueno)
* [caketype](https://github.com/justinyaodu/caketype)
* [class-validator](https://github.com/typestack/class-validator) + [class-transformer](https://github.com/typestack/class-transformer)
* [computed-types](https://github.com/neuledge/computed-types)
* [decoders](https://github.com/nvie/decoders)
Expand Down
39 changes: 39 additions & 0 deletions cases/caketype.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { bake, boolean, number, string } from 'caketype';
import { createCase } from '../benchmarks';

const cake = bake({
number: number,
negNumber: number,
maxNumber: number,
string: string,
longString: string,
boolean: boolean,
deeplyNested: {
foo: string,
num: number,
bool: boolean,
},
});

// Safe parsing is not supported because extra keys are not removed from the input.

createCase('caketype', 'parseStrict', () => data => {
if (cake.is(data)) {
return data;
}
throw new Error();
});

createCase('caketype', 'assertLoose', () => data => {
if (cake.isShape(data)) {
return true;
}
throw new Error();
});

createCase('caketype', 'assertStrict', () => data => {
if (cake.is(data)) {
return true;
}
throw new Error();
});
1 change: 1 addition & 0 deletions cases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const cases = [
'ajv',
'arktype',
'bueno',
'caketype',
'class-validator',
'computed-types',
'decoders',
Expand Down
12 changes: 12 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 @@ -44,6 +44,7 @@
"arktype": "2.0.0-dev.12-cjs",
"benny": "3.7.1",
"bueno": "0.1.5",
"caketype": "0.5.0",
"class-transformer": "0.5.1",
"class-transformer-validator": "0.9.1",
"class-validator": "0.14.1",
Expand Down
1 change: 1 addition & 0 deletions test/benchmarks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cases } from '../cases';
import '../cases/ajv';
import '../cases/arktype';
import '../cases/bueno';
import '../cases/caketype';
import '../cases/class-validator';
import '../cases/computed-types';
import '../cases/decoders';
Expand Down

0 comments on commit 724400b

Please sign in to comment.