Skip to main content

odd

Validate that a value is an odd integer.

Signature

NguardValidators.Number.odd: ValidatorFn

A parameterless validator — used directly without invocation.

Reactive forms

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

const cardsInHand = new FormControl('', [NguardValidators.Number.odd]);

Template-driven forms

<input ngModel name="cardsInHand" nguardOdd />

Error key

{ odd: true }

Notes

  • Zero is not odd.
  • Negative odd integers pass (-3, -1).
  • Non-integers fail — odd requires both numeric and integer.
  • Numeric strings work — '3' passes.

See also

  • even — symmetric counterpart
  • integer — without parity constraint