public static IServiceCollection AddModelStateValidator(this IServiceCollection services, ModelStateValidatorStrings strings = null, int order = -1) { services.Configure <ApiBehaviorOptions>(options => { options.SuppressModelStateInvalidFilter = true; }); services.AddSingleton(strings ?? new ModelStateValidatorStrings()); return(order > -1 ? services.Configure <MvcOptions>(i => i.Filters.Add <ModelStateValidator>(order)) : services.Configure <MvcOptions>(i => i.Filters.Add <ModelStateValidator>())); }
public ModelStateValidator(ModelStateValidatorStrings strings) { _strings = strings; }