Skip to content

[Feature] The new MVVM-Library should allow to run validation manually #3665

@timunie

Description

@timunie

Describe the problem this feature would solve

I tried the new MVVM Library and it suits my needs very well. I used the ObservableValidator to send messages to the user if something is wrong or missing. Unfortunately the validation will only apply if the value is set and actually changed. There might be usecases where the value did not change but needs to be validated again anyway.

Example: You have a number a=10 that may not exceed another number b=5. If now b changes to b=20 a=10 is now valid but will not be validated because it did not change.

Another example if if you want to validate the class right after creation and want to mark properties that still hold the default value of null

Describe the solution

The user can call ValidateProperty(string PropertyName) to validate a property or ValidateAll() to validate the entire class.

Describe alternatives you've considered

Set the value to something different and restore the old value then. But IMO this is not a good practise.

Additional context & Screenshots

image
The class on startup - It is not validated as the values were null at start up

image
The same view after typing a letter and reset it to null again. I want this view on start up

Metadata

Metadata

Assignees

Labels

In-PR 🚀feature request 📬A request for new changes to improve functionalitymvvm-toolkit 🧰Issues/PRs for the Microsoft.Toolkit.Mvvm package

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions