public static IActionResult FromModelState(ActionContext context) { var instance = new ValidationFailureResponse(); instance.ParseFromModelState(context); return(instance.GetResponseContext()); }
public static IServiceCollection AddSimpleModelValidation(this IServiceCollection services) { services.Configure <ApiBehaviorOptions>(options => { options.InvalidModelStateResponseFactory = context => { return(ValidationFailureResponse.FromModelState(context)); }; }); return(services); }