Skip to main content
Version: 0.10.0

maxDigits

Validate that an integer has at most N digits.

Signature​

NguardValidators.Number.maxDigits(n: number): ValidatorFn
ParameterTypeDescription
nnumberMaximum 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​