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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
ata-validator | Code snippet | 1.63.1 | n/a | JIT | All errors | 59 ns | ||||
sury (asResult) | Code snippet(Setup code is not benchmarked) | 11.1.0 | 409.26K | JIT | All errors | 4 μs | 71.37x | |||
sury (parseOrThrow + compiled) | Code snippet(Setup code is not benchmarked) | 11.1.0 | 409.26K | JIT | All errors | 5 μs | 79.94x | |||
ata-validator (parse) | Code snippet | 1.63.1 | n/a | JIT | All errors | 6 μs | 95.94x | |||
typebox (script compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 9 μs | 158.22x | |||
typebox (schema compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 10 μs | 164.54x | |||
zod | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 13 μs | 211.46x | |||
typebox (schema) | Code snippet | 1.4.4 | 16.33M | JIT | All errors | 13 μs | 214.53x | |||
typebox (compile) | Code snippet(Setup code is not benchmarked) | 1.4.4 | 16.33M | JIT | All errors | 13 μs | 220.84x | |||
zod (compile) | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 14 μs | 231.34x | |||
typebox | Code snippet | 1.4.4 | 16.33M | JIT | All errors | 17 μs | 283.6x | |||
zod/mini | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 21 μs | 355.55x | |||
zod/mini (compile) | Code snippet | 4.6.7 | 454.84M | JIT | All errors | 21 μs | 358.12x | |||
arktype | Code snippet | 2.2.9 | 2.87M | JIT | All errors | 101 μs | 1_700.36x | |||