integer
Validate that a value is an integer (whole number, no fractional part).
Signature
NguardValidators.Number.integer: ValidatorFn
A parameterless validator — used directly without invocation.
Reactive forms
import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const age = new FormControl('', [NguardValidators.Number.integer]);
Template-driven forms
<input ngModel name="age" nguardInteger />
Error key
{ integer: true }
Notes
- Accepts integers and integer-like numeric strings (
'42','-5','0'). - Rejects floats (
3.14,'3.14'),null,undefined, empty string,NaN,Infinity, non-numeric strings. - Numeric coercion applies — strings are tried as numbers first, then checked with
Number.isInteger.