Parsing a value to match the schema. This is different to validation because it returns a new value.
Copy to clipboardimport * as v from "valibot"; import { personSchema } from "./schemas"; const person = v.parse(personSchema, data); // person is of type Person
| Library | Version | /wk | Optimizations | Error type | Mean | Compare | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@paseri/compiler (safeParse) | Code snippet | 0.7.7 | 123 | Precompiled | All errors | 1 μs | ||||
@paseri/compiler (parse) | Code snippet | Throws on invalid dataThis library throws an error when parsing invalid data (and has no non-throwing equivalent), so the benchmark includes a try/catch. | 0.7.7 | 123 | Precompiled | All errors | 8 μs | 5.74x | ||
zod-compiler (compact) | Code snippet | 1.27.0 | 31.11K | Precompiled | All errors | 12 μs | 8.23x | |||
zod-compiler | Code snippet | 1.27.0 | 31.11K | Precompiled | All errors | 16 μs | 11.1x | |||
zod-compiler (bag) | Code snippet | 1.27.0 | 31.11K | Precompiled | All errors | 17 μs | 11.29x | |||
typia (createValidate) | Code snippet(Commented code is not benchmarked) | 14.0.0 | 271.05K | Precompiled | All errors | 17 μs | 11.65x | |||
typia (validate) | Code snippet | 14.0.0 | 271.05K | Precompiled | All errors | 18 μs | 12.32x | |||