Skip to content

Commit 65432b7

Browse files
committed
fixup! feat(forms): support type set in form validators
1 parent e82a0ef commit 65432b7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/forms/src/validators.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class Validators {
306306

307307
/**
308308
* @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
310310
* to the provided minimum length. This validator is also provided by default if you use
311311
* the HTML5 `minlength` attribute. Note that the `minLength` validator is intended to be used
312312
* only for types that have a numeric `length` or `size` property, such as strings, arrays or
@@ -341,7 +341,7 @@ export class Validators {
341341

342342
/**
343343
* @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
345345
* to the provided maximum length. This validator is also provided by default if you use
346346
* the HTML5 `maxlength` attribute. Note that the `maxLength` validator is intended to be used
347347
* 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
529529
}
530530

531531
/**
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
533533
* to the provided minimum length. See `Validators.minLength` for additional information.
534534
*/
535535
export function minLengthValidator(minLength: number): ValidatorFn {
536536
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) {
539539
// don't validate empty values to allow optional controls
540540
// don't validate values without `length` or `size` property
541541
return null;
542542
}
543543

544-
return _length < minLength
545-
? {'minlength': {'requiredLength': minLength, 'actualLength': _length}}
544+
return length < minLength
545+
? {'minlength': {'requiredLength': minLength, 'actualLength': length}}
546546
: null;
547547
};
548548
}
549549

550550
/**
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
552552
* to the provided maximum length. See `Validators.maxLength` for additional information.
553553
*/
554554
export function maxLengthValidator(maxLength: number): ValidatorFn {
555555
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}};
559559
}
560560
return null;
561561
};

0 commit comments

Comments
 (0)