fix(forms): fix Validators.min/maxLength with FormArray (#13095)

Fixes #13089
This commit is contained in:
Dzmitry Shylovich
2016-12-12 22:17:12 +03:00
committed by Victor Berchet
parent 65c9b5b6aa
commit 7383e4a801
3 changed files with 27 additions and 7 deletions

View File

@ -36,10 +36,6 @@ export const PENDING = 'PENDING';
*/
export const DISABLED = 'DISABLED';
export function isControl(control: Object): boolean {
return control instanceof AbstractControl;
}
function _find(control: AbstractControl, path: Array<string|number>| string, delimiter: string) {
if (path == null) return null;

View File

@ -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;