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 | ||||
|---|---|---|---|---|---|---|---|---|---|---|
@paseri/compiler (parse) | Code snippet | 0.7.7 | 317 | Precompiled | All errors | 5 μs | ||||
@paseri/compiler (safeParse) | Code snippet | 0.7.7 | 317 | Precompiled | All errors | 1 μs | 3.39x | |||
typia (createValidate) | Code snippet(Setup code is not benchmarked) | 15.3.0 | n/a | Precompiled | All errors | 12 μs | 2.44x | |||
typia (validate) | Code snippet | 15.3.0 | n/a | Precompiled | All errors | 12 μs | 2.41x | |||
zod-compiler | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 61 ns | 81.12x | |||
zod-compiler (bag + mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 61 ns | 81.23x | |||
zod-compiler (bag) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 61 ns | 81.09x | |||
zod-compiler (compact + mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 62 ns | 79.33x | |||
zod-compiler (compact) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 61 ns | 80.48x | |||
zod-compiler (mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 60 ns | 82.02x | |||