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 | 1 μs | ||||
@paseri/compiler (safeParse) | Code snippet | 0.7.7 | 317 | Precompiled | All errors | 1 μs | 1.02x | |||
typia (createValidate) | Code snippet(Setup code is not benchmarked) | 15.3.0 | n/a | Precompiled | All errors | 1 μs | 1.32x | |||
typia (validate) | Code snippet | 15.3.0 | n/a | Precompiled | All errors | 2 μs | 1.64x | |||
zod-compiler | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.09x | |||
zod-compiler (bag + mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.1x | |||
zod-compiler (bag) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.08x | |||
zod-compiler (compact + mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.08x | |||
zod-compiler (compact) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.15x | |||
zod-compiler (mini) | Code snippet | 2.0.8 | n/a | Precompiled | All errors | 1 μs | 1.12x | |||