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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
yup (strict) | Code snippet | 1.7.1 | n/a | None | Abort early | 58 μs | ||||
yup | Code snippet | 1.7.1 | n/a | None | Abort early | 86 μs | 1.48x | |||
valibot (abortPipeEarly only) | Code snippet | 1.5.0 | n/a | None | Abort early | 11 μs | 5.22x | |||
valibot | Code snippet | 1.5.0 | n/a | None | Abort early | 615 ns | 93.98x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | n/a | None | Abort early | 7 μs | 8.53x | |||
superstruct | Code snippet | 2.0.2 | n/a | None | Abort early | 7 μs | 8.63x | |||
runtypes (inspect) | Code snippet | 7.0.5 | n/a | None | Abort early | 183 μs | 3.17x | |||
runtypes | Code snippet | 7.0.5 | n/a | None | Abort early | 204 μs | 3.52x | |||
joi (no convert) | Code snippet | 18.3.2 | n/a | None | Abort early | 4 μs | 15.16x | |||
joi | Code snippet | 18.3.2 | n/a | None | Abort early | 4 μs | 14.62x | |||
effect | Code snippet(Setup code is not benchmarked) | 4.1.2 | n/a | None | Abort early | 882 ns | 65.51x | |||
@remix-run/data-schema | Code snippet | 1.0.0 | n/a | None | Abort early | 398 ns | 145.4x | |||
@railway-ts/pipelines | Code snippet | 0.1.29 | n/a | None | Abort early | 672 ns | 85.98x | |||