// matches formats like $10
const currencyRegex = /\$[0-9]*/;
const importer = new FuseImporter();
importer.getSessionToken = ... // see https://fuse-docs.flatirons.com/getting-started/sessions
importer.addColumn({
internal_key: "total_charge",
label: "Total Charge",
column_type: "string",
required: true,
position: 1,
unique: true,
});
importer.onValidateRecord = async (record) => {
const errors = {};
const warnings = {};
// make sure the total charge matches the regex
if (!record.total_charge?.match(currencyRegex)) {
errors["total_charge"] =
"Total charge must be a dollar amount matching the format $xx";
}
return {
errors: errors,
warnings: warnings,
};
};
importer.show();