Validating multiple rows at once
Row hooks are great for validating a single row, but what if you want to validate multiple rows at once? For example, you want to make sure that the user has imported at least 20 rows. In this case, you can use the beforeFinish
callback.
This function will run every time the user clicks the "Finish" button. If it returns an object with the cancel
property set to true
, the user will be reverted to the data review screen, and the message
will be displayed as a table-level error.
info
For more detail about the beforeFinish
callback, see the Reference page
- JavaScript
- React
dromo.beforeFinish(function (data, metadata, instance) {
if (data.length < 20) {
return { cancel: true, message: "You must import at least 20 rows" }
}
});
<DromoUploader
...
beforeFinish={(data, metadata, instance) =>
if (data.length < 20) {
return { cancel: true, message: "You must import at least 20 rows" }
}
}
>
Launch Dromo
</DromoUploader>