Skip to content

Commit

Permalink
Add API Key validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sarus committed Aug 9, 2024
1 parent c365afe commit e8be075
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,25 @@ function createRequestOptions(entities, options) {
return requestOptions;
}

function validateOptions(userOptions, cb) {
let errors = [];

if (
typeof userOptions.apiKey.value !== 'string' ||
(typeof userOptions.apiKey.value === 'string' &&
userOptions.apiKey.value.length === 0)
) {
errors.push({
key: 'apiKey',
message: 'You must provide a valid ECrimeX API key'
});
}

cb(null, errors);
}

module.exports = {
startup,
doLookup
doLookup,
validateOptions
};

0 comments on commit e8be075

Please sign in to comment.