title: How to fix validation errors Response in Netcore 2.2 Web API
body: <p>I'm handling asp.netcore-2.2 errors but I'm still getting ErrorMessage details from Response</p>
  
  <p>I have a login and register methods with a required username, password and a required password length for registration between 8 and 4 characters the problem is that I get the error messages expected or handled for the login method and I get validation error when I register with empty username and password. </p>
  
  <p>I added this code in ConfigureApiBehaviorOptions: </p>
  
  <pre><code>options.SuppressModelStateInvalidFilter = true;
  </code></pre>
  
  <p>and this I tried this option too:</p>
  
  <pre><code>options.SuppressUseValidationProblemDetailsForInvalidModelStateResponses = true;
  </code></pre>
  
  <p>but it doesn't work.  </p>
  
  <p>This is my Register DTO:</p>
  
  <pre><code>using System.ComponentModel.DataAnnotations;
  
  namespace DatingApp.Api.Dtos
  {
      public class UserForRegisterDto
      {
          [Required]
          public string Username { get; set; }
          [Required]
          [StringLength(8, MinimumLength= 4, ErrorMessage= "password between 4 and 8 charracters")]
          public string Password { get; set; }
      }
  }
  </code></pre>
  
  <p>I expected this error message: </p>
  
  <blockquote>
    <p>"password between 4 and 8 charracters"</p>
  </blockquote>
  
  <p>but I get this before I change <code>ConfigureApiBehaviorOptions</code>:</p>
  
  <blockquote>
    <p>"title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "0HLJIO56EGJEV:00000001"</p>
  </blockquote>
  
  <p>and a full table with error detail if I use <code>ConfigureApiBehaviorOptions</code>.</p>