I have a DTO class that implements self-validation. Can the PropertyProxyValidator call this self-validation?
For example:
public class Volunteer
{
[StringLengthValidator(1, 50, MessageTemplate = "Last Name is between 1 and 50 characters")]
[NotNullValidator(MessageTemplate = "Last Name is required")]
public string LastName { get; set; }
}
Works with PropertyProxyValidator
But
[HasSelfValidation]
public class Volunteer(
public string LastName { get; set; }
public void ValidateFirstName(ValidationResults results)
{
if (LastName != null && LastName.Length > 50)
{
results.AddResult(new ValidationResult("LastName is between 1 and 50 characters",
this, string.Empty, string.Empty, null));
}
}
}
jamie_dixon
Member
5 Points
9 Posts
PropertyProxyValidator && SelfValidation
Apr 20, 2009 02:17 PM|LINK
I have a DTO class that implements self-validation. Can the PropertyProxyValidator call this self-validation?
For example:
public class Volunteer { [StringLengthValidator(1, 50, MessageTemplate = "Last Name is between 1 and 50 characters")] [NotNullValidator(MessageTemplate = "Last Name is required")] public string LastName { get; set; } }Works with PropertyProxyValidator
But
[HasSelfValidation] public class Volunteer( public string LastName { get; set; } public void ValidateFirstName(ValidationResults results) { if (LastName != null && LastName.Length > 50) { results.AddResult(new ValidationResult("LastName is between 1 and 50 characters", this, string.Empty, string.Empty, null)); } } }Does not workropertyProxyValidator SelfValidation