-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AJV Test Case #683
Comments
Hey @sinclairzx81! Does Also, I think some packages do use |
Hey @moltar, thanks for the quick response.
Ah I didn't see the criteria section. Thanks for linking that.
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 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 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! |
Yup yup, I am a fan of your work! :)
Yup, I tried it in #97 😁
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. |
Hi, great project!
Would it be possible to include AJV to this test suite? I think a case exists for testing AJV performance as it's possible for TypeScript to inference types from JSON schema directly via conditional type mapping. Would certainly be curious to see how the defacto JSON schema validator holds up against these libraries.
Many Thanks!
The text was updated successfully, but these errors were encountered: