required : 表示这个数据必须传入javascript
max: 用于 Number 类型数据,最大值java
min: 用于 Number 类型数据,最小值mongoose
enum:枚举类型, 要求数据必须知足枚举值 enum: ['0', '1', '2']ui
match:增长的数据必须符合 match(正则)的规则spa
maxlength:最大值code
minlength:最小值ip
var UserSchema = new mongoose.Schema({ name: { type: String, required: true }, age: { type: Number // 是否必须的校验器 required: true, // 数字类型的最大值校验器 max: 120, // 数字类型的最小值校验器 min: 0 }, status: { type: String, // 设置字符串的可选值 enum: ["0", "1", "2"] }, phone: { type: Number, match: /^\d{11}$/ }, desc: { type: String, maxlength: 20, minlength: 10 } });