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