我正在使用 ember-validations,Ember 在 Add 和 Edit 控制器之间使用相同验证规则的正确方法是什么?
这样做不是 DRY 方式
App.UsersAddUserController.reopen(Ember.Validations.Mixin, {
validations: {
name: {
presence: true,
length: { minimum: 3 }
},
surname: {
presence: true,
length: { minimum: 3 }
}
},
});
App.UsersEditUserController.reopen(Ember.Validations.Mixin, {
validations: {
name: {
presence: true,
length: { minimum: 3 }
},
surname: {
presence: true,
length: { minimum: 3 }
}
},
});