[docs] Explain the new validation code
Explain the rationale and history.
We use our own custom validators, that provide similar(ish) errors as ajv.
-
"Fast" validators like
ajvand others rely on runtime compilation usingnew Function(). This is fast but is a blocker for Cloudflare Workers and other (secure) environments which can block this. There are some ways to precompile but they don't have all the same features. To remain fast at runtime without precompilation, we have a custom validator that doesn't cover the entire json-schema spec, but rather, only the few features we need. Speed is particularly important for > 1,000 tests we have. -
We tried
typeboxfor a while which had the best DX but unfortunately, was not completely stable at time of use, and struggled with certain TS features we needed. But, the biggest deal breaker is the trend for libraries not to export inferred types (so called "slow types"), because of the performance impact. (They're fine for your own main project, if libraries and libraries they depend on are all inferring, things get slow). It also helps to have clear types to use for tsdoc, etc. -
TypeScript is the single source of truth.
Anything else?