Skip to main content

minDigits

Validate that an integer has at least N digits.

Signature

NguardValidators.Number.minDigits(n: number): ValidatorFn
ParameterTypeDescription
nnumberMinimum required digit count

Reactive forms

import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';

const id = new FormControl('', [NguardValidators.Number.minDigits(4)]);

Template-driven forms

<input ngModel name="id" [nguardMinDigits]="4" />

Error key

{ minDigits: true }

Notes

  • The check is >= (inclusive).
  • The value must be an integer. Floats fail.
  • Sign is excluded from the count.

See also