-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValidationContext.MemberName is set incorrectly in the DataAnnotationsModelValidator #120
Comments
@dougbu, please associate the fix we've discussed with this bug. //cc: @danroth27 |
For historical interest: Was a PR for this in the old CodePlex repo http://aspnetwebstack.codeplex.com/SourceControl/network/forks/astolfoho/fixWebApi/contribution/8918. But, I can't find an earlier issue on this. |
- #120 `ValidationAttribute` classes that (incorrectly) expected `MemberName` to always be set or that instantiate `ValidationResult`s using the `DisplayName` may be negatively impacted. For exmaple, `MemberName` will be `null` when binding parameters and items in a collection.
Moved to 3.2.5 (really 3.2.5-preview1). |
- #120 - revert to previous behavior if `webapi:UseLegacyValidationMemberName` application setting is `true`
I still see this problem. |
This fix is in MVC 5.2.5 preview 1 and later, not 5.2.4. FYI the commit date may be much earlier than when the changes are merged into the |
Problem Description
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.
ValidationContext.MemberName is "TestValue3"
ValidationContext.MemberName is "Display name From 'DisplayAttribute'"
TestValue3 is set "DisplayAttribute".
The text was updated successfully, but these errors were encountered: