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

Need help with .validate()

Open sjonesyodle opened this issue 12 years ago • 1 comments

Need help with this validator function..

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

A few things.

  • Some errors in this example. It should look like..
//Invoke validations and wait for the validations to fulfill
u1.validate(function() {
  if ( u1.isValid ) {
     //validated, perform business logic
  } else {
     //validation failed, dump validation errors to the console
     console.log(u1.errors)
  }
});

".validate" takes an argument as "filter" but does nothing with it nor invokes it as the example above illustrates.

The function does this with it..

if (filter) {
        vProps = [filter];
      }

Am I missing something?

Best, Steve

sjonesyodle avatar Nov 19 '13 16:11 sjonesyodle

Sorry for some reason I didn't get a notification for this ticket,

Validate takes no arguments at all, Just follow one of the unit test examples, here:

https://github.com/asaf/nodejs-model/blob/master/test/test-custom_validators.coffee#L25

If it still doesn't work for you I will write you a small example,

Thanks.

asaf avatar Nov 28 '13 23:11 asaf