Humanizr/Humanizer · error · InvalidOperationException

Linked-vigesimal number profiles require descending scales.

Error message

Linked-vigesimal number profiles require descending scales.

What it means

Profile constructor validation: scale rows must be in strictly descending Value order. Non-descending adjacent values (value[i-1].Value <= value[i].Value) are rejected at instantiation.

Source

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

        {
            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>
/// <param name="Name">The scale noun used with generated counts.</param>
/// <param name="NameWithRemainder">The scale noun used with generated counts when followed by a lower-order remainder.</param>
/// <param name="CountJoiner">The joiner between scale noun and generated count.</param>
/// <param name="CountOverrides">Exact scale-count phrases keyed by count.</param>
/// <param name="CountOverridesWithRemainder">Exact scale-count phrases keyed by count when followed by a lower-order remainder.</param>

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Report the locale bug — scales are not strictly descending.
  2. Use a locale with correctly ordered scales.
  3. If authoring, order scale rows by descending Value with no duplicates.
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("descending scales"))
{
    words = value.ToWords(CultureInfo.InvariantCulture);
}

Prevention

When it happens

Trigger: First converter use for a linked-vigesimal culture whose scales are not strictly descending.

Common situations: Locale YAML listing scales in the wrong order, or duplicate scale values.

Related errors


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