-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Feature] The new MVVM-Library should allow to run validation manually #3665
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
Comments
Hello, 'timunie! 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! |
Looping in @Sergio0694 to provide insight on this and see if this is suitable for the library. |
Thanks for the info @timunie. I know there's been some discussions on validation after we shipped the last preview I believe. It's good to get some background on the scenario you're trying to accomplish here. @Sergio0694 have any changes been made since or does this help to provide background on any changes we should make before shipping? |
@timunie Thank you for the suggestion! I agree that those two scenarios would be helpful, we're looking into that 😄 @michael-hawker What I've added recently were those new That said, if we decide it's fine to offer these two APIs since the initial version, and to have these two be backed by reflection to work, I can certainly try working on a draft implementation for them so we can continue the conversation about this 😊 |
Hi @Sergio0694 and @michael-hawker I am very impressed by this fast answers. 👍 I created a short testing app to show the issue and test improvements. Basically it show the scenarios explained above. https://github.com/timunie/MvvmToolkitValidationSample If there is anything else I can do to support you feel free to ping me. Happy coding |
Would you mind if I take your current implementation and modify it to my needs? It would be available in my own library and will be removed when this package is stable and released. If I should not make it open source I can also just use it privately. |
The package is MIT licensed, so you certainly can fork the library and customize it to fit your needs, even more so if you only plan to use that privately. If making these changes will unblock you for now before they're eventually shipped officially, then sure, that's a perfectly valid approach to take 😄 I'll experiment with these suggested changes on my end too and will see if I can integrate them in #3428 🙂 |
Faster support than I am used to for paid programs. Incredible. I have my changes here:
It basically just adds the following methods If I should send you a PR let me know. Happy coding |
Well I guess we can discuss other APIs to introduce and how (in particular, one to validate everything), but for starters, making |
Hi @Sergio0694 I tested your changes in my own library and can confirm that this would be a solution for my use case. I am really looking forward to the release. Thank you and have a great weekend 🙏 |
Glad I could help, and thank you for the valuable feedbacks! 😄 |
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 numberb=5
. If nowb
changes tob=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 orValidateAll()
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
The class on startup - It is not validated as the values were
null
at start upThe same view after typing a letter and reset it to
null
again. I want this view on start upThe text was updated successfully, but these errors were encountered: