I know how to create custom validation attributes and I know how to make ASP.MVC client validation work with those attributes if I implement IClientValidatable interface, but then I would need to reference System.Web.MVC in the library containing my CSLA objects.
Is it possible to create a custom validation attribute that will be recognized by MVC without having to implement IClientValidatable?
Something that works as System.ComponentModel.DataAnnotations.RequiredAttribute and that can be applied to CSLA properties without referencing System.Web.MVC.
Any custom validation attribute that inherits from System.ComponentModel.DataAnnotations.ValidationAttribute will be used by the CSLA rule engine - just as the RequiredAttribute is.
See this excercise on MSDN on how to create custom validation rules and plugin to ASP.NET MVC 3:
Thanks for your answer.
Yes, I already know how to create an attribute that inherit from ValidationAttribute and is recognized by CSLA.
My question is about how to make that attribute in a way that is recognized by MVC to generate the HTML needed for the unobtrusive validation to work, without having to reference System.Web.MVC in my class library.
If I follow the tutorial I would have to implement IClientValidatable and then if I try to apply my attribute to a property, I will need to reference System.Web.MVC in my class library. At least that is what I understood.
Copyright (c) Marimer LLC