From 17dcbf66b9b1b6a7648f352a3c423319d80b7b37 Mon Sep 17 00:00:00 2001 From: Kara Erickson Date: Fri, 24 Jun 2016 18:24:11 -0700 Subject: [PATCH] feat(forms): expose ValidatorFn and AsyncValidatorFn Closes #8834 --- modules/@angular/forms/src/forms.ts | 3 ++- tools/public_api_guard/forms/index.d.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/@angular/forms/src/forms.ts b/modules/@angular/forms/src/forms.ts index 8390002d71..26c48d14a0 100644 --- a/modules/@angular/forms/src/forms.ts +++ b/modules/@angular/forms/src/forms.ts @@ -38,8 +38,9 @@ export {FormControlName} from './directives/reactive_directives/form_control_nam export {FormGroupDirective} from './directives/reactive_directives/form_group_directive'; export {FormGroupName} from './directives/reactive_directives/form_group_name'; export {NgSelectOption, SelectControlValueAccessor} from './directives/select_control_value_accessor'; -export {MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValidator, Validator} from './directives/validators'; +export {AsyncValidatorFn, MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValidator, Validator, ValidatorFn} from './directives/validators'; export {FormBuilder} from './form_builder'; export {AbstractControl, FormArray, FormControl, FormGroup} from './model'; export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './validators'; + export * from './form_providers'; diff --git a/tools/public_api_guard/forms/index.d.ts b/tools/public_api_guard/forms/index.d.ts index 25272cf3c9..55d1e7bca5 100644 --- a/tools/public_api_guard/forms/index.d.ts +++ b/tools/public_api_guard/forms/index.d.ts @@ -58,6 +58,10 @@ export declare abstract class AbstractControlDirective { valueChanges: Observable; } +export interface AsyncValidatorFn { + (c: AbstractControl): any; +} + export declare class CheckboxControlValueAccessor implements ControlValueAccessor { onChange: (_: any) => void; onTouched: () => void; @@ -327,6 +331,12 @@ export interface Validator { }; } +export interface ValidatorFn { + (c: AbstractControl): { + [key: string]: any; + }; +} + export declare class Validators { static compose(validators: ValidatorFn[]): ValidatorFn; static composeAsync(validators: AsyncValidatorFn[]): AsyncValidatorFn;