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

Function maxLengthValidator

packages/forms/src/validators.ts:555–563  ·  view source on GitHub ↗
(maxLength: number)

Source from the content-addressed store, hash-verified

553 * For example, the object {id: 1, length: 0, width: 0} should be validated.
554 */
555export function maxLengthValidator(maxLength: number): ValidatorFn {
556 return (control: AbstractControl): ValidationErrors | null => {
557 const length = control.value?.length ?? lengthOrSize(control.value);
558 if (length !== null && length > maxLength) {
559 return {'maxlength': {'requiredLength': maxLength, 'actualLength': length}};
560 }
561 return null;
562 };
563}
564
565/**
566 * Validator that requires the control's value to match a regex pattern.

Callers 2

MaxLengthValidatorClass · 0.90
maxLengthMethod · 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…