-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] There is no way to pass a ValidationContext to an ObservableValidator #3729
Comments
Hello, 'mdelanno! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future! |
Thanks for the suggestion @mdelanno! Going to open this up for discussion to get further insight from the community members. |
FYI @Sergio0694 |
Hi @mdelanno - thank you for the suggestion! I'm thinking a solution could be to add a second constructor to the class, to basically have something like this: namespace Microsoft.Toolkit.Mvvm.ComponentModel
{
public abstract class ObservableValidator
{
public ObservableValidator();
protected ObservableValidator(ValidationContext context);
}
} The parameterless constructor would just initialize a default
Let me know what you think! |
This would be perfect. I don't think changing the context after instantiation is needed but to be totally transparent, this is the first time I use this interface... |
Describe the problem this feature would solve
I've written a custom validator that I have added to a property via the CustomValidation attribute. This custom validator needs a service and also use ValidationContext.Items dictionary to pass some flags. But I can not tell the ObservableValidator to use my custom context because it creates a new object when it validates the object.
Describe the solution
Add a way to pass a ValidationContext to the ObservableValidator
The text was updated successfully, but these errors were encountered: