有没有办法从同一个模型中调用一个属性?因为我想使用 model/code.js 中的属性来计算同一文件中其他属性的验证器。我会用例子告诉你。
//model/code.js
import Ember from 'ember';
import DS from 'ember-data';
import {validator, buildValidations} from 'ember-cp-validations';
const CardValidations = buildValidations(
{
cardId: {
validators: [
validator('presence', true),
validator('length', {
// here instead of 10, I want to use nbBits
max: 10
}
]
}
}
);
export default Credential.extend(CardValidations, {
cardId: DS.attr('string'),
nbBits: DS.attr('number'),
displayIdentifier: Ember.computed.alias('cardId'),
});
如您所见,我想调用nbBits来对cardId进行特定验证。
有人知道方法或给我提示吗?感谢您的时间