nodejs-model icon indicating copy to clipboard operation
nodejs-model copied to clipboard

README.md has invalid sample code for validations

Open mattnesterenko opened this issue 9 years ago • 0 comments

Took a minute to figure out why I couldn't get validations working based on the sample, but it looks like the sample code has a bug with the validation promise.

It displays this u1.validate(function() {}):

    u1.validate(function() {
      if u1.isValid {
         //validated, perform business logic
      } else {
         //validation failed, dump validation errors to the console
         console.log(p1.errors)
      }
    });

When it should call u1.validate().then(function() {}) from the validate promise:

    u1.validate().then(function() {
      if u1.isValid {
         //validated, perform business logic
      } else {
         //validation failed, dump validation errors to the console
         console.log(p1.errors)
      }
    });

Thanks, Matt

mattnesterenko avatar Mar 22 '15 01:03 mattnesterenko