How dinamically set validation attributes to a Model MVC 2?

Posted by Tar on Stack Overflow See other posts from Stack Overflow or by Tar
Published on 2010-05-06T17:45:35Z Indexed on 2010/05/06 17:48 UTC
Read the original article Hit count: 133

Filed under:
|

Lets says I have the following model

public class Person { [NameIsValid] public string Name { get; set;} public string LastName { get; set; }

}

I created a custom attribute NameIsValid for this model. Lets says for ViewA I need the custom attribute validation in the model, but for ViewB I dont need this custom validation attribute, how can I dinamically set or remove the custom attribute from the model when need it?

Thanks!

© Stack Overflow or respective owner

Related posts about mvc

Related posts about validation