Skip to main content

Schema Validation

@novu/framework accepts three kinds of schemas for both payloadSchema (workflow level) and controlSchema (step level): All three are converted to JSON Schema under the hood and pushed to Novu Cloud — so the Dashboard always renders the same UI. Novu supports Zod v3.

Install

Workflow Payload

Step Controls

What gets rendered in the Dashboard

Zod doesn’t support custom title on fields — the Dashboard label is derived from the property name.

JSON Schema

Use JSON Schema when you need features Zod doesn’t expose: oneOf, if/then/else, $ref, enumNames, etc.

Workflow Payload

Without as const, TypeScript infers string for type instead of the literal "object", and you lose type inference on payload.

Examples

Simple object

Nested array

$ref reuse

oneOf discriminated union

if/then/else

Regex validation

Class Validator

For OOP-style projects (especially NestJS DTOs).

Install

class-validator-jsonschema is required to convert decorators to JSON Schema. reflect-metadata must be imported once at app entry (import "reflect-metadata").

Define DTOs

Caveats

  • Class Validator does not support default values out of the box — set them in your resolver.
  • Class Validator does not support custom titles — Dashboard labels come from the property name.
  • Nested schemas can have inconsistencies — see class-validator-jsonschema docs.

Choosing a Schema

Other Resources