{"record":{"id":"d1cae9fa3f11a974","repo":"Humanizr/Humanizer","slug":"inverted-tens-token-property-name-must-map-to","errorCode":null,"errorMessage":"Inverted tens token '{property.Name}' must map to an integer value.","messagePattern":"Inverted tens token '(.+?)' must map to an integer value\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs","lineNumber":1227,"sourceCode":"    }\n\n    static string CreateInvertedTensTokenArrayExpression(JsonElement arrayElement)\n    {\n        if (arrayElement.ValueKind is not (JsonValueKind.Array or JsonValueKind.Object))\n        {\n            throw new InvalidOperationException(\"Expected JSON array or mapping.\");\n        }\n\n        var builder = new StringBuilder(\"new InvertedTensToken[] { \");\n        var first = true;\n\n        if (arrayElement.ValueKind == JsonValueKind.Object)\n        {\n            foreach (var (Name, Value) in arrayElement.EnumerateObject()\n                         .Select(static property =>\n                         {\n                             return property.Value.ValueKind != JsonValueKind.Number || !property.Value.TryGetInt64(out var value)\n                                 ? throw new InvalidOperationException($\"Inverted tens token '{property.Name}' must map to an integer value.\")\n                                 : (property.Name, Value: value);\n                         })\n                         .OrderByDescending(static entry => entry.Value)\n                         .ThenBy(static entry => entry.Name, StringComparer.Ordinal))\n            {\n                if (!first)\n                {\n                    builder.Append(\", \");\n                }\n\n                builder.Append(\"new(\");\n                builder.Append(QuoteLiteral(Name));\n                builder.Append(\", \");\n                builder.Append(Value.ToString(CultureInfo.InvariantCulture));\n                builder.Append(')');\n                first = false;\n            }\n        }","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs#L1209-L1245","documentation":"Thrown while building an InvertedTensToken[] when the YAML node is a mapping but one of its values is not an integer. The builder maps each token name to an integer base value; a non-numeric value (or a number that fails TryGetInt64) cannot be turned into the token's numeric component.","triggerScenarios":"A locale YAML defines the inverted-tens section as a mapping where at least one entry's value is a string, boolean, or a non-integer number. The Select lambda checks ValueKind and TryGetInt64, then throws naming the offending property (the token string).","commonSituations":"A contributor adds a token but leaves its value as a word (e.g. 'einundzwanzig: einundzwanzig') instead of the integer 21, or uses a float. The build-time generator output names the specific token that is wrong.","solutions":["In the inverted-tens mapping, set each token's value to an integer literal (no quotes): einundzwanzig: 21.","Ensure no value is a string, boolean, or decimal that cannot be parsed as int64.","Rebuild; the generator will name the first offending token if others remain."],"exampleFix":"# before\ninvertedTens:\n  einundzwanzig: 'einundzwanzig'\n# after\ninvertedTens:\n  einundzwanzig: 21","handlingStrategy":"validation","validationCode":"# For every key in the inverted-tens mapping, the value must be an integer.\n#   rg -B1 -A1 \"invertedTens\" src/Humanizer/Locales/<code>.yml\n# Each token line should read '<token>: <integer>' with an unquoted number.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use unquoted integer values for inverted-tens token magnitudes.","Never reuse the token word as its own value.","Build locally so the generator names the first offending token."],"tags":["source-generator","locale-yaml","configuration","build-time","humanizer"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}