title: ValidateJS Async REST Call
body: <p>I am trying to create a validator which makes a REST call to my server and grabs a value the database. A few problems, when my validator is enabled it only validates that input and not the rest of the constraints. Also, I keep getting this error for the Id length <code>[validate.js] Attribute id has a non numeric value for length</code>, I do not receive this error when I am not using the async validator.</p>
  
  <p>Here is my validator:</p>
  
  <pre><code>  validate.validators.myAsyncValidator = function(input, options, key, attributes) {
  return new validate.Promise(function(resolve, reject) {
    if (!validate.isEmpty(input.value)) {
      axios.get('/data-management/verify-data', {
          params: {
            id: input.value,
            filter: options[0]
          }
        })
        .then(function(response) {
          if (response.data !== options[1]) resolve(" already exists!");
        })
        .catch(function(error) {
          resolve(": Error, try again.");
        });
    }
  }); };
  </code></pre>
  
  <p>Here are my constraints:</p>
  
  <pre><code>var constraints = {
  email: {
    presence: true,
    email: true
  },
  password: {
    presence: true,
    format: {
      // We don't allow anything that a-z and 0-9
      pattern: "^[a-zA-Z0-9!@#$&amp;()\\-`.+,/\"]*$",
      // but we don't care if the username is uppercase or lowercase
      flags: "i",
      message: "Must contain at least 1 Uppercase, 1 Lowercase, 1 Number, and 1 Special Character"
    },
    length: {
      minimum: 6,
      message: "Must be at least 6 characters"
    }
  },
  "confirm-password": {
    presence: true,
    equality: {
      attribute: "password",
      message: "^The passwords does not match"
    }
  },
  district: {
    presence: true
  },
  id: {
    presence: true,
    length: {
      minimum: 5,
      maximum: 20,
      message: "Must be between 6-20 characters"
    },
    format: {
      // We don't allow anything that a-z and 0-9
      pattern: "[a-z0-9]+",
      // but we don't care if the username is uppercase or lowercase
      flags: "i",
      message: "can only contain a-z and 0-9"
    },
    myAsyncValidator: ["signup", false]
  }};
  </code></pre>
  
  <p>And me hooking up my constraints to my form:</p>
  
  <pre><code>var inputs = document.querySelectorAll("input, textarea, select");
    for (var i = 0; i &lt; inputs.length; ++i) {
      inputs.item(i).addEventListener("change", function(ev) {
        // var errors = validate.async(form, constraints).then(function(data) {
        //   console.log("data");
        // });
        var obj = this;
        var n = this.name;
        validate.async(form, constraints).then(function() {
  
        }, function(errors) {
          showErrorsForInput(obj, errors[n.valueOf()]);
        });
  
  
      });
    }
  
    function handleFormSubmit(form, input) {
      // validate the form against the constraints
      // var errors = validate.async(form, constraints).then(function(data) {
      //   console.log("data2");
      // });
      validate.async(form, constraints).then(function() {
  
      }, function(errors) {
        showErrors(form, errors || {});
        if (!errors) {
          showSuccess();
        }
  
      });
  </code></pre>
  
  <p>I can provide the functons showErrors(), showSuccess(), and showErrorsForInput() if needed.</p>
  
  <p>Thanks!</p>