PropertyProxyValidator && SelfValidationhttp://forums.asp.net/t/1413033.aspx/1?PropertyProxyValidator+SelfValidationMon, 20 Apr 2009 14:17:36 -040014130333104771http://forums.asp.net/p/1413033/3104771.aspx/1?PropertyProxyValidator+SelfValidationPropertyProxyValidator && SelfValidation <p>I have a DTO class that implements self-validation.&nbsp; Can the PropertyProxyValidator call this self-validation?</p> <p>For example:<pre class="prettyprint"><em>public class Volunteer</em> { [StringLengthValidator(1, 50, MessageTemplate = &quot;Last Name is between 1 and 50 characters&quot;)] [NotNullValidator(MessageTemplate = &quot;Last Name is required&quot;)] public string LastName { get; set; } }</pre> <P>&nbsp;Works with PropertyProxyValidator</P> <P>But</P><pre class="prettyprint"><EM> [HasSelfValidation] <SPAN class=kwd>public class</SPAN> Volunteer( <SPAN class=kwd>public string</SPAN> LastName { <SPAN class=kwd>get</SPAN>; <SPAN class=kwd>set</SPAN>; } <SPAN class=kwd>public void</SPAN> ValidateFirstName(ValidationResults results) { <SPAN class=kwd>if</SPAN> (LastName != <SPAN class=kwd>null</SPAN> &amp;&amp; LastName.Length &gt; 50) { results.AddResult(<SPAN class=kwd>new</SPAN> ValidationResult(<SPAN class=st>"LastName is between 1 and 50 characters"</SPAN>, <SPAN class=kwd>this</SPAN>, <SPAN class=kwd>string</SPAN>.Empty, <SPAN class=kwd>string</SPAN>.Empty, <SPAN class=kwd>null</SPAN>)); } } }</EM></pre>&nbsp;Does not work</p> 2009-04-20T14:17:36-04:00