Custom Validation Callback

When regex validators are insufficient, you can setup a custom validator callback function that receives each row and returns a validation response that can be shown in the browser.


The below example assumes that you have configured a data model with both a country and postalCode field. This callback will conditionally validate the postal code as a US zip code if the country field is US.

If you return a promise from this function you can run asynchronous logic. Be careful with long running logic though because this will increase the amount of time required to process the file.

importer.registerValidatorCallback(function (record) {
const isZip = /^\d{5}(-\d{4})?$/;
if ( === "US") {
if (!isZip.test(record.postalCode)) {
return [
key: "postalCode",
message: "Must be of format 48222 or 48222-1746"

Validator Example

Response format

You can provide as many error messages as you'd like and you can provide more than one error message per key.

key: "foo", // the field key to associate the error to
message: "Foo is invalid" // the error message



The record parameter passed to the function will be a preview of the data you would expect from the results callback.