Function isNaturalNumberString

  • Validate a natural number string

    Parameters

    • input: unknown

      The raw input

    Returns Validated<number>

    Example

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

    isNaturalNumberString("") >>
    {
    valid: false,
    error: 'Not a number: ""',
    };

    isNaturalNumberString("0.5") >>
    {
    valid: false,
    error: 'Not an integer: "0.5"',
    };

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