Subscribe now to stay up-to-date
Developers
Ashley Mulligan
Published 12/22/2022
Let's continue thinking through more real-world examples to wrap our minds around the possibilities of Flatfile's Field Hooks, which — as their name suggests — clean up or validate data at the field level.
This is Part 2 of a 3-part series about Flatfile's Field Hooks. Read Part 1 - Field Hooks: cast first if you haven't already.
Suppose we need to convert all employee names to lowercase before reasoning about the data strings.
We'll use compute to modify the data in place before proceeding to validate
.
First, compute
will receive data of the type determined by the field's cast hook
Then, it will perform a transformation to the value returned from cast
.
Note: compute
will always return data of the same type
While Field Hooks only clean up or validate data at the field level, recordCompute
and batchRecordsCompute
come into play when you need to run computations across all fields in a single record or in bulk operations. More on Record Hooks soon.
Check out the docs to learn more about processing data with Flatfile or get started not with CLI Quickstart.