Checking if a given value matches the schema. This is different to parsing because it doesn't return a new value.
Copy to clipboardimport * as v from "valibot"; import { personSchema } from "./schemas"; if (v.is(personSchema, data)) { // data is narrowed to Person }
Optimizations
| Library | Version | /wk | Optimizations | Mean | Compare | ||||
|---|---|---|---|---|---|---|---|---|---|
typia (createIs) | Code snippet(Setup code is not benchmarked) | 14.0.6 | 242.17K | Precompiled | 56 ns | ||||
typia (is) | Code snippet | 14.0.6 | 242.17K | Precompiled | 87 ns | 1.56x | |||
zod-compiler (compact) | Code snippet | 2.0.4 | 57.98K | Precompiled | 12 μs | 220.01x | |||
zod-compiler (bag) | Code snippet | 2.0.4 | 57.98K | Precompiled | 16 μs | 286.43x | |||
zod-compiler | Code snippet | 2.0.4 | 57.98K | Precompiled | 16 μs | 287.15x | |||