{"record":{"id":"935ec4faa86c1ef4","repo":"iOfficeAI/OfficeCLI","slug":"unknown-operator-dvop","errorCode":null,"errorMessage":"Unknown operator: {dvOp}","messagePattern":"Unknown operator: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Tables.cs","lineNumber":558,"sourceCode":"                \"textlength\" => DataValidationValues.TextLength,\n                \"custom\" => DataValidationValues.Custom,\n                _ => throw new ArgumentException($\"Unknown validation type: {dvType}. Use: list, whole, decimal, date, time, textLength, custom\")\n            };\n        }\n\n        if (properties.TryGetValue(\"operator\", out var dvOp))\n        {\n            dv.Operator = dvOp.ToLowerInvariant() switch\n            {\n                \"between\" => DataValidationOperatorValues.Between,\n                \"notbetween\" => DataValidationOperatorValues.NotBetween,\n                \"equal\" => DataValidationOperatorValues.Equal,\n                \"notequal\" => DataValidationOperatorValues.NotEqual,\n                \"greaterthan\" => DataValidationOperatorValues.GreaterThan,\n                \"lessthan\" => DataValidationOperatorValues.LessThan,\n                \"greaterthanorequal\" => DataValidationOperatorValues.GreaterThanOrEqual,\n                \"lessthanorequal\" => DataValidationOperatorValues.LessThanOrEqual,\n                _ => throw new ArgumentException($\"Unknown operator: {dvOp}\")\n            };\n        }\n\n        if (properties.TryGetValue(\"formula1\", out var dvFormula1))\n        {\n            // R28-A1 — reject empty formula1 for type=list. Excel renders an empty\n            // dropdown (or rejects the file outright depending on form), and the\n            // user almost certainly meant to provide options like \"1,2,3\".\n            if (dv.Type?.Value == DataValidationValues.List\n                && string.IsNullOrWhiteSpace(dvFormula1.Trim('\"')))\n                throw new ArgumentException(\n                    \"Property 'formula1' is empty for validation type=list; supply options like formula1=\\\"1,2,3\\\" or a range reference.\");\n            // Excel caps data-validation formulas at 255 chars; longer ones\n            // pass schema validation but the file is refused (0x800A03EC).\n            if (dvFormula1.Length > 255)\n                throw new ArgumentException(\n                    $\"validation formula1 is {dvFormula1.Length} chars; Excel's limit is 255. Put the list in a range and reference it instead.\");\n            // Embedded double quotes inside a literal list (not a range ref)","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Tables.cs#L540-L576","documentation":"Thrown by AddValidation when the optional \"operator\" property is present but its lower-cased value is not one of between, notbetween, equal, notequal, greaterthan, lessthan, greaterthanorequal, lessthanorequal. These map to DataValidationOperatorValues; an unrecognized token is rejected rather than silently defaulting.","triggerScenarios":"Call Add type \"validation\" with properties[\"operator\"] set to an out-of-set value (e.g. \">=\", \"gte\", \"not equal\", \"gt\").","commonSituations":"Passing a symbol (>=) or abbreviation instead of the camelCase token; including a space; typos; mixing conditional-formatting operator vocabulary with data-validation vocabulary.","solutions":["Use a token from the set, e.g. greaterThanOrEqual, notBetween (case-insensitive, no spaces).","Translate symbols: >= -> greaterThanOrEqual, <= -> lessThanOrEqual, <> -> notEqual.","Validate the operator against the allowed set before calling."],"exampleFix":"// before\nhandler.Add(\"/Sheet1\", \"validation\", null,\n    new() { [\"sqref\"] = \"A1:A5\", [\"type\"] = \"whole\", [\"operator\"] = \">=\" });\n// after\nhandler.Add(\"/Sheet1\", \"validation\", null,\n    new() { [\"sqref\"] = \"A1:A5\", [\"type\"] = \"whole\", [\"operator\"] = \"greaterThanOrEqual\" });","handlingStrategy":"type-guard","validationCode":"static readonly HashSet<string> DvOps = new(StringComparer.OrdinalIgnoreCase)\n    { \"between\", \"notbetween\", \"equal\", \"notequal\", \"greaterthan\", \"lessthan\",\n      \"greaterthanorequal\", \"lessthanorequal\" };\nif (properties.TryGetValue(\"operator\", out var o) && !DvOps.Contains(o))\n    throw new ArgumentOutOfRangeException($\"bad operator '{o}'\");","typeGuard":"static bool IsValidValidationOperator(string? o) =>\n    o is not null && (new[] { \"between\", \"notbetween\", \"equal\", \"notequal\", \"greaterthan\",\n        \"lessthan\", \"greaterthanorequal\", \"lessthanorequal\" }).Contains(o, StringComparer.OrdinalIgnoreCase);","tryCatchPattern":null,"preventionTips":["Translate symbols to tokens (>= -> greaterThanOrEqual, <> -> notEqual).","Strip whitespace and lower-case operator values before calling.","Keep the operator vocabulary separate from conditional-formatting operators."],"tags":["excel","validation","operator","enum"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}