Function isNaturalNumber

  • Validate a natural number

    Parameters

    • input: unknown

      The raw input

    Returns Validated<number>

    Example

    isNaturalNumber(1) >>
    {
    valid: true,
    parsed: 1,
    };

    isNaturalNumber(0) >>
    {
    valid: false,
    error: "Not a natural number: 0",
    };