{"record":{"id":"7c3dcad99a5ab81a","repo":"Humanizr/Humanizer","slug":"the-configured-profile-supports-values-from-profi","errorCode":null,"errorMessage":"The configured profile supports values from {profile.MinimumValue} through {profile.MaximumValue}.","messagePattern":"The configured profile supports values from (.+?) through (.+?)\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/NumberToWords/HarmonyOrdinalNumberToWordsConverter.cs","lineNumber":32,"sourceCode":"/// </summary>\nclass HarmonyOrdinalNumberToWordsConverter(HarmonyOrdinalNumberToWordsProfile profile) : GenderlessNumberToWordsConverter\n{\n    /// <summary>\n    /// Immutable generated profile that owns the decimal-scale lexicon and harmony rules.\n    /// </summary>\n    readonly HarmonyOrdinalNumberToWordsProfile profile = profile;\n\n    /// <summary>\n    /// Converts the given value using the locale's harmony-based cardinal rules.\n    /// </summary>\n    /// <param name=\"input\">The number to convert.</param>\n    /// <returns>The localized cardinal words for <paramref name=\"input\"/>.</returns>\n    /// <exception cref=\"ArgumentOutOfRangeException\"><paramref name=\"input\"/> is outside the configured profile range.</exception>\n    public override string Convert(long input)\n    {\n        if (input > profile.MaximumValue || input < profile.MinimumValue)\n        {\n            throw new ArgumentOutOfRangeException(\n                nameof(input),\n                input,\n                $\"The configured profile supports values from {profile.MinimumValue} through {profile.MaximumValue}.\");\n        }\n\n        // The cardinal path shares one recursive engine for all supported magnitudes; the\n        // profile decides the exact hundred behavior. Keeping the sign outside the magnitude\n        // decomposition makes long.MinValue representable without overflowing.\n        var words = ConvertCore(GetAbsoluteValue(input), allowExactHundredWord: true);\n        return input < 0 ? $\"{profile.MinusWord} {words}\" : words;\n    }\n\n    // Composite counts recurse through the same decimal-scale engine; only the generated\n    // hundred/ordinal strategies vary per locale.\n    /// <summary>\n    /// Converts a number using the shared decimal decomposition while honoring the requested\n    /// exact-hundred behavior.\n    /// </summary>","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/NumberToWords/HarmonyOrdinalNumberToWordsConverter.cs#L14-L50","documentation":"Turkic-family locales bound to the harmony-based converter (e.g. kk, ky, tr, uz) declare an authored [MinimumValue, MaximumValue] range reflecting how many scales the locale actually has words for. Values outside that range throw ArgumentOutOfRangeException before decomposition. The range is a property of the generated profile, not a fixed library constant.","triggerScenarios":"value.ToWords(new CultureInfo(\"ky\")) where value > profile.MaximumValue or value < profile.MinimumValue. Fires at the top of Convert(long).","commonSituations":"Converting very large longs (population figures, astronomical values, IDs) under a Turkic culture whose authored scales stop at millions or billions.","solutions":["Route out-of-range values to a culture with a higher ceiling (e.g. invariant/English) for that conversion.","Clamp or reject oversized inputs in your own layer.","Contribute authored higher scales to the locale profile to raise MaximumValue."],"exampleFix":"// before\nvar w = value.ToWords(new CultureInfo(\"tr\"));\n\n// after — fall back for oversized values (ceiling is locale-specific, so wrap defensively)\nstring w;\ntry\n{\n    w = value.ToWords(new CultureInfo(\"tr\"));\n}\ncatch (ArgumentOutOfRangeException)\n{\n    w = value.ToWords(CultureInfo.InvariantCulture);\n}","handlingStrategy":"try-catch","validationCode":"// MaximumValue/MinimumValue are not public, so a direct pre-check is unavailable.\n// For Turkic locales, wrap the call and fall back on ArgumentOutOfRangeException:\n// (see tryCatchPattern)","typeGuard":null,"tryCatchPattern":"string words;\ntry\n{\n    words = value.ToWords(new CultureInfo(\"tr\"));\n}\ncatch (ArgumentOutOfRangeException)\n{\n    words = value.ToWords(CultureInfo.InvariantCulture);\n}","preventionTips":["Record each Turkic locale's effective ceiling from the locale docs/tests.","Bound user-facing numeric inputs before localizing them.","Fall back to a high-ceiling culture for values likely to exceed authored scales."],"tags":["number-to-words","localization","range-check"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}