reactiveui / ReactiveUI.Validation

Validation helpers for ReactiveUI-based apps.
https://reactiveui.net/docs/handbook/user-input-validation
MIT License
235 stars 24 forks source link

feature : Multiple validation context support #511

Open brignolff opened 1 year ago

brignolff commented 1 year ago

Is your feature request related to a problem? Please describe. Had a case where i needed to have validations that stop and block an external process and others that simply display the error without blocking or stopping anything. I also needed to display these validations separately.

Describe the solution you'd like I thinked of having multiple validation contexts in a single ViewModel. To do so I made overloads for the "ValidationRule(...)" and "BindValidation(...)" methods. I added a "Func<TViewModel, ValidationContext> validationContextProperty" parameter to those methods and use it instead of the one present by default in the "IValidatableViewModel" interface.

Describe alternatives you've considered An alternative could have been to create multiple validation classes inheriting from IValidationComponent but that also means adding methods to add them to the validation context. I would also need to create functions to filter them in order to know if a validation of type x is false.

Describe suggestions on how to achieve the feature Made modifications of the code of this repo and uploaded everything on this github in the multiple validation context branch. https://github.com/brignolff/Mdified.ReactiveUI.Vaidation/tree/multiple_validation_contexts