maxDigits
Validate that an integer has at most N digits.
Signature
NguardValidators.Number.maxDigits(n: number): ValidatorFn
| Parameter | Type | Description |
|---|---|---|
n | number | Maximum allowed digit count |
Reactive forms
import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const code = new FormControl('', [NguardValidators.Number.maxDigits(6)]);
Template-driven forms
<input ngModel name="code" [nguardMaxDigits]="6" />
Error key
{ maxDigits: true }
Notes
- The check is
<=(inclusive). - The value must be an integer. Floats fail.
- Sign is excluded from the count.
See also
minDigits— lower-bound counterpartdigitsBetween— both bounds in one validatordigits— exact digit count