最大值最小值、最大长度最小长度、必填、枚举列举、自定义验证
const postSchema = new mongoose.Schema({
title: {
type: String,
required: [true, '请传入文章标题'],
minlength: 2,//最小长度
maxlength: [5, '太长了'],//最大长度
trim: true
最大值最小值、最大长度最小长度、必填、枚举列举、自定义验证
const postSchema = new mongoose.Schema({
title: {
type: String,
required: [true, '请传入文章标题'],
minlength: 2,//最小长度
maxlength: [5, '太长了'],//最大长度
trim: true