Will the ValidationResult.MemberNames property contain more than one value?

I was looking for a reflector, and I could not find a case where it ValidationResult.MemberNamesshould contain more than one value.

So, first of all, I wonder why MS should have done this IEnumerable<string>, and now that they have already done this, can I rely on this property to return only one value?

Update
As for the DataAnnotations validation system, I find it more messy:

  • TryValidatePropertyand TryValidateObjectshould have removed errors from the validationResults parameter if they no longer exist.
  • ValidationResult should override Equals and GetHashCode.
  • Why is ValidationResult.ErrorMessage changed !? I can not organize EqualityComparer myself!
  • If the DataTypeAttribute is used only for presentation purposes, why does it inherit the ValidationAttribute, which is simply misleading, I had to fight until I realized (after reflexing) that it would not work. MS just did not implement it.

And this list goes on.

+3
source share
1 answer

Consider the password and password confirmation. Or any Start / Stop values ​​or any other cross field check.

+2
source

Source: https://habr.com/ru/post/1759243/


All Articles