Skip to content

v0.17.0

Choose a tag to compare

@mertcanaltin mertcanaltin released this 23 May 20:01
· 27 commits to master since this release

TypeScript inference from plain JSON Schema.

  • New exported Infer<S> type maps a schema literal to its data type, and new Validator(defineSchema({...})) returns Validator<Infer<S>>, so validate() narrows result.data with no manual annotation. Write plain JSON Schema, get the type for free, no builder DSL. Covers primitives, type-array unions, const, enum, objects (required vs optional), and arrays; $ref, tuples, and anyOf/oneOf infer unknown for now. Pure .d.ts, no runtime impact.

Fixed

  • validateAndParse() now works: it is implemented in JavaScript (JSON.parse then validate) and returns { valid, value, errors }. It previously called a native method that does not exist and threw on every call. Works with or without the native addon and in the browser.