Parsing a value to match the schema. This is different to validation because it returns a typed value, instead of a boolean.
Copy to clipboardimport * as v from "valibot"; import { personSchema } from "./schemas"; const person = v.parse( personSchema, data, ); // person is of type Person
Copy to clipboardimport * as v from "valibot"; import { personSchema } from "./schemas"; const person = v.parse(personSchema, data); // person is of type Person
Optimizations
Abort early
| Library | Version | /wk | Optimizations | Error type | Mean | Compare | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@remix-run/data-schema | Code snippet | 1.0.0 | 54.6K | None | Abort early | 387 ns | ||||
valibot | Code snippet | 1.5.0 | 32.14M | None | Abort early | 594 ns | 1.53x | |||
@railway-ts/pipelines | Code snippet | 0.1.29 | 75 | None | Abort early | 681 ns | 1.76x | |||
effect | Code snippet(Setup code is not benchmarked) | 4.1.2 | 68.36M | None | Abort early | 848 ns | 2.19x | |||
joi (no convert) | Code snippet | 18.3.2 | 34.64M | None | Abort early | 4 μs | 10.1x | |||
joi | Code snippet | 18.3.2 | 34.64M | None | Abort early | 4 μs | 10.5x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | 9.67M | None | Abort early | 7 μs | 17.5x | |||
superstruct | Code snippet | 2.0.2 | 9.67M | None | Abort early | 7 μs | 18.24x | |||
valibot (abortPipeEarly only) | Code snippet | 1.5.0 | 32.14M | None | Abort early | 11 μs | 27.88x | |||
yup (strict) | Code snippet | 1.7.1 | 16.35M | None | Abort early | 58 μs | 149.23x | |||
yup | Code snippet | 1.7.1 | 16.35M | None | Abort early | 84 μs | 216.9x | |||
runtypes (inspect) | Code snippet | 7.0.5 | 289.25K | None | Abort early | 179 μs | 462.35x | |||
runtypes | Code snippet | 7.0.5 | 289.25K | None | Abort early | 199 μs | 514.06x | |||