コード例 #1
0
        public static IActionResult FromModelState(ActionContext context)
        {
            var instance = new ValidationFailureResponse();

            instance.ParseFromModelState(context);
            return(instance.GetResponseContext());
        }
コード例 #2
0
        public static IServiceCollection AddSimpleModelValidation(this IServiceCollection services)
        {
            services.Configure <ApiBehaviorOptions>(options => {
                options.InvalidModelStateResponseFactory = context => {
                    return(ValidationFailureResponse.FromModelState(context));
                };
            });

            return(services);
        }