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.
Zod (Recommended)
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
Withoutas const, TypeScript infersstringfortypeinstead of the literal"object", and you lose type inference onpayload.
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-jsonschemais required to convert decorators to JSON Schema.reflect-metadatamust 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-jsonschemadocs.
Choosing a Schema
Other Resources
- JSON Schema specification
- JSON Schema validator playground
- React JSON Schema Form — same UI engine Novu uses for the Dashboard
- Zod docs
- class-validator docs