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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@railway-ts/pipelines | Code snippet | 0.1.29 | n/a | None | Abort early | 672 ns | ||||
@remix-run/data-schema | Code snippet | 1.0.0 | n/a | None | Abort early | 398 ns | 1.69x | |||
effect | Code snippet(Setup code is not benchmarked) | 4.1.2 | n/a | None | Abort early | 882 ns | 1.31x | |||
joi | Code snippet | 18.3.2 | n/a | None | Abort early | 4 μs | 5.88x | |||
joi (no convert) | Code snippet | 18.3.2 | n/a | None | Abort early | 4 μs | 5.67x | |||
runtypes | Code snippet | 7.0.5 | n/a | None | Abort early | 204 μs | 303.08x | |||
runtypes (inspect) | Code snippet | 7.0.5 | n/a | None | Abort early | 183 μs | 272.87x | |||
superstruct | Code snippet | 2.0.2 | n/a | None | Abort early | 7 μs | 9.96x | |||
superstruct (schema.validate) | Code snippet | 2.0.2 | n/a | None | Abort early | 7 μs | 10.08x | |||
valibot | Code snippet | 1.5.0 | n/a | None | Abort early | 615 ns | 1.09x | |||
valibot (abortPipeEarly only) | Code snippet | 1.5.0 | n/a | None | Abort early | 11 μs | 16.46x | |||
yup | Code snippet | 1.7.1 | n/a | None | Abort early | 86 μs | 127.39x | |||
yup (strict) | Code snippet | 1.7.1 | n/a | None | Abort early | 58 μs | 85.98x | |||