ALL ARTICLES
SHARE

How Flatirons Fuse Delivers Back-End Validations

author-avatar
Development
4 min read
back-end validation
Contents
Contents

In our recent blog, we covered how front-end validations help to ensure a successful data migration (via CSV or spreadsheet) to your target system, by validating the data submitted and transforming it as necessary to deliver the latter half of the ETL (Extract, Transform. Load) process. With front-end validation, you can eliminate issues before submitting your CSV for import.  But front-end validation is only half the story. Once you correct the issues discovered by front-end validation, there may still be problems that are not accounted for in the hooks set up for the front-end (see last blog for details). Without back-end validation, you may have no insights into these issues.

Flatirons Fuse offers back-end validation support to ensure that, particularly after making changes to your data on submission, your customers are not left wondering what went wrong. In this article, we’ll cover how this is done.

Initializations and Hooks

In our front-end validation blog, we showed that initializations and hooks were responsible for validation, and if necessary, making small automatic transformations to your customer’s records to ensure compliance with your system. Back-end validations are handled in a similar manner but with a different type of hook. 

onSubmit (records)

While the onValidate and formatRecord hooks validate or transform the user’s data before submitting it to your system, onSubmit passes all records to your system after the user has made the necessary corrections identified by onValidate and formatRecord.

This hook requires a callback upon submission of your client’s records to your back-end by whatever means you typically would. In other words, this layer of validation is tied to your input process, we do not submit the records ourselves. The onSubmit callback allows you to pass back any back-end records for specific rows. Each record passed to the callback will have a unique identifier under the key record._meta.id.

Return Values:


No error – If there is no error, the callback will return an empty errors object, along with a message to show the user that all is well: 

importer.onSubmit = async (records) => {
  // submit to backend here
  let message = "Data imported successfully";
  return {
    message,
    errors: {},
  };
};
importer.onSubmit = async (records) => {
  // submit to backend here
  let message = "Data imported successfully";
  return {
    message,
    errors: {},
  };
};

As you can see, with no errors reported, the message that returns to the user is delivered as “Data imported successfully”. 

Error – If an error is returned from the back-end, your system can inform the importer to show the error to the user: 

importer.onSubmit = async (records) => {
  // submit to your backend here

  return {
    errors: {
      [records[0]._meta.id]: {
        "email": "Email is already taken. Emails must be unique.",
        "first_name": "First Name must be capitalized."
      }
    }
  };
};
importer.onSubmit = async (records) => {
  // submit to your backend here

  return {
    errors: {
      [records[0]._meta.id]: {
        "email": "Email is already taken. Emails must be unique.",
        "first_name": "First Name must be capitalized."
      }
    }
  };
};

In the above example, we see two errors reported. This system does not allow duplicate email addresses, likely to ensure no one has multiple logins or is considered as separate sales prospects (which could skew metrics), among other possible reasons. As you can see, the error message provides the user with a clear reason, one that is easy to resolve. “Email is already taken. Emails must be unique.” Note as well that separate issues are identified. Whether back or front-end, you can tailor your validations and format changes as much as necessary with just a few lines of code.

Everyone Needs Validation

Flatirons Fuse offers both front-end validation and back-end validation support, ensuring that your customers are never left wondering why a problem occurred, or the next steps to fixing the issue. Because our solution is low code, you can begin validating CSV files in no time, saving your development time and energy to better serve core functionality. Let us ensure a powerful, simple, and pleasant-to-use onboarding experience so that your customers are able to focus on the unique strengths your solution has to offer. Contact Flatirons Fuse today!

Professional CSV Import Solution

Flatirons Fuse is an enterprise-grade, embeddable CSV import solution.

Learn more

Professional CSV Import Solution

Flatirons Fuse is an enterprise-grade, embeddable CSV import solution.

Learn more
author-avatar
More ideas.
Development

tRPC vs GraphQL: Which API Is Best for You?

Flatirons

May 15, 2024
Development

Choosing the Best Flutter IDE for App Development

Flatirons

May 14, 2024
Development

PWA vs. Native Apps: A Comparison

Flatirons

May 13, 2024
Development

The Key Roles in a Software Development Team

Flatirons

May 11, 2024
Development

How to Write Clean and Maintainable Code

Flatirons

May 10, 2024
Development

How to Hire an Offshore Developer

Flatirons

May 09, 2024
Development

tRPC vs GraphQL: Which API Is Best for You?

Flatirons

May 15, 2024
Development

Choosing the Best Flutter IDE for App Development

Flatirons

May 14, 2024
Development

PWA vs. Native Apps: A Comparison

Flatirons

May 13, 2024
Development

The Key Roles in a Software Development Team

Flatirons

May 11, 2024
Development

How to Write Clean and Maintainable Code

Flatirons

May 10, 2024
Development

How to Hire an Offshore Developer

Flatirons

May 09, 2024