greaterThanOrEqual
Validate that a numeric value is greater than or equal to another field's numeric value.
Signature
NguardValidators.Number.greaterThanOrEqual(fieldKey: string): ValidatorFn
| Parameter | Type | Description |
|---|---|---|
fieldKey | string | The key of the sibling field to compare against |
Reactive forms
import { FormControl, FormGroup } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const range = new FormGroup({
floor: new FormControl(0),
ceiling: new FormControl(0, [
NguardValidators.Number.greaterThanOrEqual('floor'),
]),
});
Template-driven forms
<input ngModel name="floor" type="number" />
<input ngModel name="ceiling" type="number" [nguardGreaterThanOrEqual]="'floor'" />
Error key
{ greaterThanOrEqual: true }
Notes
- The check is
>=(inclusive). Equal values pass. - Both fields must be numeric — non-numeric inputs (including a non-numeric sibling) cause failure.
- If the control has no parent form group, the validator fails.
- Numeric strings are accepted on both sides.
See also
greaterThan— strict variantlesserThanOrEqual— opposite directionmin— same operator but compares to a literal, not a sibling