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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@railway-ts/pipelines | Code snippet | 0.1.29 | 123 | None | Abort early | 649 ns | ||||
valibot | Code snippet | 1.4.2 | 14.88M | None | Abort early | 743 ns | 1.15x | |||
effect@beta | Code snippet(Commented code is not benchmarked) | 4.0.0-beta.101 | 24.3M | None | Abort early | 1 μs | 1.98x | |||
joi | Code snippet | 18.2.3 | 20.46M | None | Abort early | 4 μs | 6.08x | |||
effect | Code snippet(Commented code is not benchmarked) | 3.22.0 | 24.3M | None | Abort early | 10 μs | 15.95x | |||
superstruct | Code snippet | 2.0.2 | 5.02M | None | Abort early | 11 μs | 16.92x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | 5.02M | None | Abort early | 11 μs | 17.4x | |||
valibot (abortPipeEarly only) | Code snippet | 1.4.2 | 14.88M | None | Abort early | 30 μs | 45.99x | |||
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 | 10.52M | None | Abort early | 101 μs | 155.19x | ||
runtypes | Code snippet | 7.0.5 | 190.07K | None | Abort early | 183 μs | 281.64x | |||
runtypes | 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. | 7.0.5 | 190.07K | None | Abort early | 199 μs | 306.82x | ||