Skip to main content

positive

Validate that a numeric value is strictly greater than zero.

Signature

NguardValidators.Number.positive: ValidatorFn

A parameterless validator — used directly without invocation.

Reactive forms

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

const amount = new FormControl('', [NguardValidators.Number.positive]);

Template-driven forms

<input ngModel name="amount" nguardPositive />

Error key

{ positive: true }

Notes

  • The check is strict (> 0). Zero fails.
  • Numeric strings work — '5' passes; '0' fails.
  • null, undefined, empty string, NaN, Infinity all fail.

See also

  • negative — symmetric counterpart
  • min — pass min(0) if you want to allow zero (>= 0 instead of > 0)