Validation
Built-in Validators
Strings - Required
var customerSchema = new Schema({
name: { type: String, required: true }
});
// OR
// After the schema is defined – via the path API
// Signature = required(required, [message])
customerSchema.path(‘city’).required(true, ‘Oops! Supply a city.’);Strings – Match and Enum
Numbers Validation
Custom Validators
Overwrite In-built validation

Last updated