minLength
Validate that a string has at least N characters.
Signature
NguardValidators.String.minLength(n: number): ValidatorFn
| Parameter | Type | Description |
|---|---|---|
n | number | Minimum required length |
Reactive forms
import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const password = new FormControl('', [NguardValidators.String.minLength(8)]);
Template-driven forms
<input ngModel name="password" type="password" [nguardMinLength]="8" />
Error key
{ minLength: true }
Notes
- The check is
>=(inclusive).minLength(8)accepts length 8. null,undefined, non-string inputs all fail.- Whitespace counts toward length — pair with
notBlankif needed.