Comments (4)
@moltar Hey, awesome, that would be great ! :)
Will keep an eye out for #497, I'm very curious to see how the AJV validation stacks up against specialized TS type validation.
Many Many Thanks!
S
from typescript-runtime-type-benchmarks.
Just for a bit of context. I actually manage this project https://github.com/sinclairzx81/typebox that implements the JSON schema specification but doesn't actually implement any runtime validation logic.
Yup yup, I am a fan of your work! :)
TypeBox doesn't currently meet either criteria for benchmarking as it offers no validation function
Yup, I tried it in #97 😁
It's an interesting one. In all, I do think a pure Ajv test would give a good indication of how standard JSON validation holds up against libraries who chose to implement internal custom validation logic.
I kinda agree and maybe we'll relax the criteria a bit after we finish #497 which opens up the possibility for different groups of tests.
from typescript-runtime-type-benchmarks.
Hey @sinclairzx81!
Does ajv
fit into the criteria outlined here? https://github.com/moltar/typescript-runtime-type-benchmarks#criteria
Also, I think some packages do use ajv
internally. You can see which ones by doing npm ls ajv
in the repo.
from typescript-runtime-type-benchmarks.
Hey @moltar, thanks for the quick response.
Does ajv fit into the criteria outlined here? https://github.com/moltar/typescript-runtime-type-benchmarks#criteria
Ah I didn't see the criteria section. Thanks for linking that.
- These packages are capable of validating the data for type correctness (Yes)
- It has a validator function or method that returns a valid type casted value or throws. (Not directly)
I guess on the second point, Ajv doesn't quite meet the criteria, but it is very close. The following 4 line function would be enough for Ajv to fit the criteria.
// The following deserializes the given string and returns T if matching the given schema, otherwise throw.
function deserialize<T = unknown>(schema: any, data: string): T {
const ajv = new Ajv();
const obj = JSON.parse(data)
if(!ajv.validate(schema, obj)) throw
return obj
}
Just for a bit of context. I actually manage this project https://github.com/sinclairzx81/typebox that implements the JSON schema specification but doesn't actually implement any runtime validation logic. Conceptually, the library is similar to io-ts
, zod
and runtypes
(where it implements static inference) but whose runtime performance is measured by that of the underlying JSON schema validator.
TypeBox doesn't currently meet either criteria for benchmarking as it offers no validation function, and requires a JSON schema validator of the users choosing to runtime type check. It's an outlier because it's conceptually serving the same role as io-ts
, zod
and runtypes
but whose performance is tied to that of the JSON schema validator. So the only way to benchmark TypeBox would be to benchmark JSON schema validators. I expect this would be true for other test cases dependent on Ajv.
It's an interesting one. In all, I do think a pure Ajv test would give a good indication of how standard JSON validation holds up against libraries who chose to implement internal custom validation logic.
Open to your thoughts!
Cheers
S
from typescript-runtime-type-benchmarks.
Related Issues (20)
- How do I add a testcase (Request: Documentation on that) HOT 5
- Add `@Typia` HOT 3
- Suggest: add a table whether each type can be validated or not HOT 3
- Add `caketype`
- Add `@fp-ts/schema`
- Add `@gapstack/light-type` HOT 4
- Add `arktypeio/arktype` HOT 2
- Node 20 HOT 2
- Preview SVG image has been broken HOT 8
- Show operations/s as a number for each benchmark HOT 3
- Show weekly npm downloads for each package HOT 2
- Add `valibot`
- Include failing data in the benchmarks HOT 5
- ParseSafe for Zod calls parse() not safeParse() HOT 1
- Categories for AOT, JIT and Dynamic Validation HOT 5
- I don't really quite understand the categories... HOT 2
- Add Effect-TS schema
- ahead-of-time clarification HOT 3
- isolate benchmarked module dependencies HOT 1
- [Enchanchament] add Bun runtime in benchmark HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-runtime-type-benchmarks.