{"record":{"id":"f0292a8dbc1e4da7","repo":"dotnet/wpf","slug":"sr-format-sr-validationrule-unknownstep-validationstep","errorCode":null,"errorMessage":"SR.Format(SR.ValidationRule_UnknownStep, validationStep, bindingGroup)","messagePattern":"SR\\.Format\\(SR\\.ValidationRule_UnknownStep, validationStep, bindingGroup\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs","lineNumber":2105,"sourceCode":"        {\n            if (!NeedsValidation)\n                return true;\n\n            object value;\n            switch (validationStep)\n            {\n                case ValidationStep.RawProposedValue:\n                    value = GetRawProposedValue();\n                    break;\n                case ValidationStep.ConvertedProposedValue:\n                    value = bindingGroup.GetValue(this);\n                    break;\n                case ValidationStep.UpdatedValue:\n                case ValidationStep.CommittedValue:\n                    value = this;\n                    break;\n                default:\n                    throw new InvalidOperationException(SR.Format(SR.ValidationRule_UnknownStep, validationStep, bindingGroup));\n            }\n\n            return Validate(value, validationStep);\n        }\n\n        /// <summary>\n        /// Get the proposed value(s) that would be written to the source(s), applying\n        /// conversion and checking UI-side validation rules.\n        /// </summary>\n        internal override bool ValidateAndConvertProposedValue(out Collection<ProposedValue> values)\n        {\n            Debug.Assert(NeedsValidation, \"check NeedsValidation before calling this\");\n            values = null;\n\n            // validate raw proposed value\n            object rawValue = GetRawProposedValue();\n\n            bool isValid = Validate(rawValue, ValidationStep.RawProposedValue);","sourceCodeStart":2087,"sourceCodeEnd":2123,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs#L2087-L2123","documentation":"In BindingExpression.ValidateWithoutUpdate/Validate flow, the validationStep parameter selects which value object is handed to the rule (proposed values, the expression itself, etc.); the default branch throws this InvalidOperationException for any step outside the known set. Like error 2478, a closed-enum guard indicating corrupted or unsupported ValidationStep input.","triggerScenarios":"Calling the internal validation path with a validationStep value not in RawProposedValue/ConvertedProposedValue/UpdatedValue/CommittedValue — via invalid enum casts, corrupted deserialized values, or custom BindingExpressionBase subclasses passing wrong steps.","commonSituations":"Custom binding-group/expression extensions (e.g. bespoke BindingGroup implementations) passing unexpected steps; enum deserialized from bad persisted state; framework version drift between rule and engine.","solutions":["Pass only valid ValidationStep values when invoking validation","Fix enum deserialization/persistence so ValidationStep never exceeds the defined range","Update custom binding subclasses to map steps correctly before calling Validate"],"exampleFix":"// before\nexpr.ValidateWithoutUpdate((ValidationStep)42, bindingGroup); // throws\n// after\nexpr.ValidateWithoutUpdate(ValidationStep.UpdatedValue, bindingGroup);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(ValidationStep), validationStep)) throw new InvalidOperationException(\"Unknown ValidationStep\");","typeGuard":"static bool IsSupportedStep(ValidationStep s) => Enum.IsDefined(typeof(ValidationStep), s);","tryCatchPattern":"try { Validate(value, validationStep); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"ValidationStep\")) { /* normalize step and retry */ }","preventionTips":["Pass only closed-set ValidationStep values in custom binding internals","Guard persisted/deserialized ValidationStep values","Map custom steps onto the four standard ValidationStep members before calling engine APIs"],"tags":["wpf","data-binding","validation-rule","invalid-enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}