we have a web api in .net 6
public async Task<MyResult> SeriesDataV21([FromBody] SeriesDataRequest seriesDataRequest)
{
}
The request object SeriesDataRequest has an enum and I added a converter to accept string. option.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
However, if the enum in the request is not valid, the seriesDataRequest is passed in as null. Is there a way to ask .net 6 to directly throwing an exception? As we have multiple endpoints and it is much easier if an exception got thrown out by .net other than we manually check the request everywhere.