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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
arktype | Code snippet | 2.2.9 | n/a | JIT | All errors | 101 μs | ||||
ata-validator | Code snippet | 1.63.1 | 53.34K | JIT | All errors | 59 ns | 1_700.36x | |||
ata-validator (parse) | Code snippet | 1.63.1 | 53.34K | JIT | All errors | 6 μs | 17.72x | |||
sury (asResult) | Code snippet(Setup code is not benchmarked) | 11.1.0 | 409.26K | JIT | All errors | 4 μs | 23.82x | |||
sury (parseOrThrow + compiled) | Code snippet(Setup code is not benchmarked) | 11.1.0 | 409.26K | JIT | All errors | 5 μs | 21.27x | |||
typebox | Code snippet | 1.4.4 | 16.33M | JIT | All errors | 17 μs | 6x | |||
typebox (compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 13 μs | 7.7x | |||
typebox (schema compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 10 μs | 10.33x | |||
typebox (schema) | Code snippet | 1.4.4 | 16.33M | JIT | All errors | 13 μs | 7.93x | |||
typebox (script compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 9 μs | 10.75x | |||
zod | Code snippet | 4.6.7 | n/a | JIT | All errors | 13 μs | 8.04x | |||
zod (compile) | Code snippet | 4.6.7 | n/a | JIT | All errors | 14 μs | 7.35x | |||
zod/mini | Code snippet | 4.6.7 | n/a | JIT | All errors | 21 μs | 4.78x | |||
zod/mini (compile) | Code snippet | 4.6.7 | n/a | JIT | All errors | 21 μs | 4.75x | |||