var customValidator = function(value) {
return true;
};
var TestSchema = new mongoose.Schema({
object_of_strings: {
first: {type: String, validate: customValidator},
second: {type: String, validate: customValidator}
},
array_of_strings: [{type: String, validate: customValidator}]
});
var TestModel = db.model('Test', TestSchema);
var testObject = new TestModel();
testObject.object_of_strings.first = 'object first';
testObject.object_of_strings.second = 'object second';
testObject.array_of_strings.push('array first');
testObject.array_of_strings.push('array second');
testObject.save(function(err) {
if (err) {
console.log('failure');
} else {
console.log('success');
}
});
When I save a document of this type, it prints "object first" and "object second", but not "array first" and "array second".