max
Validate that a numeric value is less than or equal to a literal maximum.
Signature
NguardValidators.Number.max(maxVal: number): ValidatorFn
| Parameter | Type | Description |
|---|---|---|
maxVal | number | Inclusive maximum allowed value |
Reactive forms
import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const quantity = new FormControl('', [NguardValidators.Number.max(100)]);
Template-driven forms
<input ngModel name="quantity" [nguardMax]="100" />
Error key
{ max: true }
Notes
- The check is
<=(inclusive).max(100)accepts100. - Numeric strings work —
'100'passesmax(100). null,undefined, empty string,NaN,Infinityall fail.
See also
min— lower-bound counterpartbetween— both bounds in one validatorlesserThanOrEqual— same operator but compares against a sibling field instead of a literal