Parsing a value to match the schema. This is different to validation because it returns a new value.
import * 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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
valibot | Code snippet | 1.2.0 | 5.6M | None | Abort early | 745 ns | ||||
joi | Code snippet | 18.0.2 | 16M | None | Abort early | 4 μs | 5.24x | |||
typia (createValidate) | Code snippet(Commented code is not benchmarked) | 11.0.3 | 237K | Precompiled | All errors | 7 μs | 8.95x | |||
typia (validate) | Code snippet | 11.0.3 | 237K | Precompiled | All errors | 7 μs | 9.29x | |||
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 | 66K | JIT | All errors | 8 μs | 10.4x | ||
sury (compile + safe) | Code snippet(Commented code is not benchmarked) | 11.0.0-alpha.4 | 66K | JIT | All errors | 8 μs | 10.7x | |||
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 | 66K | JIT | All errors | 8 μs | 10.99x | ||
sury (safe) | Code snippet | 11.0.0-alpha.4 | 66K | JIT | All errors | 8 μs | 11.24x | |||
effect | Code snippet(Commented code is not benchmarked) | 3.19.17 | 7.1M | None | Abort early | 9 μs | 12.27x | |||
valibot (abortPipeEarly only) | Code snippet | 1.2.0 | 5.6M | None | Abort early | 28 μs | 38.03x | |||
valibot | Code snippet | 1.2.0 | 5.6M | None | All errors | 28 μs | 38.13x | |||
effect | Code snippet(Commented code is not benchmarked) | 3.19.17 | 7.1M | None | All errors | 44 μs | 59.49x | |||
joi | Code snippet | 18.0.2 | 16M | None | All errors | 59 μs | 79.09x | |||
zod/mini | Code snippet | 4.3.6 | 85M | JIT | All errors | 84 μs | 112.57x | |||
zod/mini (jitless) | Code snippet | 4.3.6 | 85M | None | All errors | 86 μs | 115.38x | |||
zod (jitless) | Code snippet | 4.3.6 | 85M | None | All errors | 90 μs | 120.46x | |||
zod | Code snippet | 4.3.6 | 85M | JIT | All errors | 92 μs | 123.1x | |||
yup | 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.7.1 | 9.3M | None | Abort early | 92 μs | 124.07x | ||
arktype | Code snippet | 2.1.29 | 694K | JIT | All errors | 98 μs | 131.45x | |||
rod-js (eager) | Code snippet | 0.2.1 | 38 | None | All errors | 121 μs | 162.62x | |||
rod-js (lazy) | Code snippet | 0.2.1 | 38 | None | All errors | 128 μs | 171.39x | |||
@vinejs/vine | Code snippet | 4.3.0 | 136K | JIT | Abort early | 204 μs | 273.84x | |||
@vinejs/vine | Code snippet | 4.3.0 | 136K | JIT | All errors | 208 μs | 279.53x | |||
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.0.81 | 166K | JIT | All errors | 282 μs | 379.16x | ||
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.0.81 | 166K | None | All errors | 295 μs | 396.66x | ||
yup | 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.7.1 | 9.3M | None | All errors | 517 μs | 693.71x | ||