最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

我如何在Express中验证模式?

网站源码admin14浏览0评论

我如何在Express中验证模式?

我如何在Express中验证模式?

我有以下模型。我希望遵循8个数字的字符串模式(示例:12345678),并且仅可以采用两个可能的值(infetado和suspeito)。如何进行验证?var userSchema = new Schema({ cartaoCidadao: { type: String, required: true, index: { unique: true, }, }, password: { type: String ,required:true}, role: { type: String }, estado:{type:String} });

我有以下模型。我希望cartaoCidadao遵循8个数字的字符串模式(例如:12345678),并且estado只能采用两个可能的值(infetado和suspeito)。我该如何做... 回答如下:因此,对于estado,它只能有两个可能的值('infetado'和'suspeito'),您可以使用enum
发布评论

评论列表(0)

  1. 暂无评论