{"record":{"id":"66c4f951de5d703f","repo":"Humanizr/Humanizer","slug":"value-cannot-be-empty-or-whitespace","errorCode":null,"errorMessage":"Value cannot be empty or whitespace.","messagePattern":"Value cannot be empty or whitespace\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/PluralizationForms.cs","lineNumber":173,"sourceCode":"        {\n            CardinalPluralCategory.Other => Other,\n            CardinalPluralCategory.Zero => Zero,\n            CardinalPluralCategory.One => One,\n            CardinalPluralCategory.Two => Two,\n            CardinalPluralCategory.Few => Few,\n            CardinalPluralCategory.Many => Many,\n            _ => throw new ArgumentOutOfRangeException(nameof(category))\n        };\n\n        return form is not null;\n    }\n\n    static string RequireForm(string value, string parameterName)\n    {\n        ArgumentNullException.ThrowIfNull(value, parameterName);\n        if (string.IsNullOrWhiteSpace(value))\n        {\n            throw new ArgumentException(\"Value cannot be empty or whitespace.\", parameterName);\n        }\n\n        return value;\n    }\n\n    static string? ValidateOptionalForm(string? value, string parameterName)\n    {\n        if (value is not null && string.IsNullOrWhiteSpace(value))\n        {\n            throw new ArgumentException(\"Value cannot be empty or whitespace.\", parameterName);\n        }\n\n        return value;\n    }\n\n    static bool Matches(string normalized, string? candidate) =>\n        candidate is not null &&\n        string.Equals(normalized, Normalize(candidate), StringComparison.Ordinal);","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/PluralizationForms.cs#L155-L191","documentation":"Thrown by the PluralizationForms constructor when the 'singular' or 'other' argument is empty or whitespace-only. These two forms are mandatory for every pluralization entry because the CLDR plural rules always resolve to at least one of them. An empty required form would produce broken output.","triggerScenarios":"Constructing new PluralizationForms(\"\", \"words\") or new PluralizationForms(\"word\", \"  \"). The RequireForm helper is called on the first two positional parameters.","commonSituations":"Loading pluralization data from a YAML/JSON file where a required field is blank. Building PluralizationForms dynamically from user input without trimming/validation. Migrating locale data with a missing 'other' key.","solutions":["Validate that singular and other are non-blank before constructing PluralizationForms.","Check your locale data source for empty or whitespace-only required fields.","Provide sensible defaults (e.g. the singular form as 'other') when data is missing."],"exampleFix":"// before\nvar forms = new PluralizationForms(singular, other);\n\n// after\nif (string.IsNullOrWhiteSpace(singular) || string.IsNullOrWhiteSpace(other))\n    throw new InvalidOperationException(\"Pluralization data is incomplete.\");\nvar forms = new PluralizationForms(singular, other);","handlingStrategy":"validation","validationCode":"static void ValidateRequiredForms(string singular, string other)\n{\n    if (string.IsNullOrWhiteSpace(singular))\n        throw new InvalidOperationException(\"singular is required\");\n    if (string.IsNullOrWhiteSpace(other))\n        throw new InvalidOperationException(\"other is required\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate locale data at load time, not at construction time.","Use data annotations or schema validation on locale YAML/JSON.","Log which field is blank to speed up diagnosis."],"tags":["pluralization","argument-validation","constructor"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}