fix(forms): fix Validators.min/maxLength with FormArray (#13095)
Fixes #13089
This commit is contained in:
committed by
Victor Berchet
parent
2e500cc85b
commit
e9f307f948
@@ -72,7 +72,7 @@ export class Validators {
|
||||
if (isEmptyInputValue(control.value)) {
|
||||
return null; // don't validate empty values to allow optional controls
|
||||
}
|
||||
const length = typeof control.value === 'string' ? control.value.length : 0;
|
||||
const length: number = control.value ? control.value.length : 0;
|
||||
return length < minLength ?
|
||||
{'minlength': {'requiredLength': minLength, 'actualLength': length}} :
|
||||
null;
|
||||
@@ -84,7 +84,7 @@ export class Validators {
|
||||
*/
|
||||
static maxLength(maxLength: number): ValidatorFn {
|
||||
return (control: AbstractControl): {[key: string]: any} => {
|
||||
const length = typeof control.value === 'string' ? control.value.length : 0;
|
||||
const length: number = control.value ? control.value.length : 0;
|
||||
return length > maxLength ?
|
||||
{'maxlength': {'requiredLength': maxLength, 'actualLength': length}} :
|
||||
null;
|
||||
|
||||
Reference in New Issue
Block a user