对象架构内的简单模式有条件必填字段

时间:2018-08-25 00:01:02

标签: javascript meteor simple-schema

我试图使字段成为有条件的必填项,但是,当字段值位于对象数组中时,我很难访问它。 this.field返回未定义。基本上,我想做的是检查classes.$.active字段是否为false。如果为假,我想将monday字段设置为false。如果我可以成功检查active的值,则可以进行其余工作。

classes: {
  type: Array,
  optional: true,
},
'classes.$': {
  type: Object,
  optional: true,
},
'classes.$.monday': {
  type: Boolean,
  optional: true,
  custom() {
    console.log('test', this.field('classes.$.active').value);
  },
}

0 个答案:

没有答案