Min Length Custom AbstractValidationAttribute and Implementing Castle.Components.Validator.IValidato

Posted by CRice on Stack Overflow See other posts from Stack Overflow or by CRice
Published on 2010-04-21T11:29:29Z Indexed on 2010/04/21 11:33 UTC
Read the original article Hit count: 375

Filed under:
|

I see with the Castle validators I can use a length validation attribute.

    [ValidateLength(6, 30, "some error message")]
    public string SomeProperty { get; set; }

I am trying to find a MinLength only attribute is there a way to do this with the out of the box attributes?

So far my idea is implementing AbstractValidationAttribute

public class ValidateMinLengthAttribute : AbstractValidationAttribute

and making its Build method return a MinLengthValidator, then using ValidateMinLength on SomeProperty

public class MinLengthValidator : Castle.Components.Validator.IValidator

Does anyone have an example of a fully implemented IValidator or know where such documentation exists?? I am not sure what all the methods and properties are expecting.

Thanks

© Stack Overflow or respective owner

Related posts about castle

Related posts about validation