Skip to content

Instantly share code, notes, and snippets.

@jvitoroc
Created February 4, 2018 18:22
Show Gist options
  • Save jvitoroc/d90b4f2c33548c29c700a22a5bcc24f6 to your computer and use it in GitHub Desktop.
Save jvitoroc/d90b4f2c33548c29c700a22a5bcc24f6 to your computer and use it in GitHub Desktop.
var schema = new Schema({
name: {
type: String,
required: true
}
});
var Cat = db.model('Cat', schema);
// This cat has no name :(
var cat = new Cat();
cat.save(function(error) {
assert.equal(error.errors['name'].message,
'Path `name` is required.');
error = cat.validateSync();
assert.equal(error.errors['name'].message,
'Path `name` is required.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment