Novu changelog
Zod Integration with Novu
You can now use Zod Schemas for defining your payload and step controls schemas. The Framework SDK will infer those zod
schemas and provide a run-time validation and autocompletion for usage.
Here is an example of a Zod-based validation:
import { workflow } from '@novu/framework';
import { z } from 'zod';
workflow('comment-workflow', async ({ step }) => {
await step.email('digest-email', async (controls) => ({
subject: controls.subject,
body: 'body'
}), {
controlSchema: z.object({
subject: z.string().default('Hi {{subscriber.firstName}}'),
openAiModel: z.enum(['gpt-3.5-turbo', 'gpt-4o']).default('gpt-4o'),
aiPrompt: z.string().default('Produce a concise comment digest'),
})
});
}, {
payloadSchema: z.object({
name: z.string(),
comment: z.string()
})
});
Common usecases
Validate trigger payload contents to make sure that null or undefined data ends up in your notifications.
Provide default values for non-required attributes
Create custom validation logic based on backend logic
Define UI step controls and expose UI elements from zod schemas
To learn more about Zod integration, read our documentation.