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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
effect | Code snippet(Setup code is not benchmarked) | 4.1.2 | 66.82M | None | Abort early | 882 ns | ||||
joi | Code snippet | 18.3.2 | 34.47M | None | Abort early | 4 μs | 4.48x | |||
joi (no convert) | Code snippet | 18.3.2 | 34.47M | None | Abort early | 4 μs | 4.32x | |||
valibot | Code snippet | 1.5.0 | 32.05M | None | Abort early | 615 ns | 1.43x | |||
valibot (abortPipeEarly only) | Code snippet | 1.5.0 | 32.05M | None | Abort early | 11 μs | 12.54x | |||
yup | Code snippet | 1.7.1 | 16.36M | None | Abort early | 86 μs | 97.06x | |||
yup (strict) | Code snippet | 1.7.1 | 16.36M | None | Abort early | 58 μs | 65.51x | |||
superstruct | Code snippet | 2.0.2 | 9.59M | None | Abort early | 7 μs | 7.59x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | 9.59M | None | Abort early | 7 μs | 7.68x | |||
runtypes | Code snippet | 7.0.5 | 281.67K | None | Abort early | 204 μs | 230.91x | |||
runtypes (inspect) | Code snippet | 7.0.5 | 281.67K | None | Abort early | 183 μs | 207.89x | |||
@remix-run/data-schema | Code snippet | 1.0.0 | 51.96K | None | Abort early | 398 ns | 2.22x | |||
@railway-ts/pipelines | Code snippet | 0.1.29 | 59 | None | Abort early | 672 ns | 1.31x | |||