【发布时间】:2017-11-01 07:38:11
【问题描述】:
我想将我的 Rest-API 验证更改为 node simple schema 用于架构定义和 collection2@core 用于架构验证。
我想使用Person schema来验证用户提供的data。
Schemas = {};
Schemas.Person = new SimpleSchema({
name: {
type: String,
label: "Person's Name",
unique: true,
max: 200
},
surname: {
type: String,
unique: true,
label: "person's surname"
},
};
validData = API.utility.validate(data, Schemas.Person });
API: {
utility: {
validate: function(data, schema) {
return "The SimpleSchema Validation";
}
}
};
【问题讨论】:
标签: rest meteor simple-schema