title: asyncvalidator promise not being resolved
body: <p>I am trying to cancel an $asyncValidator promise but I am an error of undefined is being thrown, here is my code:</p>
  
  <pre><code>(function () {
      'use strict';
  
  angular
      .module("webclient.common.directives")
      .directive("duplicateModelNameValidator",
                  ["$q",
                   "modelManager",
                   duplicateModelNameValidator
                  ]);
  
  function duplicateModelNameValidator($q, modelManager) {
      return {
          restrict: "A",
          require: "ngModel",
          link: function (scope, element, attrs, ngModel) {
              var classId = attrs.duplicateModelNameValidator;
  
              ngModel.$asyncValidators.duplicateModelName = function (modelValue) {
                  var defer = $q.defer();
                  //if the user hasn't touched the input box I don't want to call the database code
                  if (ngModel.$pristine)
                      //I want to resolve the promise but get the error below?
                      return defer.resolve();
  
                  modelManager.find(modelValue, false).then(function (data) {
                      if (data.exists === true)
                          // Found a row
                          return defer.reject();
                      else
                          // Did not find a row
                          return defer.resolve();
                  });
  
                  return defer.promise;
              }
          }
      }
  }
  }());
  </code></pre>
  
  <p>The code throws the error:</p>
  
  <p>[ngModel:nopromise] Expected asynchronous validator to return a promise but got 'undefined' instead.</p>
  
  <p>Thanks</p>