Skip to content

dhi v1.6.0

Choose a tag to compare

@justrach justrach released this 31 Aug 00:19
· 5 commits to main since this release
51f9b8f

Zod 4 core compatibility, one runtime-agnostic core, and Windows wheels.

Zod 4 core internals (#76)

Every dhi schema now exposes Zod 4's internals (_zod.def, _zod.run, optin/optout,
values, the JSON-Schema hook) and is assignable to Zod's $ZodType at the type level.
Libraries that detect Zod 4 schemas and call Zod's own core helpers work unchanged:

  • @modelcontextprotocol/sdk registerTool / registerPrompt — object schemas, raw shapes
    and output schemas. tools/list no longer fails with def.shape is not a function.
  • z.toJSONSchema(dhiSchema), z.safeParse(dhiSchema, …), instanceof z.ZodObject.

Single runtime-agnostic core

dhi, dhi/edge, dhi/cloudflare and dhi/nextjs now re-export the same core: identical
behaviour and JIT everywhere, no WASM instantiation, no top-level await, no bundler
configuration. The edge and Next.js entries had drifted ~800 lines behind the Node entry.

Behavioural parity with Zod 4

A new differential test (tests/test-zod-parity.ts) runs 250+ schemas over 4,400+ inputs
against the real zod package and requires identical accept/reject decisions and identical
parsed output. Closing the gaps it found changed, among others:

  • String formats: uuid checks RFC 9562 version/variant nibbles, url accepts any
    WHATWG-parsable URL, ipv6/cidrv6 use the WHATWG parser, base64/base64url padding
    rules, leap-year-aware date, ISO 8601-1 duration, Zod's email rules.
  • .lowercase() / .uppercase() validate case (.toLowerCase() / .toUpperCase() transform).
  • z.number() rejects Infinity; .int() means safe integer; float-safe .multipleOf().
  • Objects: absent optional keys stay absent, .catchall() validates unknown keys, JSON Schema
    required follows Zod's optin/optout rule with io: 'input' | 'output' honoured.
  • Tuples allow omitting trailing optional items; enum-keyed records are exhaustive
    (z.partialRecord for optional keys); z.coerce.date() coerces any input.

Also added

  • Zod 4 standalone checks for .check(...): z.minLength, z.gt/gte/lt/lte,
    z.multipleOf, z.regex, z.refine, z.superRefine and the rest of the set.
  • z.uuidv4/v6/v7, z.xid, z.ksuid, z.hash(), z.httpUrl(), z.hostname(), z.hex(),
    z.stringbool(), z.iso.datetime(), z.mac(), z.jwt().
  • .nonoptional() and .exactOptional() as real wrappers.
  • z.enum([...]) infers the literal union instead of widening to string.
  • dhi/schema-nextjs export alias.

Python

Windows wheels (AMD64, CPython 3.9–3.14 including free-threaded) are now built and
published; the C extension compiles under MSVC. (#59)