{"record":{"id":"fe553dd847f9dfcb","repo":"Humanizr/Humanizer","slug":"inflection-quantityselector-exact-numeric-singlet-fe553d","errorCode":null,"errorMessage":"Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display.","messagePattern":"Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs","lineNumber":179,"sourceCode":"                ? ExactNumericSingletonSelector\n                : throw new InvalidOperationException(\n                    \"Inflection defines unsupported quantity selector; expected 'exact-numeric-singleton'.\");\n        }\n\n        static void ValidateQuantitySelector(\n            SimpleYamlMapping mapping,\n            string cardinalRule,\n            string? quantitySelector,\n            ImmutableArray<InflectionLexemeInput> lexemes,\n            ImmutableArray<InflectionRuleInput> rules)\n        {\n            var hasOptedLexeme = lexemes.Any(static lexeme =>\n                lexeme.Display.ContainsKey(\"one\"));\n            if (quantitySelector is not null)\n            {\n                if (!hasOptedLexeme)\n                {\n                    throw new InvalidOperationException(\n                        \"Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display.\");\n                }\n\n                if (rules.Any(static rule => rule.Display.ContainsKey(\"one\")))\n                {\n                    throw new InvalidOperationException(\n                        \"Inflection quantitySelector 'exact-numeric-singleton' cannot select productive rule display.\");\n                }\n\n                return;\n            }\n\n            if (!IsCategoryReachable(mapping, cardinalRule, \"one\") &&\n                (hasOptedLexeme ||\n                 rules.Any(static rule => rule.Display.ContainsKey(\"one\"))))\n            {\n                throw new InvalidOperationException(\n                    \"Inflection display category 'one' is unreachable without quantitySelector 'exact-numeric-singleton'.\");","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs#L161-L197","documentation":"When 'quantitySelector: exact-numeric-singleton' is active, the selector picks the 'one' display category, so at least one lexeme must author a 'display.one' form. ValidateQuantitySelector throws when the selector is set but no lexeme has an authored 'one' display, because the selector would have nothing to select.","triggerScenarios":"quantitySelector is set to 'exact-numeric-singleton' but every lexeme's 'forms.display' omits the 'one' category (only 'other' or other categories are present).","commonSituations":"Enabling the selector on a locale whose lexemes only declare 'other'; deleting the lexeme that was the sole provider of the 'one' display; forgetting to add the 'one:' block when enabling the selector.","solutions":["Add a 'display.one' block (preferred + accepted) to at least one lexeme","Remove the quantitySelector if the locale's cardinal rule already reaches 'one' via its CLDR rule"],"exampleFix":"# before\n          display:\n            other:\n              preferred: 'cat'\n              accepted:\n                - 'cat'\n# after\n          display:\n            one:\n              preferred: 'cat'\n              accepted:\n                - 'cat'\n            other:\n              preferred: 'cats'\n              accepted:\n                - 'cats'","handlingStrategy":"validation","validationCode":"// Given parsed lexemes and an active quantitySelector:\nbool selectorSet = m.GetScalar(\"quantitySelector\") == \"exact-numeric-singleton\";\nbool anyOne = lexemes.Any(l => l.Forms.Display.ContainsKey(\"one\"));\nif (selectorSet && !anyOne)\n    Report($\"{locale}: add a lexeme display.one or drop quantitySelector.\");","typeGuard":"static bool SelectorHasOneDisplay(\n    bool selectorSet, IEnumerable<Lexeme> lexemes) =>\n    !selectorSet || lexemes.Any(l => l.Display.ContainsKey(\"one\"));","tryCatchPattern":null,"preventionTips":["When enabling the selector, immediately add display.one to the first lexeme","Mirror the ExactNumericSingletonInflectionFixture shape"],"tags":["inflection","localization","yaml","source-generator","locale","validation"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}