(maxLength: number)
| 553 | * For example, the object {id: 1, length: 0, width: 0} should be validated. |
| 554 | */ |
| 555 | export 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. |
no test coverage detected
searching dependent graphs…