MCPcopy Index your code
hub / github.com/angular/angular / minLengthValidator

Function minLengthValidator

packages/forms/src/validators.ts:533–546  ·  view source on GitHub ↗
(minLength: number)

Source from the content-addressed store, hash-verified

531 * For example, the object {id: 1, length: 0, width: 0} should be validated.
532 */
533export function minLengthValidator(minLength: number): ValidatorFn {
534 return (control: AbstractControl): ValidationErrors | null => {
535 const length = control.value?.length ?? lengthOrSize(control.value);
536 if (length === null || length === 0) {
537 // don't validate empty values to allow optional controls
538 // don't validate values without `length` or `size` property
539 return null;
540 }
541
542 return length < minLength
543 ? {'minlength': {'requiredLength': minLength, 'actualLength': length}}
544 : null;
545 };
546}
547
548/**
549 * Validator that requires the number of items in the control's value to be less than or equal

Callers 2

MinLengthValidatorClass · 0.90
minLengthMethod · 0.85

Calls 1

lengthOrSizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…