I have these classes:
public class RequestModel
{
[Required]
public string name { get; set; }
[Required]
public List<AnotherClass> anotherClassList { get; set; }
}
public class AnotherClass
{
[Required]
public string anotherName { get; set; }
[Required]
public List<ThirdClass> third { get; set; }
}
public class ThirdClass
{
[Required] public string foo3;
[Required]
public FourthClass four;
}
public class FourthClass
{
[Required]
public string foo4 { get; set; }
[Required]
public string bar4
And this controller
public async Task<IActionResult> ValidateModelProperly([FromBody] RequestModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
return NoContent();
}
And only the [Required] properties from RequestModel and AnotherClass is validated by the framework. The two remaining classes are completely ignored (properties just set to null if i omit them from the json body).
Is there some limitation by the framework, or what the heck is happening?