Class Validator
Integrate Class Validator with your notification workflows
Novu Framework allows you to use Class Validator to define the Control and Payload schemas for your workflows.
Add class validator to your project
Install Class Validator Packages
Novu requires the class-validator-jsonschema
package to generate JSON schemas from your DTOs. You may also need the reflect-metadata
package.
Use Class Validator in your workflow
After installation, the Class Validator DTOs can be used interchangeably with the controlSchema
and payloadSchema
options in your workflow definitions.
Controls and Payload UI
When you define a controlSchema
for a step, Novu will automatically generate a UI for the controls in the workflow editor.
- Form Input Title - Will be derived from the key of the Class Validator schema. Unfortunately Class Validator does not support custom titles at this point.
- Form Input Type - Will be derived from the Class Validator schema type, with support for
string
,number
,boolean
, andenum
andarray
types. - Default Value - Unfortunately Class Validator does not support default values at this point.
- Validation - Will be derived from the Class Validator schema validation decorators, including
@Min
,@Max
,@IsEmail
,@IsUrl
and etc...