title: How to make "One or more validation errors occurred" raise an exception?
body: <p>I'm running a WebAPI on Core 3.1 and one of my endpoints excepts JSON with a model that has fields with <code>[Required]</code> attribute like so:</p>
  <pre><code>public class Vendor
  {
          public int ID { get; set; }
          [Required(ErrorMessage = &quot;UID is required&quot;)]   &lt;&lt;&lt;------ required attribute
          public string UID { get; set; }
  }
  </code></pre>
  <p>When i call this endpoint without setting UID I get the following output as expected:</p>
  <pre><code>{
      &quot;type&quot;: &quot;https://tools.ietf.org/html/rfc7231#section-6.5.1&quot;,
      &quot;title&quot;: &quot;One or more validation errors occurred.&quot;,
      &quot;status&quot;: 400,
      &quot;traceId&quot;: &quot;|7ced8b82-4aa34d65daa99a12.&quot;,
      &quot;errors&quot;: {
          &quot;Vendor.UID&quot;: [
              &quot;UID is required&quot;
          ]
      }
  }
  </code></pre>
  <p>Altho this output is pretty informative and clear it is not consistent with other error outputs that my API produces by means of ExceptionFilter. Is there any way this errors can be routed to the exception filter as well?</p>
  <p>Here is my Startup.cs:</p>
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
              Common.Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddControllers();
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
              services.AddMvc().AddXmlDataContractSerializerFormatters();
              services.AddMvc().AddMvcOptions(options =&gt;
              {
                  options.EnableEndpointRouting = false;
              });
              services.AddMvcCore(options =&gt; options.OutputFormatters.Add(new XmlSerializerOutputFormatter()));
              services.AddOptions();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger&lt;Startup&gt; logger)
          {
  
              //Middleware for exception filtering
              app.UseMiddleware&lt;ErrorHandlingMiddleware&gt;(new ErrorHandlingMiddlewareOptions { logger = logger });
  
              app.UseStaticFiles();            
  
              app.UseHttpsRedirection();
  
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
              });
  
              app.UseMvc(routes =&gt;
              {
                  routes.MapRoute(&quot;EndpointNotFound&quot;, &quot;{*url}&quot;, new { controller = &quot;Error&quot;, action = &quot;EndpointNotFound&quot; });
              });
          }
      }
  </code></pre>