Model validation hooks
💡This features is available for Enterprise plans only
To start, go to your Models page, select the model you want to validate and click Show more options
The click Edit validation hook
A pop-up will appear with this sample code:
The code we write here will have access to these constants:
model: The model object being validated
contentModel: The entire content object currently loaded in the editor
editingVariation: The current content variation being edited
Validation works by returning validation error objects from this code, or returning nothing (
undefined) to indicate no errors.
Validation errors are regular JS objects with this shape:
level: (required) Indicates the severity of the problem. Possible values are the strings 'warning' or 'error'
message: (required) Main error text
secondaryMessage: (optional) Additional text about this error.
element: (optional) If you can pinpoint the element with the problem, put it here and the editor will highlight it
moreInfoUrl: (optional) A URL for external help on the error
affectedElements: (optional) If the error is related to several elements, put them all here as an array
You can return a single object to indicate a single error, or you can return an array of these error to indicate several of them.