reactiveui / reactiveui/ReactiveUI.Validation
[Question] Initial List Validation / Getting IsValid
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 275
- Forks
- 29
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 9
Description
I'm trying to do something very simple. I want to validate that the Sources ObservableCollection is not empty.
var sourceNotEmpty = Sources
.ToObservableChangeSet(x => x.Path)
.ToCollection()
.Select(x => x.Any());
this.ValidationRule(x => x.Sources,
sourceNotEmpty,
"You must select source files or folders to encode");
Testing GetErrors works except for this test. It fails because the ValidationRule hasn't yet been evaluated. If I add an item and then remove it, then it works.
[Fact]
public void GetErrors_SourceEmpty_Error()
{
var errors = Model.GetErrors(nameof(Model.Sources));
Assert.Single(errors); // errors is empty
}
Then, how do I get IsValid? Before doing some work in the ViewModel, I first need to check "IsValid" but haven't yet found the way to get the current value. LastAsync won't work if it hasn't yet been evaluated.
[Fact]
public void IsValid_MissingData_ReturnsFalse()
{
bool? result = null;
Model.IsValid().Do(x => result = x);
Assert.False(result);
}
These 2 things are extremely simple but there's probably something I'm missing with the whole paradigm?
Adding to this, on the UI, I probably don't want to display all the "field missing" errors right away, but only when he tries to click Submit or re-empties a field after typing in it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing GetErrors_SourceEmpty_Error and IsValid_MissingData_ReturnsFalse using the Sources, ValidationRule, GetErrors, IsValid, and LastAsync entry points mentioned in the issue. Review the validation lifecycle and existing UI error-display guidance; done should define initial evaluation, current validity access, and deferred display behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100