Data Validation
- 05 Dec 2022
-
DarkLight
-
PDF
Data Validation
- Updated on 05 Dec 2022
-
DarkLight
-
PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
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?