fix(forms): accept number length in length validators (#32057)

Both `MinLengthValidator` and `MaxLengthValidator` accepted only string inputs for the length required, which throws with Ivy and `fullTemplateTypeCheck` enabled:

    <!-- min = 2 in the component -->
    <input [minlength]="min">

with:

    Type 'number' is not assignable to type 'string | undefined'

This relaxes the accepted type to `string | number` to avoid breakage when developers switch to Ivy and fTTC.

PR Close #32057
This commit is contained in:
cexbrayat
2019-08-08 19:19:41 +02:00
committed by atscott
parent e100bbc696
commit 3113bb7ad2
2 changed files with 9 additions and 7 deletions

View File

@ -330,14 +330,14 @@ export declare class FormsModule {
}
export declare class MaxLengthValidator implements Validator, OnChanges {
maxlength: string;
maxlength: string | number;
ngOnChanges(changes: SimpleChanges): void;
registerOnValidatorChange(fn: () => void): void;
validate(control: AbstractControl): ValidationErrors | null;
}
export declare class MinLengthValidator implements Validator, OnChanges {
minlength: string;
minlength: string | number;
ngOnChanges(changes: SimpleChanges): void;
registerOnValidatorChange(fn: () => void): void;
validate(control: AbstractControl): ValidationErrors | null;