3
我有以下模式:验证日期值
Dates.attachSchema(new SimpleSchema({
description: {
type: String,
label: "Description",
max: 50
},
start: {
type: Date,
autoform: {
afFieldInput: {
type: "bootstrap-datepicker"
}
}
},
end: {
type: Date,
autoform: {
afFieldInput: {
type: "bootstrap-datepicker"
}
}
}
}));
我如何可以验证end
日期不start
过吗?我使用MomentJS来处理日期类型,但是我的主要问题是我如何访问custom
函数中的其他属性。
例如:
end: {
type: Date,
autoform: {
afFieldInput: {
type: "bootstrap-datepicker"
}
},
custom: function() {
if (moment(this.value).isBefore(start)) return "badDate";
}
}
如何访问start
?
此外,我怎么能验证,如果start
+ end
日期组合独特,意思是没有保存在我的数据库文件,该文件具有完全相同的start
和end
日期?