I'm using DataAnnotation for client and server validation of my view model. I would like to ask you about the best practices of using custom validation.

I have two forms, which use the same view model:

public class RecipientViewModel
    public string Address1 { get; set; }

    public string Address2 { get; set; }

What I want to achieve, it is that the first form should validate the Address2 field, but the second form did not. Of course my view model is much bigger and I want to do it generic as much as possible.

Is there any possibility to pass a list of fields to be validated and how? For example view could pass it to view model somehow?

Related posts

Recent Viewed