本文整理汇总了TypeScript中angular2/core.Validators类的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators类的具体用法?TypeScript Validators怎么用?TypeScript Validators使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Validators类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should not include controls that have no errors", () => {
var one = new Control("one", validator("a", true));
var two = new Control("two");
var g = new ControlGroup({"one": one, "two": two});
expect(Validators.group(g)).toEqual({"a": [one]});
});
示例2: it
it("should ignore nulls", fakeAsync(() => {
var c = Validators.composeAsync([asyncValidator("expected", {"one": true}), null]);
var value = null;
c(new Control("invalid")).then(v => value = v);
tick(1);
expect(value).toEqual({"one": true});
}));
示例3: it
it("should return null when no errors", () => {
var c = Validators.compose([Validators.nullValidator, Validators.nullValidator]);
expect(c(new Control(""))).toEqual(null);
});
示例4: expect
() => { expect(Validators.compose(null)).toBe(Validators.nullValidator); });