假设我Invoice在 SailsJS 中有一个模型。它有 2 个日期属性:issuedAt和dueAt. 如何创建自定义验证规则来检查到期日期是否等于或大于发布日期?
我尝试创建自定义规则,但似乎我无法访问规则内的其他属性。
module.exports = {
  schema: true,
  types: {
    duedate: function(dueAt) {
      return dueAt >= this.issuedAt // Doesn't work, "this" refers to the function, not the model instance
    }
  },
  attributes: {
    issuedAt: {
      type: 'date'
    },
    dueAt: {
      type: 'date',
      duedate: true
    }
  }
};