本文整理汇总了TypeScript中angular2/forms.Validators类的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators类的具体用法?TypeScript Validators怎么用?TypeScript Validators使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Validators类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should collect errors from the child controls", () => {
var one = new Control("one", validator("a", true));
var two = new Control("one", validator("b", true));
var g = new ControlGroup({"one": one, "two": two});
expect(Validators.group(g)).toEqual({"a": [one], "b": [two]});
});
示例2: it
it("should collect errors from all the validators", () => {
var c = Validators.compose([validator("a", true), validator("b", true)]);
expect(c(new Control(""))).toEqual({
"a": true,
"b": true
});
});
示例3: constructor
constructor(c:ControlDirective) {
c.validator = Validators.compose([c.validator, Validators.required]);
}
示例4: expect
() => { expect(Validators.required(new Control("not empty"))).toEqual(null); });