In I Compared 6 TypeScript Validation Libraries. Here's What Surprised Me 🤔, DEV author nyaomaru compares six libraries and a handwritten guard against a shared user-record contract. Nyaomaru maintains one of those libraries, is-kit, and includes the handwritten guard as a baseline.
Define the input domain before comparing validators
The comparison uses ordinary JSON-decoded data as its main domain. The record requires an integer age in range, a name of one to 100 UTF-16 code units, and exact fields at the root and inside a nested profile. The author reports agreement on 35 fixtures across the seven implementations. That result covers the tested JSON-shaped inputs.
A separate set of JavaScript object probes changes the picture. The handwritten guard counts enumerable string keys with Object.keys, so the extra symbol property in the probe does not enter its count. Its array check uses every, which skips holes, so the sparse tags array passes that guard. The article reports that is-kit rejects the sparse array and accepts the symbol property. The word “exact” therefore needs a stated policy for the kinds of objects that can actually reach a boundary.
Decide what the caller gets back
The handwritten predicate can narrow an unknown value after a successful check. A form that needs to explain why a nested field failed has a different output requirement. The comparison shows how a runtime validator object can expose structured failures and how a schema can provide parsing or transformation APIs. Those capabilities matter when the caller needs more than a decision to enter a branch.
The source measures isolated browser bundles and a steady-state Node loop over repeated shapes. A standalone bundle measures a different cost from adding a schema to an app that already ships the library. The benchmark also exercises APIs that perform different work, including a generated guard and a schema parse followed by a success check. What would your own contract test include if values can also arrive from plugins or in-memory application code?