Dynz.

Introduction

Dynz is a headless TypeScript schema library. Define your interaction logic once — validate it on the frontend, enforce it on the backend, expose it to any AI agent.

What is Dynz?

Dynz is a headless schema library that replaces scattered form logic with a single TypeScript definition any consumer can evaluate.

The core idea: the rules behind your interactions — what fields to show, what's required, what's valid — should live in one place. Not split between a frontend component and a backend validator. Not locked inside a specific framework or channel.

A Dynz schema is a plain object. It survives a JSON round-trip. It can be generated on the server, sent to the client, validated by an AI agent, or enforced by an API — with no modification.

import * as d from 'dynz';

const schema = d.object({
  email: d.string().email(),
  plan:  d.options(['free', 'pro', 'enterprise']),
  seats: d.number().min(1)
           .setIncluded(d.eq(d.ref('plan'), 'enterprise')),
});

That one definition is all you need. Your frontend reads it to render the form. Your backend reads it to validate the submission. Your AI agent reads it to understand what the interaction expects.

Why Dynz?

Most validation libraries solve the wrong problem. They give you a rich API for describing data shapes — but the result is a JavaScript function, not data. You can't serialize it. You can't send it over the wire. You can't evaluate it in a different runtime.

Dynz expresses everything — conditions, rules, cross-field references — as serializable data structures. The predicate d.eq(d.ref('plan'), 'enterprise') is not a closure; it's an object like { type: 'eq', left: { type: 'ref', path: 'plan' }, right: 'enterprise' }. Any runtime that can evaluate that structure can act on the schema.

Key features

  • Headless by design — no UI components, no rendering opinions. Bring your own renderer.
  • Fully serializable — schemas survive JSON.stringify / JSON.parse and can be generated at runtime.
  • Cross-field expressionsd.ref(), d.multiply(), d.sum() and friends let rules reference and compose other field values.
  • Conditional everythingrequired, mutable, and included all accept a predicate, not just a boolean.
  • Zero dependencies (core) — ~6 kb, tree-shakeable.
  • First-class TypeScriptSchemaValues<typeof schema> infers the exact value type from your schema definition.

Packages

PackageDescription
dynzCore schema builder, rules, predicates, and validate()
@dynz/react-hook-formReact Hook Form resolver and reactive hooks

Next steps

On this page