Data Validation
  • 05 Dec 2022
  • Dark
    Light
  • PDF

Data Validation

  • Dark
    Light
  • PDF

Article Summary

Data Validation

When there is an error in data validation, the adapter utilizes the formatErrorObject library call to make sure the error is formatted consistently.

The parameters to formatErrorObject are:

  • Information on the origin of the error.
  • A key in the error.json to provide additional information for the error. You can add errors to the error.json and use the keys when defining the error to get more information. If the key does not match any errors in the error.json, the key will be used as a display string for the error.
  • An array of variables to populate the display message.
  • The error code that came from the other system.
  • The raw response that came from the other system.
  • The stack trace or exception.

Example: Data validation in adapter.js

/* HERE IS WHERE YOU VALIDATE DATA */
if (param1 === undefined || param1 === null || param1 === '') {
  const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['param1'], null, null, null);
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
  return callback(null, errorObj);
}

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.