Comments (8)
I will check it out over the weekend. Thank you for reporting this @BenWhite27.
from reactiveui.validation.
@BenWhite27 for a temporary solution, try passing the ImmediateScheduler.Instance
to your ValidationContext
constructor. Instead of doing this:
new ValidationContext();
do this:
// The ImmediateScheduler will make your sample work.
new ValidationContext(ImmediateScheduler.Instance);
Currently, _validationSource
and _validations
won't stay synchronized without the ImmediateScheduler
due to the following code blocks:
This issue takes place here due to DynamicData misuse. Feels like I've broken some stuff while migrating from
ReactiveList<T>
to SourceList<T>
. The _validations
collection is empty when _validationConnectable
ticks on a scheduler other than ImmediateScheduler
. Working on a fix now.from reactiveui.validation.
Hey @BenWhite27 👋,
Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider backing us.
https://opencollective.com/reactiveui
PS.: We offer
priority
support for all backers. Don't forget to addpriority
label when you start backing us 😄
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!
from reactiveui.validation.
Some more info.
View Code Behind
this.Bind(this.ViewModel, vm => vm.Username, v => v.userTxt.Text)
.DisposeWith(disposables);
this.Bind(this.ViewModel, vm => vm.Password, v => v.passTxt.Password)
.DisposeWith(disposables);
this.BindCommand(this.ViewModel, vm => vm.Login, v => v.loginBtn)
.DisposeWith(disposables);
this.BindValidation(this.ViewModel, v => v.errorsTxt.Text)
.DisposeWith(disposables);
ViewModel
public class SampleViewModel : ReactiveObject, ISupportsValidation
{
private ValidationHelper valHelper1;
private ValidationHelper valHelper2;
public SampleViewModel()
{
this.Login = ReactiveCommand.Create(() => { Debug.WriteLine("Login Invoked"); }, this.IsValid());
this.SetupValidations();
}
[Reactive] public string Username { get; set; } = "";
[Reactive] public string Password { get; set; } = "";
public ReactiveCommand<Unit, Unit> Login { get; }
public ValidationContext ValidationContext { get; } = new ValidationContext();
private void SetupValidations()
{
this.valHelper1 = this.ValidationRule(vm => vm.Username,
username => !String.IsNullOrWhiteSpace(username),
"The username cannot be empty");
this.valHelper1.ValidationChanged.Subscribe(change =>
{
Debug.WriteLine("valHelper1.ValidationChanged");
});
this.valHelper2 = this.ValidationRule(vm=>vm.Password,
password => password?.Length > 6,
"The password must be longer than 6");
this.valHelper2.ValidationChanged.Subscribe(change =>
{
Debug.WriteLine("valHelper2.ValidationChanged");
});
this.ValidationContext.ValidationStatusChange.Subscribe(change =>
{
Debug.WriteLine("ValidationContext.ValidationStatusChange");
});
this.ValidationContext.Valid.Subscribe(change =>
{
Debug.WriteLine("ValidationContext.Valid");
});
this.IsValid().Subscribe(valid =>
{
Debug.WriteLine("this.IsValid()");
});
}
}
So whilst running the above and updating text in the ui controls I'll see debug console output like the following.
// These are the initial values coming from the observables.
valHelper1.ValidationChanged
valHelper2.ValidationChanged
ValidationContext.ValidationStatusChange
ValidationContext.Valid
this.IsValid()
// These are during the test
valHelper1.ValidationChanged
valHelper2.ValidationChanged
valHelper2.ValidationChanged
valHelper1.ValidationChanged
Login Invoked
So whilst the rules are updating just fine the state for the whole object is valid all the time and allows me to execute the command.
from reactiveui.validation.
@alexmartinezm Mind having a look at this one?
from reactiveui.validation.
Thanks all. I'll download the source myself tonight when I get home and see if I can pin-point it further, I'm still a rookie with Reactive stuff though 😕
Edit - 16:54
More info.
Adding another ValidationRule at a later point via a command suddenly triggers an update from all objects and I can see some validation errors displayed in the UI. The first 2 rules then seem to function properly but the newly added rule doesn't behave correctly, almost as though the text it's producing is 1 property change behind the current value.
from reactiveui.validation.
Hi there, I'm trying to fix this bug, but I cannot reproduce this on a XF project and I don't have a Windows machine. However, I have a VM but the debug session is a bit slow. I hope to get this fixed this weekend.
from reactiveui.validation.
Thanks @alexmartinezm, I had a look at the code but struggled to get my head around it. If there's anything I can do let me know. I could setup a windows VM with Visual Studio and the repro for you to remote desktop into if that helps?
When I was looking at the code I think everything inside BasePropertyValidation.cs was working, but the flow of sequences doesn't seem to get pass this observable.
from reactiveui.validation.
Related Issues (20)
- feature: Add Xamarin.Android Sample App HOT 2
- feature: Make `ValidationText` immutable, and add `Empty` property. HOT 2
- [BUG] NullReferenceException when using `ReactiveValidationObject` HOT 1
- [BUG] Build failure for uap10.0.17763 target HOT 3
- Make Add and Clear operations immutable. HOT 3
- feature: Add ValidationRule extensions method overloads to accept any object implementing IValidationState HOT 1
- bug: Make nullability warnings errors HOT 2
- [Question] Correct data validation with collection HOT 3
- WPF ValidationRule is not working when call ShowDialog HOT 2
- [Question] How to use ReactiveValidationObject and INotifyDataErrorInfo in WPF HOT 6
- WPF ValidationRule is not working when ShowDialog window HOT 2
- BindValidation throws System.NotSupportedException HOT 4
- feature: Add a MAUI app to samples HOT 2
- [BUG] readme says to use ValidationRule on ReactiveValidationObject but it doesn't exist HOT 5
- [Question] Initial List Validation / Getting IsValid HOT 1
- feature: Bind validation to non-string view properties
- [Bug]: ReactiveValidationObject doesnt work with latest DynamicData version HOT 3
- feature : Multiple validation context support
- [Bug]: HasErrors is incorrect when performing a side effect from WhenAnyPropertyChanged
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveui.validation.