中的集合中的值
我正在使用简单模式,我希望有一种方法来验证一些字段中的值与预定义的列表或其他
根据预定义的、未更改的列表(如enum)进行验证。这也许可以用一个复杂的正则表达式来完成,但这感觉不太对:
dialogType: {
type: String,
label: "Dialog Type", // 'article', 'sentence','exercise','lesson','word'
optional: false
},
对用户集合进行验证,可能会应用一些过滤器:
userId: {
type: String,
label: "User ID",
optional: false
}
一个相关的问题将allowedValues绑定到simple-schema
我想你可以这样做:
dialogType: {
type: String,
allowedValues: ['article', 'sentence','exercise','lesson','word'],
optional: true
},
你看了https://github.com/aldeed/meteor-simple-schema#allowedvalues