title: Validation of nested class properties in c#
body: <p>I have the following class:</p>
  
  <pre><code>public class Container
  {
      public ContainerDetails Details { get; set; }
  
      public class ContainerDetails
      {
          [MaxLength(50)]
          public string Name { get; set; }
      }
  }
  </code></pre>
  
  <p>on controller I have:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Details([FromBody] Container model)
  {
      if (!ModelState.IsValid)
      {
          throw new Error();
      }
      ...
      return Json();
  }
  </code></pre>
  
  <p>and my <code>ModelState.IsValid</code> always <code>true</code></p>
  
  <p>Can I validate nested class properties without any custom code? And how? Or may be plugin where I can set some attribute to validate it?</p>