You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My customer creating custom validation class which deliveerd from System.ComponentModel.DataAnnotations.ValidationAttribute.
Using this in .NET4.7.1 ASP.NET Web API 2.0, ValidationContext.MemberName is set "DisplayName".
This is problem for custom class because they can not know MemberName without this property.
Expected behavior
ValidationContext.MemberName is "TestValue3"
Actual behavior
ValidationContext.MemberName is "Display name From 'DisplayAttribute'"
TestValue3 is set "DisplayAttribute".
public class TestModel
{
[Validations.CustomValidation]
public string TestValue1 { get; set; }
[Validations.CustomValidation(ErrorMessage = "ErrorMessage: {0} ErrorMessage")]
public string TestValue2 { get; set; }
[Validations.CustomValidation(ErrorMessage = "ErrorMessage: {0} ErrorMessage")]
[Display(Name = "Display name From 'DisplayAttribute'")]
public string TestValue3 { get; set; }
public string Message { get; set; }
}