I have a set of models that looks similar to this
public class OtherModel
{
[Required]
string name { get; set; }
}
public class OthersEditModel
{
List<OtherModel> others { get; set; }
}
I then have a controller method that looks like this
[HttpPost]
public ActionResult EditOthers(OthersEditModel others)
{
if(ModelState.IsValid)
{
// Save
}
}
My problem is that the ModelState.IsValid
isn't triggering the validation of the objects in the list.
How do I accomplish this, or is it even possible?
Or alternatively can I manually trigger the validation of the elements in the list?