                   + ' in to source control.' # Project setup success!
 
 
+# Validates that an API key works with Pixabay.
+#
+# @param [String] key the API key to validate
+# @param [Function] callback the function to call back on
+#
+validateApiKey = (key, callback) ->
+  url = buildUrl key, '195893', 0 # We know this image exists.
+  options =
+    url: url
+    json: true
+  request url, (error, response, body) -> # Request image JSON using API key.
+    callback(!error && response.statusCode == 200)
+
+
 # Walks the user through initializing their user file.
 #
 auth = () ->

persistUser = (obj, callback) ->
  if obj then user = obj # Replace loaded user.
  persist USER_PATH, user, callback


# Returns true if a request to the Pixabay API was successful.
#
# @param [Object] error any error returned with the response
# @param [Object] body the body of the response
#
isSuccessful = (error, body) ->
  !error \
  && body \
  && body.hits \
  && body.hits instanceof Array \
  && body.hits.length > 0


# Downloads an image.

    if err || exists
      callback err, exists # Folder exists already, or error.
    else
      ask "Doesn't look like the #{dir} directory exists, create it? (y/n) ", \
        (answer) ->
          if yn answer # Create directory? Yes or no.
            mkdirp dir, (err) ->
