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 | Downloads (/wk) | Optimizations | Error type | Mean | Compare | ||||
|---|---|---|---|---|---|---|---|---|---|---|
ata-validator | Code snippet | 0.8.0 | 728 | JIT | All errors | 682 ns | ||||
sury (compile) | Code snippet(Commented code is not benchmarked) | 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. | 11.0.0-alpha.4 | 146.04K | JIT | All errors | 7 μs | 10.79x | ||
sury (compile + safe) | Code snippet(Commented code is not benchmarked) | 11.0.0-alpha.4 | 146.04K | JIT | All errors | 8 μs | 11.28x | |||
sury (safe) | Code snippet | 11.0.0-alpha.4 | 146.04K | JIT | All errors | 8 μs | 11.48x | |||
sury | 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. | 11.0.0-alpha.4 | 146.04K | JIT | All errors | 8 μs | 11.53x | ||
zod/mini | Code snippet | 4.3.6 | 151.14M | JIT | All errors | 64 μs | 93.4x | |||
zod | Code snippet | 4.3.6 | 151.14M | JIT | All errors | 73 μs | 107.52x | |||
typebox (schema compile) | Code snippet(Commented code is not benchmarked) | 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. | 1.1.23 | 277.92K | JIT | All errors | 76 μs | 111.86x | ||
typebox (schema) | 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. | 1.1.23 | 277.92K | JIT | All errors | 80 μs | 117.33x | ||
typebox (compile) | Code snippet(Commented code is not benchmarked) | 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. | 1.1.23 | 277.92K | JIT | All errors | 82 μs | 120.81x | ||
typebox | 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. | 1.1.23 | 277.92K | JIT | All errors | 88 μs | 128.93x | ||
arktype | Code snippet | 2.2.0 | 885.45K | JIT | All errors | 91 μs | 132.98x | |||