System.ComponentModel.DataAnnotations.Validator does not validate StringLengthAttribute unless "validateAllProperties" specified - by Daniel Mork

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 672247 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 6/1/2011 12:28:41 PM
Access Restriction Public


The ValidateObject and TryValidateObject methods of the Validator class does not validate StringLengthAttribute instances on a target object unless the overloaded method is used where validateAllProperties:true is specified.

Based on the documentation of the two method signatures, "validateAllProperties" implies a deep (or recursive) validation into an object graph. Therefore the method signatures which omit this parameter should still validate string properties. Are you perhaps checking the property type and skipping object types while validating value types which may be a logic error since System.String is virtually a value type?
Sign in to post a comment.
Posted by mliesmons on 10/12/2011 at 5:48 AM
I do not see from the doc that there is a recursive, deep validation in the graph when the boolean is set to true, and this does not happen either.
However, this is something I would be looking for, a real deep (parent/child/...) recursive validation option.
Posted by Microsoft on 7/20/2011 at 10:10 AM
This behavior is by design and unfortunately cannot be changed as it is relied upon by other consuming frameworks.
Posted by MS-Moderator10 [Feedback Moderator] on 6/1/2011 at 9:24 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 6/1/2011 at 2:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(