Aurelia验证不适用于派生类

时间:2015-09-23 08:04:34

标签: aurelia aurelia-validation

我在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属性甚至没有在验证中列出基。

0 个答案:

没有答案