Humanizr/Humanizer · error · InvalidOperationException

Linked-vigesimal number profiles require positive scale valu

Error message

Linked-vigesimal number profiles require positive scale values.

What it means

Profile constructor validation: every scale Value must be strictly positive (> 0). A non-positive scale value is rejected at instantiation.

Source

Thrown at src/Humanizer/Localisation/NumberToWords/LinkedVigesimalNumberToWordsConverter.cs:192

    }

    static string[] ValidateWords(string[] value)
    {
        if (value.Length == 0)
        {
            throw new InvalidOperationException("Linked-vigesimal number profiles require at least a zero word.");
        }

        return value;
    }

    static LinkedVigesimalScale[] ValidateScales(LinkedVigesimalScale[] value)
    {
        for (var i = 0; i < value.Length; i++)
        {
            if (value[i].Value <= 0)
            {
                throw new InvalidOperationException("Linked-vigesimal number profiles require positive scale values.");
            }

            if (i > 0 && value[i - 1].Value <= value[i].Value)
            {
                throw new InvalidOperationException("Linked-vigesimal number profiles require descending scales.");
            }
        }

        return value;
    }
}

/// <summary>
/// One descending scale row for linked-vigesimal renderers and parsers.
/// </summary>
/// <param name="Value">The numeric scale value.</param>
/// <param name="One">The exact singular scale phrase.</param>
/// <param name="OneWithRemainder">The singular scale phrase when followed by a lower-order remainder.</param>

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Report the locale bug — a scale value is non-positive.
  2. Use a locale with correct scale values.
  3. If authoring, fix the offending scale Value to a positive integer.
Defensive patterns

Strategy: try-catch

Validate before calling

// Construction-time validation; no public pre-check. Isolate converter resolution per culture.

Try / catch

string words;
try
{
    words = value.ToWords(culture);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("positive scale values"))
{
    words = value.ToWords(CultureInfo.InvariantCulture);
}

Prevention

When it happens

Trigger: First converter use for a linked-vigesimal culture whose scale data includes a Value <= 0.

Common situations: Locale YAML typo entering 0 or a negative scale value.

Related errors


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/c0e90e5eb7441202. Report an issue: GitHub.