Skip to content

Schema Validation

Coming soon

This page is a placeholder while the full guide is written. See the @mqttkit/core README — Schema Validation for current reference material.

topic({ schema }) accepts any Standard Schema v1 validator: zod ≥3.24, valibot ≥1, arktype, and others. The validated payload is exposed on ctx.body with full type inference. The validate option controls direction ('inbound' | 'outbound' | 'both' | false).

  • @mqttkit/typebox — register once with app.addSchemaProvider(typeboxProvider) and pass raw Type.X(...) schemas directly. TypeBox schemas are JSON Schema natively, so @mqttkit/asyncapi emits the full payload automatically.
  • @mqttkit/zodjsonify(schema) attaches a JSON Schema representation to a zod schema so @mqttkit/asyncapi can emit the full payload (zod 3.x already speaks Standard Schema for runtime validation).

Examples

See examples/schema-validation for zod, typebox, coexist, and manual variants.

Released under the MIT License.