1const schema = new Schema({
2 name: {
3 type: String,
4 required: true
5 }
6});
7const Cat = db.model('Cat', schema);
8
9// This cat has no name :(
10const cat = new Cat();
11cat.save(function(error) {
12 assert.equal(error.errors['name'].message,
13 'Path `name` is required.');
14
15 error = cat.validateSync();
16 assert.equal(error.errors['name'].message,
17 'Path `name` is required.');
18});