Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected ObservableValidator(ValidationContext validationContext)
}

/// <inheritdoc/>
[Display(AutoGenerateField = false)]
public bool HasErrors => this.totalErrors > 0;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,20 @@ public void Test_ObservableValidator_ValidateAllProperties_IncludeInheritedPrope
Assert.IsFalse(model.HasErrors);
Assert.IsTrue(events.Count == 1);

Assert.IsTrue(events.Any(e => e.PropertyName == nameof(DerivedModelWithValidatableProperties.Name))); }
Assert.IsTrue(events.Any(e => e.PropertyName == nameof(DerivedModelWithValidatableProperties.Name)));
}

// See https://github.com/CommunityToolkit/dotnet/issues/881
[TestMethod]
public void Test_ObservableValidator_HasErrors_IncludeNonAutogenerateAttribute()
{
DerivedModelWithValidatableProperties model = new();

DisplayAttribute? displayAttribute = model.GetType().GetProperty(nameof(ObservableValidator.HasErrors))?.GetCustomAttribute<DisplayAttribute>();

Assert.IsNotNull(displayAttribute);
Assert.IsFalse(displayAttribute.AutoGenerateField);
}

public class Person : ObservableValidator
{
Expand Down