Skip to content

Commit adae322

Browse files
Shuunenjordan-boyer
authored andcommitted
feat: add Suretype validation library to the comparison
1 parent ad9a387 commit adae322

File tree

5 files changed

+360
-12
lines changed

5 files changed

+360
-12
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"cSpell.words": [
33
"arktype",
4+
"suretype",
5+
"Suretype",
46
"valibot"
57
],
68
"editor.quickSuggestions": {

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,27 @@ At the time of writing, Node 22 is around 2 times slower than Bun v1 ^^'
3030
Here are the library used in this comparison :
3131

3232
- [arktype](https://github.com/arktypeio/arktype) from David Blass
33+
- [suretype](https://github.com/grantila/suretype) from Gustaf Räntilä
3334
- [valibot](https://github.com/fabian-hiller/valibot) from Fabian Hiller
3435
- [zod](https://github.com/colinhacks/zod) from Colin McDonnell
3536
- [zod/mini](https://github.com/colinhacks/zod) from Colin McDonnell
3637

37-
| Date | Score | Library | Deps | Size | Light | Input A | Input B | Throw | Safe | Script exec | Lib exec | Fast | Readability |
38-
| ---------- | :---: | :-------: | :---: | :----: | :---: | :-----: | :-----: | :---: | :---: | :----------: | :---------: | :---: | :---------: |
39-
| 2025-04-13 | 2 | arktype | 2 | 147 KB | _0_ | **1** | **1** | _0_ | **1** | 875 ms _-1_ | 709 ms _-1_ | _0_ | **1** |
40-
| 2025-04-13 | 8 | valibot | **0** | 5 KB | **1** | **1** | **1** | **1** | **1** | 72 ms **1** | 10 ms **1** | **1** | _0_ |
41-
| 2025-04-13 | 4 | @zod/mini | 1 | 21 KB | **1** | **1** | _0_ | **1** | **1** | 218 ms _0_ | 131 ms _0_ | _0_ | _0_ |
42-
| 2025-04-13 | 8 | zod v3 | **0** | 60 KB | _0_ | **1** | **1** | **1** | **1** | 102 ms **1** | 35 ms **1** | **1** | **1** |
43-
| 2025-04-13 | 5 | zod v4 | 1 | 49 KB | _0_ | **1** | **1** | **1** | **1** | 225 ms _0_ | 144 ms _0_ | _0_ | **1** |
38+
| Date | Score | Library | Deps | Size | Light | Input A | Input B | Throw | Safe | Script exec | Lib exec | Fast | Readability |
39+
| ---------- | :---: | :-------: | :---: | :----: | :---: | :-----: | :-----: | :---: | :---: | :----------: | :----------: | :---: | :---------: |
40+
| 2025-04-27 | 2 | ArkType | 2 | 148 KB | _0_ | **1** | **1** | _0_ | **1** | 878 ms _-1_ | 715 ms _-1_ | _0_ | **1** |
41+
| 2025-04-27 | 1 | Suretype | 3 | 195 KB | _0_ | _0_ | _0_ | **1** | **1** | 2477 ms _-1_ | 2312 ms _-1_ | _0_ | **1** |
42+
| 2025-04-27 | 8 | Valibot | **0** | 6 KB | **1** | **1** | **1** | **1** | **1** | 69 ms **1** | 8 ms **1** | **1** | _0_ |
43+
| 2025-04-27 | 4 | @zod/mini | 1 | 22 KB | **1** | **1** | _0_ | **1** | **1** | 211 ms _0_ | 135 ms _0_ | _0_ | _0_ |
44+
| 2025-04-27 | 8 | Zod v3 | **0** | 60 KB | _0_ | **1** | **1** | **1** | **1** | 100 ms **1** | 32 ms **1** | **1** | **1** |
45+
| 2025-04-27 | 5 | Zod v4 | 1 | 49 KB | _0_ | **1** | **1** | **1** | **1** | 224 ms _0_ | 146 ms _0_ | _0_ | **1** |
4446

4547
Legend :
4648

4749
- Deps : the number of dependencies of the library
48-
- Size : the minified build size in bytes of the related file in `src`, run `bun run build` to see by yourself
50+
- Size : the minified build size in kilobytes of the related `.ts` file in `src`, run `bun run build` to see by yourself
4951
- Light : 1 point if the build is `<= 20 KB`
50-
- Input A : 1 point if the library can see that `age` is `optional, number` in the input but `not optional, number` in `type User` the output type
51-
- Input B : 1 point if the library can see that `phone` is `optional, string or number` in the input but `not optional, string` in `type User` the output type
52+
- Input A : 1 point if the library can see that `age` is `optional, number` in `type UserInput` but `not optional, number` in `type User` the output type
53+
- Input B : 1 point if the library can see that `phone` is `optional, string or number` in `type UserInput` but `not optional, string` in `type User` the output type
5254
- Throw : 1 point if the library have a parse or throw method, useful when we don't want to handle the error cases
5355
- Safe : 1 point if the library have a safe parse method that will not throw and usually return a `Result` type
5456
- Script exec : 1 point if the average time in ms to execute the test file with bun is `<= 100ms`, check the `bun run bench` command output

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dependencies": {
1515
"@zod/mini": "4.0.0-beta.20250412T085909",
1616
"arktype": "^2.1",
17+
"suretype": "^3.3",
1718
"valibot": "latest",
1819
"zod3": "npm:zod@^3.24.2",
1920
"zod4": "npm:[email protected]"
@@ -24,6 +25,7 @@
2425
"@tsconfig/strictest": "^2.0",
2526
"@types/bun": "latest",
2627
"repo-check": "^1.42",
28+
"shuutils": "^10.6",
2729
"typescript": "^5.8"
2830
},
2931
"files": [
@@ -46,15 +48,16 @@
4648
},
4749
"scripts": {
4850
"bench": "bun bench:bun --warmup 5 --runs 10",
49-
"bench:bun": "hyperfine 'bun src/arktype.ts' 'bun src/valibot.ts' 'bun src/zod-mini.ts' 'bun src/zod3.ts' 'bun src/zod4.ts'",
51+
"bench:bun": "hyperfine 'bun src/arktype.ts' 'bun src/suretype.ts' 'bun src/valibot.ts' 'bun src/zod-mini.ts' 'bun src/zod3.ts' 'bun src/zod4.ts'",
5052
"bench:node": "hyperfine --runs 10 'node dist/arktype.js' 'node dist/valibot.js' 'node dist/zod-mini.js' 'node dist/zod3.js' 'node dist/zod4.js'",
5153
"bench:node:strip": "hyperfine --runs 10 'node --experimental-strip-types src/arktype.ts' 'node --experimental-strip-types src/valibot.ts' 'node --experimental-strip-types src/zod-mini.ts' 'node --experimental-strip-types src/zod3.ts' 'node --experimental-strip-types src/zod4.ts'",
5254
"build": "bun scripts/build.ts && echo build success",
5355
"check": "pnpm i && bun check:tsc && bun check:biome && bun run build && bun check:once && echo check success",
5456
"check:biome": "biome check --error-on-warnings --write --unsafe src && echo check:biome success",
57+
"check:once": "bun src/arktype.ts && bun src/suretype.ts && bun src/valibot.ts && bun src/zod-mini.ts && bun src/zod3.ts && bun src/zod4.ts && echo check:once success",
5558
"check:repo": "repo-check && echo check:repo success",
5659
"check:tsc": "tsc --noEmit && echo check:tsc success"
5760
},
5861
"type": "module",
5962
"version": "1.0.0"
60-
}
63+
}

0 commit comments

Comments
 (0)