diff --git a/README.md b/README.md index eafa8c7d6..e83f062c6 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/cases/caketype.ts b/cases/caketype.ts new file mode 100644 index 000000000..b6767e4f5 --- /dev/null +++ b/cases/caketype.ts @@ -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(); +}); diff --git a/cases/index.ts b/cases/index.ts index 245f00ed6..362f4aa9e 100644 --- a/cases/index.ts +++ b/cases/index.ts @@ -2,6 +2,7 @@ export const cases = [ 'ajv', 'arktype', 'bueno', + 'caketype', 'class-validator', 'computed-types', 'decoders', diff --git a/package-lock.json b/package-lock.json index 5fe2deb9f..df98d9417 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,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", @@ -4328,6 +4329,12 @@ "node": ">= 0.8" } }, + "node_modules/caketype": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/caketype/-/caketype-0.5.0.tgz", + "integrity": "sha512-RXb+W/PttNXH3TdYLIrNwvRnyPignAwjwIoLbE19ZmyQaDN7lMbaZMlchUtkr6sjDbpy+Tl0lsTcAjYwtZA3Vw==", + "license": "MIT" + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -14365,6 +14372,11 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" }, + "caketype": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/caketype/-/caketype-0.5.0.tgz", + "integrity": "sha512-RXb+W/PttNXH3TdYLIrNwvRnyPignAwjwIoLbE19ZmyQaDN7lMbaZMlchUtkr6sjDbpy+Tl0lsTcAjYwtZA3Vw==" + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", diff --git a/package.json b/package.json index ffe1c661c..214cdf091 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/benchmarks.test.ts b/test/benchmarks.test.ts index 3f2f1b206..3701092c7 100644 --- a/test/benchmarks.test.ts +++ b/test/benchmarks.test.ts @@ -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';