Closed CodingOctocat closed 1 month ago
Fixed: The validationContext.MemberName must be provided manually.
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
{
if (value is IEnumerable<ICheckable> items)
{
if (items.Any(x => x.IsChecked))
{
return ValidationResult.Success;
}
// The validationContext.MemberName must be provided manually.
return new ValidationResult(ErrorMessage, [validationContext.MemberName!]);
}
return null;
}
Describe the bug
I'm using MAUI and I like to use ValidationAttribute to handle data validation, to simplify matters I made a simple WPF sample.
I customized a ValidationAttribute to check if the elements in the collection satisfy the conditions.
GetErrorsIssue.zip
Regression
No response
Steps to reproduce
Expected behavior
MemberNames should Contains property names ProjectItems
Screenshots
No response
IDE and version
VS 2022
IDE version
17.9.6
Nuget packages
Nuget package version(s)
8.2.2
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item