I have this code
var ClientSchema = new Schema({
name: {type: String, required: true, trim: true}
});
var Client = mongoose.mode(\'Client\', ClientSchema)
mongodb does not run validation on update by default. in order to make validation works by default when update also, just before connecting to mongodb you can set global setting only ones like that:
mongoose.set('runValidators', true); // here is your global setting
mongoose.connect(config.database, { useNewUrlParser: true });
mongoose.connection.once('open', () => {
console.log('Connection has been made, start making fireworks...');
}).on('error', function (error) {
console.log('Connection error:', error);
});
and any built-in or custom validation will run on update also