Humanizr/Humanizer · error · InvalidOperationException
Indian scale-form number profiles require a scale value cove
Error message
Indian scale-form number profiles require a scale value covered by the dense unit map range.
What it means
Profile constructor validation: the scales array must be non-empty and its smallest (last) scale Value must not exceed the dense unit map count. Thrown at instantiation when scales are empty or the lowest scale starts above where dense words end, leaving an uncovered gap.
Source
Thrown at src/Humanizer/Localisation/NumberToWords/IndianScaleFormNumberToWordsConverter.cs:153
public FrozenDictionary<int, string> OrdinalMap { get; } = ordinalMap ?? FrozenDictionary<int, string>.Empty;
/// <summary>Gets terminal cardinal-token replacements used to form ordinals.</summary>
public FrozenDictionary<string, string> OrdinalTerminalReplacements { get; } = ordinalTerminalReplacements ?? FrozenDictionary<string, string>.Empty;
static string[] ValidateDenseUnitsMap(string[] value)
{
if (value.Length < 100)
{
throw new InvalidOperationException("Indian scale-form number profiles require dense words for 0 through 99.");
}
return value;
}
static IndianScaleForm[] ValidateScales(IndianScaleForm[] value, int denseUnitCount)
{
if (value.Length == 0 || value[^1].Value > denseUnitCount)
{
throw new InvalidOperationException("Indian scale-form number profiles require a scale value covered by the dense unit map range.");
}
for (var i = 0; i < value.Length; i++)
{
if (value[i].Value <= 0)
{
throw new InvalidOperationException("Indian scale-form number profiles require positive scale values.");
}
if (i > 0 && value[i - 1].Value <= value[i].Value)
{
throw new InvalidOperationException("Indian scale-form number profiles require scales in descending order.");
}
}
return value;
}
}View on GitHub (pinned to ffc2b77c0f)
Solutions
- Report the locale bug — scales are missing or start above the dense range.
- Use a locale with a complete scale table.
- If authoring, ensure scales are non-empty and the smallest scale Value <= dense map length.
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("scale value covered by the dense unit map range"))
{
words = value.ToWords(CultureInfo.InvariantCulture);
} Prevention
- Smoke-test converter resolution per locale at startup.
- Report empty/misaligned scale tables upstream.
- Pin consistent Humanizer versions.
When it happens
Trigger: First converter use for an IndianScaleForm culture whose scales array is empty or whose value[^1].Value > denseUnitsMap.Length.
Common situations: Locale YAML missing scales entirely, or scales whose lowest value sits above the dense map ceiling.
Related errors
- Indian scale-form number profiles require dense words for 0
- Indian scale-form number profiles require positive scale val
- Indian scale-form number profiles require scales in descendi
- Linked-vigesimal number profiles require at least a zero wor
- Linked-vigesimal number profiles require positive scale valu
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/ab0d4e9c4316dd3e.
Report an issue: GitHub.