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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@railway-ts/pipelines | Code snippet | 0.1.29 | 143 | None | Abort early | 634 ns | ||||
effect | Code snippet(Commented code is not benchmarked) | 3.21.2 | 13.85M | None | Abort early | 10 μs | 15.08x | |||
effect@beta | Code snippet(Commented code is not benchmarked) | 4.0.0-beta.65 | 13.85M | None | Abort early | 1 μs | 1.9x | |||
joi | Code snippet | 18.2.1 | 20.07M | None | Abort early | 4 μs | 6.36x | |||
runtypes | Code snippet | 7.0.4 | 310.48K | None | Abort early | 170 μs | 268.46x | |||
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.4 | 310.48K | None | Abort early | 182 μs | 286.51x | ||
superstruct | Code snippet | 2.0.2 | 4.68M | None | Abort early | 10 μs | 15.43x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | 4.68M | None | Abort early | 10 μs | 15.83x | |||
valibot | Code snippet | 1.4.0 | 10.19M | None | Abort early | 715 ns | 1.13x | |||
valibot (abortPipeEarly only) | Code snippet | 1.4.0 | 10.19M | None | Abort early | 27 μs | 42.08x | |||
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 | 11.07M | None | Abort early | 83 μs | 130.48x | ||