每当我从架构中添加验证并尝试发布请求时,我都会收到以下错误消息:
错误:发送后无法设置标头。
var PlayerSchema = new Schema({
firstName: { type: String, require: true, required: 'First Name is required' },
lastName: { type: String, require: true, required: 'Last Name is required' },
nickName: { type: String, trim: true },
mentor: { type: String, trim: true },
clubName: { type: String, trim: true },
created_at: { type: Date, default: Date.now },
updated_at: { type: Date, default: Date.now },
email: {
type: String,
trim: true,
unique: true,
required: 'Email address is required',
validate: [validateEmail, 'Please fill a valid email address'],
match: [/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/, 'Please fill a valid email address']
},
phoneNumber: {
type: String,
unique: true,
required: 'Phone Number is required',
}
});