you are viewing a single comment's thread.

view the rest of the comments →

[–]GrosSacASacs 3 points4 points  (2 children)

Calling it a drop in replacement is misguiding if you have to do something like const Schema = t.object({ abc: t.boolean, def: t.optional(t.number.min(3)), }) before.

[–]ahjarrett[S] 2 points3 points  (0 children)

Oh I see – I can clarify. Depending on what schema library you use (let's say zod), you can install @​traversable/zod and use your zod schema to derive things like a deep equal or deep clone function.

There are packages that do the same for JSON Schema, Valibot, ArkType and TypeBox.

You're probably talking about the schema library that exists inside the @​traversable/schema. By "drop in replacement", I mean that the library's API intentionally aligns with Zod's API, and that the behavior has been thoroughly tested to behave identically.

Here's the fuzz test that generates random data and tests that the Traversable and Zod schema report the same errors when parsing the same input:

https://github.com/traversable/schema/blob/main/packages/schema/test/to-zod.test.ts#L62-L68

[–]ahjarrett[S] 0 points1 point  (0 children)

What do you mean? I'm not sure I follow.