Skip to content

Commit

Permalink
feat(forms): expose ValidatorFn and AsyncValidatorFn
Browse files Browse the repository at this point in the history
Closes #8834
  • Loading branch information
kara committed Jun 25, 2016
1 parent 40b907a commit 17dcbf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/@angular/forms/src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
10 changes: 10 additions & 0 deletions tools/public_api_guard/forms/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export declare abstract class AbstractControlDirective {
valueChanges: Observable<any>;
}

export interface AsyncValidatorFn {
(c: AbstractControl): any;
}

export declare class CheckboxControlValueAccessor implements ControlValueAccessor {
onChange: (_: any) => void;
onTouched: () => void;
Expand Down Expand Up @@ -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;
Expand Down

1 comment on commit 17dcbf6

@SaraSlm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, i wanna write my own validator in rc5 (i know it in rc4)but i don't know how:( can you help to explain for me how can i do this please?

Please sign in to comment.