I am trying to test validation on a very simple mongoose model, but I have
some problem with exceptions.
//model.js
var ResourceDef = new Schema({
name: {type: String, required: true},
content: String,
});
var Resource = mongoose.model('Resources', ResourceDef);
//test.js
vows.describe('test model behavior').addBatch({
'validating a Resource object with name equals to null': {
topic: function() {
new model.Resource({
name: null,
content: '.....',
}).validate(this.callback);
},
'should throw an error': function(e) {
assert.ok(e);
}
}
}).export(module);
I get this error:
validating a Resource object with name equals to null
✗ should throw an error
» An unexpected error was caught: ValidationError: Validator
"required" failed for path name
I don't understand why mongoose is throwing that ValidationError!
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en