我在typescript 1.6和最新的aurelia中有以下场景:
import {ensure, Validation} from "aurelia-validation";
import {ValidationGroup} from "aurelia-validation";
@inject(Validation)
export class BaseClass {
validation: ValidationGroup;
@ensure(function (it) { it.isNotEmpty().hasLengthBetween(3, 10) })
firstName: string;
constructor(validation: Validation) {
this.validation = validation.on(this, null);
}
}
@inject(Validation)
export class DerivedClass extends BaseClass {
@ensure(function (it) { it.isNotEmpty().hasLengthBetween(3, 10) })
lastName: string;
constructor(validation: Validation) {
super(validation);
}
submit() {
this.validation.validate().then((value) => { /* */ });
}
}
问题在于,当我在derived-class.html
视图中提交表单数据时,只有lastName
属性得到验证,而firstName
属性甚至没有在验证中列出基。