I have 2 ViewModels:
public class AViewModel
{
public string Text {get; set;}
//some other properties
}
And:
public class BViewModel
{
public List<AViewModel> List {get; set;}
//some other properties
}
I'm passing BViewModel
to View
and by default displaying 4 inputs for my list. I would like to achieve that validation is successful only if 2 or more inputs are non-empty, so my List
in viewmodel must contain 2 AViewModel
objects which have non-empty Text
property.
How can I achieve that?
Should I try to write custom validation attribute or is there any other way?