Skip to content

Commit 0ea848e

Browse files
worldbeaterglennawatson
authored andcommitted
Fix ReactiveValidationObject<T> concurrency issues (#54)
* Update ReactiveValidationObject.cs * Don't rely on IsValid observable * Update tests to comply the new behavior
1 parent 433f19e commit 0ea848e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/ReactiveUI.Validation.Tests/NotifyDataErrorInfoTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ public void ShouldFireErrorsChangedEventWhenValidationStateChanges()
113113
Assert.False(viewModel.ValidationContext.IsValid);
114114
Assert.Single(viewModel.ValidationContext.Validations);
115115
Assert.Single(viewModel.GetErrors("Name").Cast<string>());
116-
Assert.Null(arguments);
117116

118117
viewModel.Name = "JoJo";
119118

120119
Assert.False(viewModel.HasErrors);
121120
Assert.Empty(viewModel.GetErrors("Name").Cast<string>());
122121
Assert.NotNull(arguments);
123-
Assert.Equal("Name", arguments.PropertyName);
122+
Assert.Equal(string.Empty, arguments.PropertyName);
124123
}
125124
}
126125
}

src/ReactiveUI.Validation/Helpers/ReactiveValidationObject.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ protected ReactiveValidationObject(IScheduler scheduler = null)
3838
.Select(valid => !valid)
3939
.ToProperty(this, x => x.HasErrors, scheduler: scheduler);
4040

41-
ValidationContext
42-
.ValidationStatusChange
43-
.CombineLatest(Changed, (_, change) => change.PropertyName)
44-
.Where(name => name != nameof(HasErrors))
45-
.Select(name => new DataErrorsChangedEventArgs(name))
41+
ValidationContext.ValidationStatusChange
42+
.Select(validity => new DataErrorsChangedEventArgs(string.Empty))
4643
.Subscribe(args => ErrorsChanged?.Invoke(this, args));
4744
}
4845

0 commit comments

Comments
 (0)