@@ -306,7 +306,7 @@ export class Validators {
306
306
307
307
/**
308
308
* @description
309
- * Validator that requires the length of the control's value to be greater than or equal
309
+ * Validator that requires the number of items in the control's value to be greater than or equal
310
310
* to the provided minimum length. This validator is also provided by default if you use
311
311
* the HTML5 `minlength` attribute. Note that the `minLength` validator is intended to be used
312
312
* only for types that have a numeric `length` or `size` property, such as strings, arrays or
@@ -341,7 +341,7 @@ export class Validators {
341
341
342
342
/**
343
343
* @description
344
- * Validator that requires the length of the control's value to be less than or equal
344
+ * Validator that requires the number of items in the control's value to be less than or equal
345
345
* to the provided maximum length. This validator is also provided by default if you use
346
346
* the HTML5 `maxlength` attribute. Note that the `maxLength` validator is intended to be used
347
347
* only for types that have a numeric `length` or `size` property, such as strings, arrays or
@@ -529,33 +529,33 @@ export function emailValidator(control: AbstractControl): ValidationErrors | nul
529
529
}
530
530
531
531
/**
532
- * Validator that requires the length of the control's value to be greater than or equal
532
+ * Validator that requires the number of items in the control's value to be greater than or equal
533
533
* to the provided minimum length. See `Validators.minLength` for additional information.
534
534
*/
535
535
export function minLengthValidator ( minLength : number ) : ValidatorFn {
536
536
return ( control : AbstractControl ) : ValidationErrors | null => {
537
- const _length = lengthOrSize ( control . value ) ;
538
- if ( isEmptyInputValue ( control . value ) || ! _length ) {
537
+ const length = lengthOrSize ( control . value ) ;
538
+ if ( isEmptyInputValue ( control . value ) || ! length ) {
539
539
// don't validate empty values to allow optional controls
540
540
// don't validate values without `length` or `size` property
541
541
return null ;
542
542
}
543
543
544
- return _length < minLength
545
- ? { 'minlength' : { 'requiredLength' : minLength , 'actualLength' : _length } }
544
+ return length < minLength
545
+ ? { 'minlength' : { 'requiredLength' : minLength , 'actualLength' : length } }
546
546
: null ;
547
547
} ;
548
548
}
549
549
550
550
/**
551
- * Validator that requires the length of the control's value to be less than or equal
551
+ * Validator that requires the number of items in the control's value to be less than or equal
552
552
* to the provided maximum length. See `Validators.maxLength` for additional information.
553
553
*/
554
554
export function maxLengthValidator ( maxLength : number ) : ValidatorFn {
555
555
return ( control : AbstractControl ) : ValidationErrors | null => {
556
- const _length = lengthOrSize ( control . value ) ;
557
- if ( _length !== null && _length > maxLength ) {
558
- return { 'maxlength' : { 'requiredLength' : maxLength , 'actualLength' : _length } } ;
556
+ const length = lengthOrSize ( control . value ) ;
557
+ if ( length !== null && length > maxLength ) {
558
+ return { 'maxlength' : { 'requiredLength' : maxLength , 'actualLength' : length } } ;
559
559
}
560
560
return null ;
561
561
} ;
0 commit comments