All Collections
Versions 3.0 and 2.0
Implement
Platform SDK
What is new or different about Data Hooks® in the Platform SDK?
What is new or different about Data Hooks® in the Platform SDK?
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!

The Platform SDK will provide several different kinds of hooks that can be used to validate your data. Previously, the functions that these hooks perform could have been added as validation steps in the template editor in the Dashboard or would have all been added to the data hooks editor.

Field Hooks

Field hooks are hooks that are run directly on specific fields before the record level hooks are run. The validate hook is slightly different than the others, as it is run after all other hooks, whether field hooks or record hooks.

These hooks are run on the field level, and cannot reference other fields when running. If your validation would require input from multiple fields in your dataset, a recordCompute hook would be the way to go.

Cast:

Cast will take a string or undefined field and return either the primitive type specified by the field, null, or will throw an error. When the default cast function cannot parse an incoming value, it will throw an error in the UI and retain the original value so users can edit that value. Each of our field types have a default casting, except for the OptionField.

Compute:

Compute Data Hooks receive a single fully present value and return a value of the same type. This hook should be idempotent, returning a value of the same type each time the hook is run on the same field.

Validate:

Validate Data hooks should be used to confirm that user-inputted data matches what you're expecting to see. This hook will not allow you to write values to the cell, so should be used to add errors, warnings, or comments to the cell informing your user about what needs to be fixed.

Record Hooks

Record Hooks run your full record, rather than on individual fields. There are two types of record hooks - recordCompute hooks and batchRecordCompute hooks. Record hooks can also capture session data passed in when the importer is launched. Field hooks cannot access the same session data at this time.

recordCompute:

recordCompute hooks run synchronously for each record. They can be used to validate multiple fields in a record, as well as update values based on your validation rules. recordCompute hooks run on groups of 1000 rows at once.

batchRecordCompute:

batchRecordCompute hooks run after all recordCompute hooks and runs on the full list of processed rows, allowing you to perform bulk operations on them. This is where to add hooks that would be slow when run per row and would benefit from batching.

For more information on how our hooks work in the Platform SDK as well as examples of how to build these hooks, please visit our developer documentation.

Did this answer your question?