All Collections
Versions 3.0 and 2.0
Implement
Platform SDK
Message Syntax for Validate Hook vs. Record Hooks
Message Syntax for Validate Hook vs. Record Hooks
Elisa Dinsmore avatar
Written by Elisa Dinsmore
Updated over a week ago

This article is for Flatfile's Portal 3.0 and Workspaces. If you'd like to check out the latest version of the Flatfile Data Exchange Platform, click here!

Field Hooks and Record Hooks are both instrumental in validating your data. They both allow the addition of messages to inform your users of any changes you made as well as giving you the ability to specify the severity of the error, but they do each require a different format for displaying the messages.

Validate Hook:

Validate hooks messages are inserted using Message and take three parameters - the message, the message level, and the stage at which the hook is being run. The stage for validate hooks will always be 'validate', and the level can be 'warning', 'error', or 'comment'/'info'.

return [  new Message(    `${salary} is less than minimum wage ${minSalary}`,    'warn',    'validate'  ),]

Record Hook:

Record hook messages are inserted using the addError, addWarning, addComment, or addInfo methods like in previous versions of hooks. These methods take two parameters: the field(s) on which the message should appear and the message itself.

if (!countryCodeValid) {  record.addError('country', 'Country Code is not valid')}

Please note that Errors will both flag the field and block it from being submitted if the error is still there. Warnings, Comments, and Info will flag the field but allow the data to still be submitted, even if it is not corrected.

For more information on Data Hooks® in the Platform SDK, please visit our developer documentation.

Did this answer your question?