Checking if a given value matches the schema. This is different to parsing because it doesn't return a new value.
import * as v from "valibot";
import { personSchema } from "./schemas";
if (v.is(personSchema, data)) {
// data is narrowed to Person
}
Optimizations
| Library | Version | Optimizations | Mean | Compare | |||
|---|---|---|---|---|---|---|---|
typebox (compile) | Code snippet(Commented code is not benchmarked) | 1.0.51 | JIT | 50 ns | |||
ajv (compile) | Code snippet(Commented code is not benchmarked) | 8.17.1 | JIT | 3 μs | 67.96x | ||
ajv (validate) | Code snippet | 8.17.1 | JIT | 3 μs | 68.74x |