{"record":{"id":"78e54f3dd29a2329","repo":"dotnet/wpf","slug":"sr-format-sr-validationrule-unknownstep-validationrule","errorCode":null,"errorMessage":"SR.Format(SR.ValidationRule_UnknownStep, validationRule.ValidationStep, validationRule)","messagePattern":"SR\\.Format\\(SR\\.ValidationRule_UnknownStep, validationRule\\.ValidationStep, validationRule\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs","lineNumber":1562,"sourceCode":"                        {\n                            case ValidationStep.RawProposedValue:\n                                if (rawValue == DependencyProperty.UnsetValue)\n                                {\n                                    rawValue = GetRawProposedValue();\n                                }\n                                value = rawValue;\n                                break;\n                            case ValidationStep.ConvertedProposedValue:\n                            case ValidationStep.UpdatedValue:\n                            case ValidationStep.CommittedValue:\n                                if (itemValue == DependencyProperty.UnsetValue)\n                                {\n                                    itemValue = Worker.RawValue();\n                                }\n                                value = itemValue;\n                                break;\n                            default:\n                                throw new InvalidOperationException(SR.Format(SR.ValidationRule_UnknownStep, validationRule.ValidationStep, validationRule));\n                        }\n\n                        // lazy-fetch culture (avoids exception when target DP is Language)\n                        if (culture == null)\n                        {\n                            culture = GetCulture();\n                        }\n\n                        validationError = RunValidationRule(validationRule, value, culture);\n                        if (validationError != null)\n                            break;\n                    }\n                }\n            }\n\n            if (needDataErrorRule && validationError == null)\n            {\n                // lazy-fetch culture (avoids exception when target DP is Language)","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs#L1544-L1580","documentation":"During validation, the engine switches on the ValidationRule's ValidationStep to decide what value object to pass to the rule; the default branch throws this InvalidOperationException for any unrecognized step. Since ValidationStep is a closed enum this normally indicates an out-of-range or corrupted enum value rather than an app mistake.","triggerScenarios":"A ValidationRule whose ValidationStep holds an invalid enum value (cast from int, deserialized from bad config/XAML producing a value outside the enum, or a newer enum value from a mismatched framework version hitting an older code path).","commonSituations":"Enum values deserialized from corrupted or hand-edited XAML/BAML; binary-formatted settings carrying an out-of-range ValidationStep; framework version mismatch where a rule was defined against a newer ValidationStep.","solutions":["Set ValidationRule.ValidationStep to a valid value: RawProposedValue, ConvertedProposedValue, UpdatedValue, or CommittedValue","Check XAML/config for the rule's ValidationStep value and correct typos or out-of-range numbers","Verify assembly/framework versions agree between the rule definition and the WPF runtime"],"exampleFix":"// before\nrule.ValidationStep = (ValidationStep)99; // throws ValidationRule_UnknownStep\n// after\nrule.ValidationStep = ValidationStep.ConvertedProposedValue;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(ValidationStep), rule.ValidationStep)) throw new InvalidOperationException(\"ValidationStep out of range\");","typeGuard":"static bool IsKnownStep(ValidationStep s) => s is ValidationStep.RawProposedValue or ValidationStep.ConvertedProposedValue or ValidationStep.UpdatedValue or ValidationStep.CommittedValue;","tryCatchPattern":"try { RunValidation(rule); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"ValidationStep\")) { rule.ValidationStep = ValidationStep.ConvertedProposedValue; }","preventionTips":["Only assign literal ValidationStep enum members; never cast raw ints","Validate deserialized enum values with Enum.IsDefined","Keep WPF assemblies versions aligned with rule definitions"],"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"}