Skip to content

Commit

Permalink
Merge pull request #1 from GiantThinkwell/al-validate-api-key
Browse files Browse the repository at this point in the history
Validate API key
  • Loading branch information
adamloving committed Aug 6, 2014
2 parents cb91809 + f560148 commit bef522f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/mailchimp/MailChimpAPI_v2_0.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var http = require('http'),
request = require('request'),
helpers = require('./helpers');
request = require('request'),
helpers = require('./helpers');

/**
* MailChimp API wrapper for the API version 2.0. This object should not be
Expand All @@ -15,6 +15,11 @@ function MailChimpAPI_v2_0 (apiKey, options) {
if (!options)
var options = {};

// API Key must look like abc123-us2 (where us2 is the data center)
if (!apiKey.match(/^[a-z0-9]*\-[a-z0-9]*$/)) {
throw new Error('Unrecognized API key format: ' + apiKey + '. should look more like abc123-us2.');
}

this.version = '2.0';
this.apiKey = apiKey;
this.packageInfo = options.packageInfo;
Expand Down

0 comments on commit bef522f

Please sign in to comment.