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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
arktype | Code snippet | 2.2.0 | 896.39K | JIT | All errors | 91 μs | ||||
ata-validator | Code snippet | 0.13.2 | 750 | JIT | All errors | 738 ns | 122.61x | |||
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 | 194.21K | JIT | All errors | 8 μs | 11.53x | ||
sury (compile + safe) | Code snippet(Commented code is not benchmarked) | 11.0.0-alpha.4 | 194.21K | JIT | All errors | 8 μs | 11.92x | |||
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 | 194.21K | JIT | All errors | 8 μs | 11.96x | ||
sury (safe) | Code snippet | 11.0.0-alpha.4 | 194.21K | JIT | All errors | 8 μs | 11.46x | |||
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.38 | 1.75M | JIT | All errors | 94 μs | 1.04x | ||
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.38 | 1.75M | JIT | All errors | 87 μs | 1.04x | ||
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.38 | 1.75M | JIT | All errors | 80 μs | 1.13x | ||
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.38 | 1.75M | JIT | All errors | 85 μs | 1.07x | ||
typebox (script 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.38 | 1.75M | JIT | All errors | 90 μs | 1.01x | ||
zod | Code snippet | 4.4.3 | 165.11M | JIT | All errors | 63 μs | 1.43x | |||
zod/mini | Code snippet | 4.4.3 | 165.11M | JIT | All errors | 58 μs | 1.56x | |||