本文整理汇总了TypeScript中@angular/forms.Validators.composeAsync方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Validators.composeAsync方法的具体用法?TypeScript Validators.composeAsync怎么用?TypeScript Validators.composeAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.Validators
的用法示例。
在下文中一共展示了Validators.composeAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should ignore nulls', () => {
const v = Validators.composeAsync([observableValidator({'one': true}), null !]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true});
});
示例2: FormControl
dynamicFormModel.items.forEach(controlModel => {
formGroup[controlModel.id] = new FormControl(
controlModel.value || null,
Validators.compose(controlModel.validators),
Validators.composeAsync(controlModel.validatorsAsync)
);
});
示例3: it
it('should ignore nulls', fakeAsync(() => {
const v = Validators.composeAsync([promiseValidator({'one': true}), null]);
let errorMap: {[key: string]: any};
first.call(v(new FormControl('invalid')))
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
expect(errorMap).toEqual({'one': true});
}));
示例4: it
it('should collect errors from all the validators', () => {
const v = Validators.composeAsync(
[observableValidator({'one': true}), observableValidator({'two': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true, 'two': true});
});