You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Add Validation to ReactiveProperty (#3777)
<!-- Please be sure to read the
[Contribute](https://github.com/reactiveui/reactiveui#contribute)
section of the README -->
**What kind of change does this PR introduce?**
<!-- Bug fix, feature, docs update, ... -->
Feature for #3771
**What is the current behavior?**
<!-- You can also link to an open issue here. -->
ReactiveProperty has basic functionality
**What is the new behavior?**
<!-- If this is a feature change -->
ReactiveProperty now supports Validation through INotifyDataErrorInfo
AddValidation and AddValidationError methods added to attach the
ReactiveProperty to the Validation mechanism
CheckValidation and Refresh exist to re-evaluate the Validation
```c#
MyReactiveProperty = new ReactiveProperty<string>()
.AddValidation(() => MyReactiveProperty)
.AddValidationError(s => string.IsNullOrWhiteSpace(s) ? "required" : null);
```
**What might this PR break?**
None expected.
**Please check if the PR fulfills these requirements**
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
**Other information**:
public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
357
360
{
@@ -753,18 +756,37 @@ namespace ReactiveUI
753
756
public ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) { }
754
757
public TSender Sender { get; }
755
758
}
759
+
public static class ReactivePropertyMixins
760
+
{
761
+
public static ReactiveUI.ReactiveProperty<T> AddValidation<T>(this ReactiveUI.ReactiveProperty<T> self, System.Linq.Expressions.Expression<System.Func<ReactiveUI.ReactiveProperty<T>?>> selfSelector) { }
762
+
public static System.IObservable<string?> ObserveValidationErrors<T>(this ReactiveUI.ReactiveProperty<T> self) { }
763
+
}
756
764
[System.Runtime.Serialization.DataContract]
757
-
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
765
+
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.ComponentModel.INotifyDataErrorInfo, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
758
766
{
759
767
public ReactiveProperty() { }
760
768
public ReactiveProperty(T? initialValue) { }
761
-
public ReactiveProperty(T? initialValue, System.Reactive.Concurrency.IScheduler? scheduler) { }
769
+
public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues) { }
public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
357
360
{
@@ -753,18 +756,37 @@ namespace ReactiveUI
753
756
public ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) { }
754
757
public TSender Sender { get; }
755
758
}
759
+
public static class ReactivePropertyMixins
760
+
{
761
+
public static ReactiveUI.ReactiveProperty<T> AddValidation<T>(this ReactiveUI.ReactiveProperty<T> self, System.Linq.Expressions.Expression<System.Func<ReactiveUI.ReactiveProperty<T>?>> selfSelector) { }
762
+
public static System.IObservable<string?> ObserveValidationErrors<T>(this ReactiveUI.ReactiveProperty<T> self) { }
763
+
}
756
764
[System.Runtime.Serialization.DataContract]
757
-
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
765
+
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.ComponentModel.INotifyDataErrorInfo, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
758
766
{
759
767
public ReactiveProperty() { }
760
768
public ReactiveProperty(T? initialValue) { }
761
-
public ReactiveProperty(T? initialValue, System.Reactive.Concurrency.IScheduler? scheduler) { }
769
+
public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues) { }
public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
357
360
{
@@ -753,18 +756,37 @@ namespace ReactiveUI
753
756
public ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) { }
754
757
public TSender Sender { get; }
755
758
}
759
+
public static class ReactivePropertyMixins
760
+
{
761
+
public static ReactiveUI.ReactiveProperty<T> AddValidation<T>(this ReactiveUI.ReactiveProperty<T> self, System.Linq.Expressions.Expression<System.Func<ReactiveUI.ReactiveProperty<T>?>> selfSelector) { }
762
+
public static System.IObservable<string?> ObserveValidationErrors<T>(this ReactiveUI.ReactiveProperty<T> self) { }
763
+
}
756
764
[System.Runtime.Serialization.DataContract]
757
-
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
765
+
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.ComponentModel.INotifyDataErrorInfo, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
758
766
{
759
767
public ReactiveProperty() { }
760
768
public ReactiveProperty(T? initialValue) { }
761
-
public ReactiveProperty(T? initialValue, System.Reactive.Concurrency.IScheduler? scheduler) { }
769
+
public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues) { }
public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging
355
358
{
@@ -751,18 +754,37 @@ namespace ReactiveUI
751
754
public ReactivePropertyChangingEventArgs(TSender sender, string? propertyName) { }
752
755
public TSender Sender { get; }
753
756
}
757
+
public static class ReactivePropertyMixins
758
+
{
759
+
public static ReactiveUI.ReactiveProperty<T> AddValidation<T>(this ReactiveUI.ReactiveProperty<T> self, System.Linq.Expressions.Expression<System.Func<ReactiveUI.ReactiveProperty<T>?>> selfSelector) { }
760
+
public static System.IObservable<string?> ObserveValidationErrors<T>(this ReactiveUI.ReactiveProperty<T> self) { }
761
+
}
754
762
[System.Runtime.Serialization.DataContract]
755
-
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
763
+
public class ReactiveProperty<T> : ReactiveUI.ReactiveObject, ReactiveUI.IReactiveProperty<T>, System.ComponentModel.INotifyDataErrorInfo, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, System.IObservable<T?>, System.Reactive.Disposables.ICancelable
756
764
{
757
765
public ReactiveProperty() { }
758
766
public ReactiveProperty(T? initialValue) { }
759
-
public ReactiveProperty(T? initialValue, System.Reactive.Concurrency.IScheduler? scheduler) { }
767
+
public ReactiveProperty(T? initialValue, bool skipCurrentValueOnSubscribe, bool allowDuplicateValues) { }
0 commit comments